[R] symbols in a data frame

2014-07-09 Thread Sam Albers
Hello, I have recently received a dataset from a metal analysis company. The dataset is filled with less than symbols. What I am looking for is a efficient way to subset for any whole numbers from the dataset. The column is automatically formatted as a factor because of the symbols making it

Re: [R] symbols in a data frame

2014-07-09 Thread Sarah Goslee
Hi Sam, I'd take the similar tack of removing the instead. Note that if you import the data frame using the stringsAsFactors=FALSE argument, you don't need the first step. metals$Cedar.Creek - as.character(metals$Cedar.Creek) metals$Cedar.Creek - gsub(, , metals$Cedar.Creek) metals$Cedar.Creek

Re: [R] symbols in a data frame

2014-07-09 Thread Marc Schwartz
On Jul 9, 2014, at 12:19 PM, Sam Albers tonightstheni...@gmail.com wrote: Hello, I have recently received a dataset from a metal analysis company. The dataset is filled with less than symbols. What I am looking for is a efficient way to subset for any whole numbers from the dataset. The

Re: [R] symbols in a data frame

2014-07-09 Thread Bert Gunter
Well, ?grep and ?regex are clearly apropos here -- dealing with character data is an essential skill for handling input from diverse sources with various formatting conventions. I suggest you go through one of the many regular expression tutorials on the web to learn more. But this may not be the

Re: [R] symbols in a data frame

2014-07-09 Thread Sam Albers
Thanks for all the responses. It sometimes difficult to outline exactly what you need. These response were helpful to get there. Speaking to Bert's point a bit, I needed a column to identify where the symbol was used. If I knew more about R I think I might be embarrassed to post my solution to

Re: [R] symbols in a data frame

2014-07-09 Thread Claudia Beleites
Hi Sam, But this may not be the important issue here at all. If k means the value is left censored at k -- i.e. we know it's less than k but not how much less -- than Sarah's proposal is not what you want to do. Exactly what you do want to do depends on context, and as it concerns

Re: [R] symbols in a data frame

2014-07-09 Thread MacQueen, Don
After reading the metals data frame, I would do this: metals$result - as.numeric(gsub('','',metals$Cedar.Creek)) metals$flag - ifelse(grepl('',metals$Cedar.Creek),'','h') Also, assuming you got your data into R using read.table(), read.csv(), or similar, I would include stringsAsFactors=TRUE