We just completed our first R project…whew.

The overall purpose of the project was to understand the simplicity and beauty of functions. We read in csv files, cleaned the data by creating variables, parsed the csv file into two separate files, and created plots for those files. The coding was simplified with functions. If you can write a line of code, you can write a function. In the most basic sense, it’s just a “wrapper” for your code. Other than providing default arguments (if necessary) and return() at the end of the function that is all you need.

Looking back at the project, I would have done two things differently:

1) I would have added checks. It was not required for the project, but it would have made it more robust. For example, when the user has the option to select whether returning data from the top or bottom of the data set, the function only checked for some form of ‘top’. If any other argument was entered, the function would assume it should return the bottom results. Also, when reading the argument in, I would have converted the argument into lowercase.

2) Clarification on the display of the ‘state’ graph. It seems the extreme values in the data produced its outcome. I created box plots and a histogram on the data to validate my thoughts - But who knows I might have read too much into it.

In addition to functions, I learned how to use %in% to parse data from two different files. It’s almost like completing an INNER join. I also have a better understanding of lists. The project allowed us to see that a list can take any objects even a data frame. Even though it was pointed out in lectures, now that you see it done – it just drills that fact in.

So, what’s your takeaway – Functions are great!

Curious about the project here


<
Previous Post
My First Post
>
Next Post
Pokémon API - Group Project