Posts

Showing posts with the label Visualization

1.4.5 R1. Understanding Food - Video 4 Creating Plots in R

Visualization is a crucial step for initial data exploration. It helps us discern relationships, patterns, and outliers. This video will give us a starting point on how to make plots in R, but more advanced and way cooler visualization tips will be given in Week 8 of this class. Let us first create a scatterplot with Protein on the x-axis and Fat on the y-axis. To do this we can use the plot function in R and give it as a first input the Protein vector on the x-axis, and as a second input the TotalFat vector on the y-axis. And now pressing Enter, a new window pops up. If you are on a PC, the new Windows is called R Graphics, and if you are on a Mac it is called Quartz. The plot has a very interesting triangular shape. It looks like foods that are higher in protein are typically lower in fat, and vice versa. Now, looking at the aesthetics of the graph, we realize that R gives default names for the x-axis and the y-axis using the vector dollar notation. Now we can modify th...