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
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,
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
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
4 matches
Mail list logo