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 along the lines of "[out<3]<-0" that works...
Thank you for any help!
Sarah
m<-matrix(c("1,6", "0,12", "130,12", "0,0", "123,4", "2,2","3,7","9,6", "0,0",
"12,2", "1,2", "0,3"), ncol=4)
required output:
[,1] [,2] [,3] [,4]
[1,] "0,6" "0,0" "0,7" "12,0"
[2,] "0,12" "123,4" "9,6" "0,0"
[3,] "130,12" "0,0" "0,0" "0,0"
[[alternative HTML version deleted]]
______________________________________________
[email protected] 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.