Posts

Showing posts from October, 2024

Module # 9 Visualization in R

Image
  Three types of Visualization in R 1) Today we are going to be taking a look at a dataset about consumer goods with three different visualization methods in R. We will first see what we can do without any packages in R. Just the basics, to create some sort of graphic. Then we will be using lattice, and then finally ggplot2.  2) The data base we will be using for this assignment is called " Properties of a Fast-Moving Consumer Good" found here . Without further ado let's get to it. 3) BASE R VISUALIZATION

Module # 8 Input/Output, string manipulation and plyr package

  String Manipulation and the plyr Package 1) We have three important steps we need to cover for this week's assingent. Step #1: Import some data then, run the commend "mean" using Sex as the category (use plyr package for this operation). Last commend in this step: write the resulting output to a file. Step#2: Convert the data set to a dataframe for names whos' name contains the letter i, then create a new data set with those names, Write those names to a file separated by comma’s (CSV). Step#3: Write the filtered data set and convert it to CSV file. With all of that laid out lets write some code to make it all happen. 

Module # 7 R Object: S3 vs. S4 assignment

  Objects in R: S3 vs. S4 1) This week we have three steps to complete, as we learn about object oriented programing or OOP. First we need to find a data set. Then see if a generic function can be assigned to said data set. The last step is to see if S3 or S4 objects can be assigned to the data set. Here we go. 2) The data set I have chosen covers electric vehicle population. I chose this one because it was the easiest to obtain besides mtcars. You can find it here for free .  3) To see if a generic function can be assigned to this data set. To do this we need to first understand what a generic function is. A generic function in R, are functions designed to change their behavior based on the class of the input object. Some examples of this are "plot", "mean", "predict", "summary" etc. We are going to try to use "summary" on our data and see if we get back a summary of each column, custom made to that column's data type. Here we go:

Module # 6 Doing math in R part 2

  Doing Math with a Matrix in RStudio Part 2 1) This week we are going to be handling more matrices in RStudio. Adding them, subtracting them and building them. I have done this a few times before so this should again, go pretty smoothly. We have three parts to tackle for this assignment so with out further ado lets jump right in.  2) I was given the following instructions for this first part: Consider A=matrix(c(2,0,1,3), ncol=2) and B=matrix(c(5,2,4,-1), ncol=2). Find A + B, and find A - B. We can easily do this with some simple code in RStudio.