Dr. Koch wrote some R code to compare Anthony and my FTIR data with Dr. Siegelstein’s data from 1981. The night before my presentation took a look at his code and thought, I’m going to tweak it just a little bit before my presentation to show how easy working with R can be. I had forgotten that all the little non-code related things can turn into a lot of work when “tweaking.” Especially when I’m new to the language (and haven’t written code in a really, really long time. Needless to say I ran out of time.

Today I’ve been working on the tweak (open in notepad, or some other editor). It’s been a really good learning experience. Here is what I’ve done so far:

I had to first upload the Rcurl and binom packages for the require command.

Dr. Koch read the Siegelstein data in as a table (read.table). I couldn’t get that to work so I copied the data into an Excel spreadsheet and saved it as a .csv file which I was then able to upload with the read.csv command.

Running the code I was getting an error message after the names(refwater) command. Steve skipped the first 5 rows of the table file and then adding the column names with names(). This wasn’t working for me. I was getting the following error:

names(refwater) <- c(“wavelength”, “abs”)
## getting the following error after this line
## Error in names(refwater) <- c(“wavelength”, “abs”) :
##  ‘names’ attribute [2] must be the same length as the vector [1]
## which is messing up all references to refwater

Steve suggested that I try str(refwater) to see what kind of data structure I was dealing with. I tried that, hoping for some enlightenment. What I recieved was:

‘data.frame’:   1262 obs. of  1 variable:
 $ V1: Factor w/ 1262 levels “10,21928”,”100,6.82E+05″,..: 1262 1 48 89 125 166 247 332 402 444 …

Which I think may mean exactly what Steve thought, “it’s coming in as a 1-dimension array of characters (vector). ” I don’t feel very enlightened.

So, I decided to forget the names() option and just put the names of the columns in the .csv file directly.  Adding ‘wavelength’ and ‘abs’ to row 5 columns 1 and 2, respectively, did the trick (and commented out the names() line)!

Now I’m only getting the following error message in two places.
> lines(subref$wavelength/1000, subref$abs, type=”l”, lty=1, col=”red”)
Error in subref$wavelength : $ operator is invalid for atomic vectors
Which I think may because we are using a matrix instead of a dataset. I’m looking into that now.
Oh and my graphs are a little wacked: