[R] assign object with loop (translation from SAS to R)

lynx ecotopia21c at gmail.com
Sat Jun 30 03:55:19 CEST 2012


Dear 

Rui Barradas 
David Winsemius 
ONKELINX, Thierry 
David Carlson 

I really appreciate your helps.
I did not realize that there were such many ways to do it.

Among them, I just pick up the simple one and it worked out.
It was like this.

<<ONKELINX, Thierry's way>>
n <- 10
p <- 9
dataset <- data.frame(matrix(rep(seq_len(p), each = n), nrow = n, ncol = p))
colnames(dataset) <- paste("p", seq_len(p), sep = "")
test <- t(apply(dataset, 1, function(x){ x %o% x}))
colnames(test) <- paste("p", rep(seq_len(p), each = p), "p", rep(seq_len(p),
p), sep = "")
test <- test[, rep(seq_len(p), each = p) < rep(seq_len(p), p)]

In fact, this is first time for me to post in R help. 
I was very surprised to see quick replys and how you are supportive.
You guys are awesome. Thank you so so much!
I will pay back the debt to someone else. :-)


--
View this message in context: http://r.789695.n4.nabble.com/assign-object-with-loop-translation-from-SAS-to-R-tp4634806p4634941.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list