Plotting your Data

1. In order to make a scatterplot in order to perform generic x, y plotting, use the following: plot(x, y, …)

2. To practice this, let's use the following csv file. http://joeystanley.com/downloads/menu.csv. To load the data into R, type the following: data<-read.csv("http://joeystanley.com/downloads/menu.csv")

3. Type the following into the script: plot(data$Calories,data$Fat). Calories will be on the x-axis, fat will be on the y axis.

4. Then, press Run.

5. A plot will come up on the bottom right-hand corner on your screen.

6. Now let's make a histogram.

7. The function to make a histogram is the following: hist()

8. Using the dataset above, you can make a histogram of the Calories in the foods from lines 1-57.

9. Type the following into your script: x<-(data$Calories[1:57]) hist(x)

10. The plot should look like the following in plots on the bottom left hand side of your screen.

Now try making plots on your own!