Re: [R] using a variable in a subset of a dataframe

2008-04-01 Thread K. Elo
Henrique Dallazuanna wrote (1.4.2008): > You can try this: > > x <- data.frame() > for(i in LETTERS[1:5]) x[1:10, i] <- rnorm(10) > x Or this: --- cut here --- df<-data.frame(0) [obsolet, if df already exists] for (i in 1:10) { df<-data.frame(cbind(df,0)); names(df) [ncol(df)]<-as.character(i) }

Re: [R] using a variable in a subset of a dataframe

2008-04-01 Thread Zaihra T
i m not sure what u really want to do but if ur looking for some subsample of dataset then u might wanna try this (say in case u want to resample ur dataset by column "id" in ur dataset then do resample<-sample(dataset$id,n,replace=F) dataset<-dataset[resample, ] note here n

Re: [R] using a variable in a subset of a dataframe

2008-04-01 Thread Henrique Dallazuanna
You can try this: x <- data.frame() for(i in LETTERS[1:5]) x[1:10, i] <- rnorm(10) x On 01/04/2008, Georg Ehret <[EMAIL PROTECTED]> wrote: > Dear R community,I am using a dataset and would like to define new > variables using a R variable: > > e.g. > > for (i in 1:10){ >dataset$i<-som

[R] using a variable in a subset of a dataframe

2008-04-01 Thread Georg Ehret
Dear R community,I am using a dataset and would like to define new variables using a R variable: e.g. for (i in 1:10){ dataset$i<-something } But this is not the right way, I get only one variable in "dataset"... How can I change this? Thank you! Georg. Georg Ehr