[R] Chemical Names in Data Frames

David Winsemius dwinsemius at comcast.net
Fri Sep 2 21:24:39 CEST 2011


On Sep 2, 2011, at 3:13 PM, Durant, James T. (ATSDR/DTEM/PRMSB) wrote:

> Greetings -
>
> I am working on some data that contain chemical names with air  
> concentrations, and I am creating a data frame with date/time and  
> each chemical having its own column. However, these are organic  
> chemicals (e.g. 1-butene, 2,3,4-trimethylbenzene etc). The package I  
> am going to be using the data with is openair, and many of the great  
> functions require you to specify a column name which does not seem  
> to work with improper column names- e.g. smoothTrend(mydata,  
> pollutant="1-Butene" and smoothTrend(mydata, pollutant=mydata[,"1- 
> Butene"])
>
> I was wondering if there was a function to automatically convert  
> these chemical names (with all sorts of numbers and minuses in the  
> beginning) to something openair can handle?  Or am I going to be  
> stuck recoding several hundred chemical names in my database?
>

Try using back-ticks on the invalid names, rather than quotes.

-- 

David Winsemius, MD
West Hartford, CT



More information about the R-help mailing list