[R] sample and rearrange
    jim holtman 
    jholtman at gmail.com
       
    Thu May 20 03:19:36 CEST 2010
    
    
  
you just need the function name; the parameter is being supplied by the lapply:
 t(apply(x, 1, rearrange))
On Wed, May 19, 2010 at 7:47 PM, Wu Gong <ghowoo at gmail.com> wrote:
>
> 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.
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
-- 
Jim Holtman
Cincinnati, OH
+1 513 646 9390
What is the problem that you are trying to solve?
    
    
More information about the R-help
mailing list