[R] assign

Petr Pikal petr.pikal at precheza.cz
Wed Jan 7 18:34:49 CET 2004


Hi

is it possible for you to use one object (data frame) and assign 
along its collumns?

> x<-rep(0,10)
> x<-cbind(x,x,x,x,x,x)
> x
      x x x x x x
 [1,] 0 0 0 0 0 0
 [2,] 0 0 0 0 0 0
 [3,] 0 0 0 0 0 0
 [4,] 0 0 0 0 0 0
 [5,] 0 0 0 0 0 0
 [6,] 0 0 0 0 0 0
 [7,] 0 0 0 0 0 0
 [8,] 0 0 0 0 0 0
 [9,] 0 0 0 0 0 0
[10,] 0 0 0 0 0 0
> for(i in 1:6) x[,i]<-rnorm(10)


or you can use list in quite similar manner.

Cheers
Petr


On 7 Jan 2004 at 17:53, Perez Martin, Agustin wrote:

> DeaR useRs:
> 
> I would like to assign a values in an object using a loop 'for'.
> This is a reduce example of my problem, my real problem is a few
> complicated:
> 
> for (j in 1:10) {
>  x.j<-rnorm(100)
> }
> 
> I want to create 10 objects as "x.1, x.2, ... , x.9, x.10" with values
> in it. I used the "assign" function but nothing happens. Thank you
> very much
> 
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://www.stat.math.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide!
> http://www.R-project.org/posting-guide.html

Petr Pikal
petr.pikal at precheza.cz




More information about the R-help mailing list