[R] sample and rearrange

Wu Gong ghowoo at gmail.com
Thu May 20 01:47:46 CEST 2010


I tried to use a separate function to make the code more understandable. But
I failed. I don't know what's wrong with the code.

x <- as.matrix(x)

rearrange <- function(.row){
	z <- do.call(rbind, strsplit(.row[-1], ''))
	z.col <- t(apply(z, 2, paste, collapse=''))
	cbind(.row[1], z.col)
	}
	
t(apply(x, 1, rearrange(.row)))

Error in strsplit(.row[-1], "") : object '.row' not found

I don't know how to pass the value to the function.

-----
A R learner.
-- 
View this message in context: http://r.789695.n4.nabble.com/sample-and-rearrange-tp2222747p2223767.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list