课程: Data Visualization in R with ggplot2

免费学习该课程!

今天就开通帐号,24,700 门业界名师课程任您挑!

Lines and smoothers

Lines and smoothers

- [Instructor] Scatterplots are useful, but they're certainly not the only type of helpful visualization in R. Let's take a look at two other geometries that can help us visualize data using lines. The geom_line function simply connects data points using a line, while the geom_smooth function fits a line to the set of points. We'll talk more about that in a moment. The aesthetics for lines are pretty much the same as the aesthetics for points. We still need to specify the x and y positions for the points that contribute to the line, and we can specify color, size, and other attributes. Let's try working with lines in R. Here, I have the code in my start file that loads the dataset and creates what now should be a familiar scatterplot, tuition versus SAT scores. Now, let's say I'd like to convert this to a line graph. I can do that by simply changing the point geometry to a line geometry. The aesthetics are the same, so I only have to change one word here by changing the geom_point…

内容