On Feb 9, 2012, at 5:01 PM, Changbin Du wrote:
test<-
c("20120111_181515_001_CCL54D_A01_S02_APL932_PL11_DL_20120111.CEL",
"20120111_181516_002_CCL54D_A02_S08_APL932_PL11_DL_20120111.CEL")
test
[1] "20120111_181515_001_CCL54D_A01_S02_APL932_PL11_DL_20120111.CEL"
[2] "20120111_181516_002_CCL54D_A02_S08_APL932_PL11_DL_20120111.CEL"
fields1<-strsplit(test, "_")
fields1
[[1]]
[1] "20120111" "181515" "001" "CCL54D"
"A01"
[6] "S02" "APL932" "PL11" "DL"
"20120111.CEL"
[[2]]
[1] "20120111" "181516" "002" "CCL54D"
"A02"
[6] "S08" "APL932" "PL11" "DL"
"20120111.CEL"
*releaseqc<-sapply(fields1, "[",4)*
releaseqc
[1] "CCL54D" "CCL54D"
_____________
Dear R community,
I used the *releaseqc<-sapply(fields1, "[",4)* to get the 4th
elements from
each sub-list within fields1 list.
How do I get the first non-digital or first character element from
each
list?
Perhaps something like:
mapply ( "[", fields1, sapply(fields1, function(x)
{ which.min( is.na( is.numeric(fields1))) }
There are certainly other grep()-ish ways of approaching this.
--
David Winsemius, MD
West Hartford, CT
______________________________________________
R-help@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.