That is great! 
Thank you so much.

-----Original Message-----
From: arun [mailto:smartpink...@yahoo.com] 
Sent: Thursday, August 15, 2013 5:29 PM
To: Ista Zahn
Cc: Pooya Lalehzari; R help
Subject: Re: [R] How can I create a data.table with 1000 variables 
(Var1:Var1000)

Just to add:

You could convert "logi" to "numeric" by:
Large_Table2<-data.frame(matrix(nrow = 0, ncol=1000, dimnames = 
list(c(),paste0("Var", 1:1000))))
str(Large_Table2)
#'data.frame':    0 obs. of  1000 variables:
# $ Var1   : logi
# $ Var2   : logi
# $ Var3   : logi
-------------------
Large_Table2[]<- lapply(Large_Table2,as.numeric)


 str(Large_Table2)
#'data.frame':    0 obs. of  1000 variables:
# $ Var1   : num
# $ Var2   : num
# $ Var3   : num 


Large_Table<- data.frame(lapply(paste0("Var",1:1000),function(x) 
{x1<-data.frame(numeric());colnames(x1)<-x; x1}))


identical(Large_Table,Large_Table2)
#[1] TRUE
A.K.



----- Original Message -----
From: Ista Zahn <istaz...@gmail.com>
To: Pooya Lalehzari <plalehz...@platinumlp.com>
Cc: arun <smartpink...@yahoo.com>; "r-help@r-project.org" <r-help@r-project.org>
Sent: Thursday, August 15, 2013 5:19 PM
Subject: Re: [R] How can I create a data.table with 1000 variables 
(Var1:Var1000)

On Thu, Aug 15, 2013 at 5:09 PM, Pooya Lalehzari <plalehz...@platinumlp.com> 
wrote:
>
> Here is the sample code.
>
> Large_Table = data.frame(
>                   Var1=numeric(),
>                         Var2=numeric(),
>                         Var3=numeric(),
>                         .
>                         .
>                         .
>                         Var1000=numeric())  Ideally, I would like to 
>say  Large_Table = data.frame(
>                   Var1-Var1000=numeric()
>                         )


One way is to create a matrix of the desired dimensions and convert it to a 
data.frame, e.g

data.frame(matrix(nrow = 0, ncol=1000, dimnames = list(c(), paste("Var", 
1:1000))))

Best,
Ista

>
> Or maybe the answer is not to declare them and just create the 
> variables as needed (i.e. in the for-loop that will use the 
> data.frame.)
>
>
> -----Original Message-----
> From: arun [mailto:smartpink...@yahoo.com]
> Sent: Thursday, August 15, 2013 5:04 PM
> To: Pooya Lalehzari
> Subject: Re: [R] How can I create a data.table with 1000 variables 
> (Var1:Var1000)
>
> This question is still not clear.  Could you show a reproducible example as 
> to what you want?  In the title, it says to create 1000 variable and now your 
> explanation is "refer".  Also, it is unclear as to what function in SAS you 
> are referring to.  As Bert said, please follow the posting guide while 
> posting.
> Best.
>
>
>
>
> ----- Original Message -----
> From: Pooya Lalehzari <plalehz...@platinumlp.com>
> To: Bert Gunter <gunter.ber...@gene.com>
> Cc: "r-help@r-project.org" <r-help@r-project.org>
> Sent: Thursday, August 15, 2013 4:27 PM
> Subject: Re: [R] How can I create a data.table with 1000 variables 
> (Var1:Var1000)
>
> Sorry. data.table or even data.frame (as they are related). My question is, 
> if there is a short form to refer to all 1000 of them similar to what exists 
> in SAS.
>
> Thank you,
> Pooya Lalehzari.
>
>
> -----Original Message-----
> From: Bert Gunter [mailto:gunter.ber...@gene.com]
> Sent: Thursday, August 15, 2013 4:24 PM
> To: Pooya Lalehzari
> Cc: r-help@r-project.org
> Subject: Re: [R] How can I create a data_table with 1000 variables 
> (Var1:Var1000)
>
> Please:
>
> 1. Define "data_table"  (??)
>
> 2. Follow the advice from the posting guide link below to post a coherent 
> question.
>
> -- Bert
>
> On Thu, Aug 15, 2013 at 1:16 PM, Pooya Lalehzari <plalehz...@platinumlp.com> 
> wrote:
> > Hello everyone,
> > How can I create a data_table with 1000 variables (Var1:Var1000)?
> >
> > Thank you,
> > Pooya Lalehzari
> >
> >
> >
> > THIS E-MAIL IS FOR THE SOLE USE OF THE INTENDED RECIPIENT(S) AND MAY 
> >CONTAIN CONFIDENTIAL AND PRIVILEGED INFORMATION.ANY UNAUTHORIZED 
> >REVIEW, USE, DISCLOSURE OR DISTRIBUTION IS PROHIBITED. IF YOU ARE NOT 
> >THE INTENDED RECIPIENT, PLEASE CONTACT THE SENDER BY REPLY E-MAIL AND 
> >DESTROY ALL COPIES OF THE ORIGINAL E-MAIL.
> >         [[alternative HTML version deleted]]
> >
> > ______________________________________________
> > R-help@r-project.org mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide
> > http://www.R-project.org/posting-guide.html
> > and provide commented, minimal, self-contained, reproducible code.
>
>
>
> --
>
> Bert Gunter
> Genentech Nonclinical Biostatistics
>
> Internal Contact Info:
> Phone: 467-7374
> Website:
> http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pdb
> -biostatistics/pdb-ncb-home.htm
>
>
>
> THIS E-MAIL IS FOR THE SOLE USE OF THE INTENDED RECIPIENT(S) AND MAY 
> CONTAIN CONFIDENTIAL AND PRIVILEGED INFORMATION.ANY UNAUTHORIZED 
> REVIEW, USE, DISCLOSURE OR DISTRIBUTION IS PROHIBITED. IF YOU ARE NOT 
> THE INTENDED RECIPIENT, PLEASE CONTACT THE SENDER BY REPLY E-MAIL AND DESTROY 
> ALL COPIES OF THE ORIGINAL E-MAIL.
> ______________________________________________
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide 
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
>
>
>
> THIS E-MAIL IS FOR THE SOLE USE OF THE INTENDED RECIPIENT(S) AND MAY 
> CONTAIN CONFIDENTIAL AND PRIVILEGED INFORMATION.ANY UNAUTHORIZED 
> REVIEW, USE, DISCLOSURE OR DISTRIBUTION IS PROHIBITED. IF YOU ARE NOT 
> THE INTENDED RECIPIENT, PLEASE CONTACT THE SENDER BY REPLY E-MAIL AND DESTROY 
> ALL COPIES OF THE ORIGINAL E-MAIL.
>
> ______________________________________________
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide 
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code. 



THIS E-MAIL IS FOR THE SOLE USE OF THE INTENDED RECIPIENT(S) AND MAY CONTAIN
CONFIDENTIAL AND PRIVILEGED INFORMATION.ANY UNAUTHORIZED REVIEW, USE, DISCLOSURE
OR DISTRIBUTION IS PROHIBITED. IF YOU ARE NOT THE INTENDED RECIPIENT, PLEASE
CONTACT THE SENDER BY REPLY E-MAIL AND DESTROY ALL COPIES OF THE ORIGINAL 
E-MAIL.

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to