Re: [R] function on strsplit output

2012-07-06 Thread Jessica Streicher
Could also do it in one apply i realized.. apply(m,1:2,FUN=function(x) {y<-as.numeric(strsplit(x,split=",")[[1]]);y[which(y <= 3)]<-0;paste(y,collapse=",")}) On 06.07.2012, at 10:18, Jessica Streicher wrote: > sap<-sapply(strsplit(m,","),as.numeric) > sap[which(sap <= 3)]<-0 > mNew<-matrix(ap

Re: [R] function on strsplit output

2012-07-06 Thread Sarah Auburn
Perfect, thank you! From: Jessica Streicher To: Sarah Auburn Cc: R help Sent: Friday, 6 July 2012, 17:48 Subject: Re: [R] function on strsplit output sap<-sapply(strsplit(m,","),as.numeric) sap[which(sap <= 3)]<-0 mNew<-matrix(apply(sap,2,FUN=function(x){paste(x,

Re: [R] function on strsplit output

2012-07-06 Thread Jessica Streicher
sap<-sapply(strsplit(m,","),as.numeric) sap[which(sap <= 3)]<-0 mNew<-matrix(apply(sap,2,FUN=function(x){paste(x,collapse=",")}),ncol=4) works? On 06.07.2012, at 08:47, Sarah Auburn wrote: > Hi, > I am trying to format some data (example matrix "m" below) for which each > data point has 2 assoc

[R] function on strsplit output

2012-07-05 Thread Sarah Auburn
Hi, I am trying to format some data (example matrix "m" below) for which each data point has 2 associated values separated by a comma. I want to replace values <3 with "0" to give the example output below. I have got as far as: out<-lapply(strsplit(m,","),as.numeric) Failed to identify anything a