Re: [R] Finding/identifying a value within a factor

2011-07-25 Thread Peter Ehlers
On 2011-07-25 10:51, "Dénes TÓTH" wrote: Hi, you provided a character vector as an example. I guess you meant something like: x<- factor(c("1","2","3","4","<1")) # You can identify those elements with an "<" by ?grep or ?grepl: indices<- grep("<",as.character(x)) # You can transform those ele

Re: [R] Finding/identifying a value within a factor

2011-07-25 Thread Dénes TÓTH
Hi, you provided a character vector as an example. I guess you meant something like: x <- factor(c("1","2","3","4","<1")) # You can identify those elements with an "<" by ?grep or ?grepl: indices <- grep("<",as.character(x)) # You can transform those elements by ?as.numeric as.numeric(x[indices

Re: [R] Finding/identifying a value within a factor

2011-07-25 Thread Daniel Malter
b<-c("1","2","3","4","<1") grep('<',b) HTH, Daniel Ryan Utz-2 wrote: > > Hi all, > > I'm trying to identify a particular digit or value within a vector of > factors. Specifically, this is environmental data where in some cases the > minimum value reported is "<" a particular number (and I wan

Re: [R] Finding/identifying a value within a factor

2011-07-25 Thread Sarah Goslee
Hi Ryan, The key to this is the grep() command. It's easiest if you import your data as character rather than factor, since these aren't properly factors. You don't say how that's done, but if you are using read.table() then as.is=TRUE will prevent conversion to factor. For a character vector, h

[R] Finding/identifying a value within a factor

2011-07-25 Thread Ryan Utz
Hi all, I'm trying to identify a particular digit or value within a vector of factors. Specifically, this is environmental data where in some cases the minimum value reported is "<" a particular number (and I want to manipulate only these). For example: x<-c("1","2","3","4","<1") For a dataset