pulse <- read_pulse() survey <- read_survey()
Necessary libraries and data.
In your R Markdown document load the tidyverse
library and read the pulse.csv
file into the pulse
variable.
A series of charts.
Reproduce the sequence of charts.
Each next chart is a small modification of the command.
ggplot( pulse, aes( x = age, y = weight ) ) + geom_point()
ggplot( pulse, aes( x = age, y = weight ) ) + geom_point( aes( color = exercise ) )
ggplot( pulse, aes( x = age, y = weight ) ) + geom_point( aes( color = exercise ), alpha = 0.6 )
ggplot( pulse, aes( x = age, y = weight ) ) + geom_point( aes( color = exercise, shape = gender ), alpha = 0.6 )
ggplot( pulse, aes( x = age, y = weight ) ) + geom_point( aes( color = exercise, shape = gender ), alpha = 0.6, size = 3 )
Help
for commands xlab
, ylab
, ggtitle
.ggplot( pulse, aes( x = age, y = weight ) ) + geom_point( aes( color = exercise, shape = gender ), alpha = 0.6, size = 3 ) + xlab( "Age [years]" ) + ylab( "Weight [kg]" ) + ggtitle( "All subjects from pulse.csv" )
geom_
component in a single plot.geom_point
components (so, add one more than used above) to reproduce the following chart.ggplot( pulse, aes( x = age, y = weight ) ) + geom_point( color = "yellow", size = 3 ) + geom_point( color = "black", size = 1, shape = 3 )
geom_
functions use the data provided in the call to the ggplot
function.data
argument: geom_point( data = otherData )
.filter
to select from pulse
all subjects with height >= 190
; store the result in filtPulse
. Now, modify the previous plot to draw the black symbol only for filtPulse
subjects.filtPulse <- pulse %>% filter( height >= 190 ) ggplot( pulse, aes( x = age, y = weight ) ) + geom_point( color = "yellow", size = 3 ) + geom_point( color = "black", size = 1, shape = 3, data = filtPulse )
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.