Week 2: learning R

To improve my data analysis skills, I have been trying to teach myself how to code in R.  This is my first foray into coding so the going has been rough.  Part of the challenge is that I have no idea what is or isn’t possible to do while coding in R.  I started out by watching some videos on the basics of R coding language.  Honestly, the videos weren’t very helpful.  They went very in depth on the theory of everything and what R was doing behind the scenes.  I spent a long time watching one video explaining logical vectors.  Eventually I gave up on the watching videos method of learning and turned to old fashioned googling all of my problems.

My first task in R was to create a line graph showing the abundances of milkweed species over time.  At first it seemed like a simple task.  How hard could a line graph be? It took me all week to get just part of the assignment done.  The first challenge was learning how to import my data frame into R.  I’m working with a large data frame of herbarium records from multiple herbaria that have digitized their records.  Once I managed to import my file (which took way too long) I spent a few hours learning how to subset my data.  Then I tried the filter function, the count function, the aggregate function, and many more.  Eventually I had to make a simpler data frame of 20 lines of made up data so that I could recognize right and wrong results.  After much struggling and googling, I made a line graph of A. syriaca records per year for the last 118 years.  Victory, sorta.  Now I need to figure out how to code the same thing but more efficiently.  I also need to learn to loop my code because there are a lot of milkweed species in the dataset and manually repeating the code for each species will take too long.  of course, learning to loop will also take too long but hopefully it will be useful in the future.

Comments

  1. I feel you on the coding experience! I’ve had to code many graphs and data sets, and I’ve also started trying to read manuals but then switching to google – and while I’ve never used R, I have made many plots on Python and Matlab.

    I was also wondering why you’re using R to plot these milkweed species. If you’d happen to know, is there a particular value of R that Matlab & Python don’t have – either in general or with plotting biological data?

Speak Your Mind

*