Durant, James T. (ATSDR/DTEM/PRMSB)
2011-Sep-02 19:13 UTC
[R] Chemical Names in Data Frames
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? VR Jim James T. Durant, MSPH CIH Emergency Response Coordinator US Agency for Toxic Substances and Disease Registry Atlanta, GA 30341 770-378-1695 [[alternative HTML version deleted]]
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
?make.names perhaps. On Fri, Sep 2, 2011 at 4:13 PM, Durant, James T. (ATSDR/DTEM/PRMSB) <hzd3 at cdc.gov> 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? > > VR > > Jim > > James T. Durant, MSPH CIH > Emergency Response Coordinator > US Agency for Toxic Substances and Disease Registry > Atlanta, GA 30341 > 770-378-1695 > > > > > > ? ? ? ?[[alternative HTML version deleted]] > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >