Warning: Parameter 2 to wp_hide_post_Public::query_posts_join() expected to be a reference, value given in /home/rexercis/public_html/wp-includes/class-wp-hook.php on line 286
Building metricsgraphics charts follows the “piping” idiom, made popular through the magrittr, ggvis and dplyr packages. This makes it possible to avoid one giant function with a ton of parameters and facilitates, breaking out the chart and building into logical steps. While MetricsGraphics.js charts may not have the flexibility of the ggplot2, you can build functional, interactive [multi-]lines, scatter-plot, bar charts, histograms and you can even link charts together.
Before proceeding, please follow our short tutorial.
Look at the examples given and try to understand the logic behind them. Then, try to solve the exercises below using R without looking at the answers. Then, check the solutions to check your answers.
To begin, load these packages and data-frames:
tmp <- data.frame(year=seq(1790, 1970, 10), uspop=as.numeric(uspop))
Create a basic line chart of years and US population.
Add a marker named “Marker” in the year 1850.
Add a baseline named “baseline” in the uspop = 150.
Create a basic bar chart of the
tmp data frame.
width to 500 and the
height to 400.
Create a basic scatter-plot between
mpg of the
mtcars data frame.
size of the data points according to
Add titles to “x” and “y” axes.
Add square lines to the plot.
size according to
- Become a Top R Programmer Fast with our Individual Coaching Program
- Explore all our (>4000) R exercises
- Find an R course using our R Course Finder directory
- Subscribe to receive weekly updates and bonus sets by email
- Share with your friends and colleagues using the buttons below