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) }
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
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
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
4 matches
Mail list logo