Created
June 19, 2012 11:04
-
-
Save antagomir/2953549 to your computer and use it in GitHub Desktop.
google motion chart example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Plot a Motion Chart using googleVis package - a brief example | |
# Leo Lahti 2012 | |
# Load the library | |
# Note: requires flash and internet connection | |
# use install.packages("googleVis") to install the library if needed | |
library(googleVis) | |
# Form a motion chart from 'Fruits' example data | |
# NOTE: the data set ('Fruits' in this example) must be given as data.frame | |
# which can contain NUMERIC and CHARACTER fields | |
# (NO FACTORS, NOR LOGICAL variables!). | |
# The FIRST FOUR FIELDS must be provided in the following order: | |
# idvar, timevar, two numeric fields, then any number of numeric and character fields | |
# See help(gvisMotionChart) for details | |
mchart <- gvisMotionChart(Fruits, "Fruit", "Year") | |
# Plot the chart (opens in browser, requires flash) | |
plot(mchart) | |
# Save as html (needs javascript to open!) | |
# NOTE: html file viewing does not work locally - store the html file on server and view through internet | |
print(mchart, file="MotionChart.html") | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment