Message-ID: <CAAmySGOJJRV05vrQtp9meGFKkfAyXrSYAzEevxp1B3pVzhFKRg@mail.gmail.com>
Date: 2011-10-20T21:37:25Z
From: R. Michael Weylandt
Subject: apply with function
In-Reply-To: <CAFAD80_7mLUeiKJwXzpXi-Dg9-wrJtAAaAuywouKE1+4TE67Wg@mail.gmail.com>
Does this work?
apply(Iske, 1, function(x) rawToChar(as.raw(x)))
> apply(Iske, 1, function(x) rawToChar(as.raw(x)))
[1] "\001\002\003\004\005" "\001\002\003\004\005" "\001\002\036\004\005"
[4] "\002\001\003\004\005" "\002\001\003\004\005" "\002\001\003,\005"
[7] "\n\004\003\002\005" "\001\004\003\002\005" "\001\004\003\002_"
[10] "\005\004\003\002\001" "\001\003\005\004\002"
Michael
On Thu, Oct 20, 2011 at 5:20 PM, J?rg Reuter <joerg at reuter.at> wrote:
> (Iske <- matrix(c(1, 1, 1, 2, 2, 2, 10, 1, 1, 5,
> 1,2,2,2,1,1,1,4,4,4,4,3,3,3,30,3,3,3,3,3,3,3,5,4,4,4,4,4,44,2,2,2,2,4,5,5,5,5,5,5,5,5,95,1,2),
> ncol = 5))
> numtochar <- function(Zahl){
> text <- rawToChar(as.raw(Iske[1,]))}
> (Iske.char[]<-apply(Iske,1,numtochar))
>
> I have a little problem with the command apply(). I want use the
> function numtochar for every row and the result should be a vector
> with the chars for every row.
> At the moment the function numtorow create a char with all items, but
> separate not every row.
> I think the function apply is the right way, bu I did not know how to
> use it at this example. Attention: At the real data set every row have
> a other length (!)
>
> ______________________________________________
> 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.
>