Entering edit mode
10.5 years ago
minni9234
▴
50
Hi,
How to separate 2 delimiters (-
and ///
) for a dataset? I only know how to separate one delimiter.
genenames=as.character(rownames(selExpr))
delim.ind=grep("///",genenames)
tmpgene=NA # object for single gene names
for (i in 1:length(delim.ind)){
tmp=strsplit(as.character(genenames[delim.ind[i]]),"///",fixed=TRUE)
tmpgene[i]=tmp[[1]][1] # just want the first name
} # need to iterate b/c some rows have more than one ///
genenames[delim.ind]=tmpgene
rownames(selExpr)=genenames
0
Entering edit mode
Having two different delimiters in the same file is not a good idea, and a potential source of errors in the future. That is probably the reason why read.table in r doesn't have am option to read more than one delimiter. You should edit the file with sed, and unify all the delimiters in a single one.
ADD REPLY
• link
10.5 years ago by
Giovanni M Dall'Olio
28k