[R] How to reorder rows in dataframe by text flag

Dale Steele dale.w.steele at gmail.com
Wed Feb 7 02:34:10 CET 2007


Given two columns of type character in a dataframe of the form:

col1    col2
31*      66
0         0*
102*    66
71*      80
31       2*
66       31*
47       38*

How do I generate the following dataframe?  Ie. col1 contains row item
 with "*" and col2 contains row member without "*"

col1    col2
31       66
0         0
102     66
71       80
2        31
31      66
38      47

Partial ideas thus far....
grep("*",col1,fixed=T)
as.numeric(gsub("*","",col1))

Thanks.  --Dale



More information about the R-help mailing list