Which of the following reads a data.frame and creates text output referring to the Google Visualization API?

gvisAnnotatedLine
gvisTimeLine
gvisAnnotatedTimeLine
none of the mentioned

The correct answer is: D. none of the mentioned

  • gvisAnnotatedLine is a function in the gvis package that creates a line chart with annotations.
  • gvisTimeLine is a function in the gvis package that creates a timeline chart.
  • gvisAnnotatedTimeLine is not a function in the gvis package.

The following code shows how to use gvisAnnotatedLine to create a line chart with annotations:

“`
library(gvis)

data(cars)

gvisAnnotatedLine(cars$speed, cars$dist, xlab=”Speed”, ylab=”Distance”,
main=”Cars Speed vs. Distance”,
annotations=list(
lapply(cars$speed, function(x) {
c(x, cars$dist[cars$speed == x])
})
))
“`

The following code shows how to use gvisTimeLine to create a timeline chart:

“`
library(gvis)

data(USArrests)

gvisTimeLine(USArrests$year, USArrests$murder, xlab=”Year”, ylab=”Murders”,
main=”Murders in the USA”,
annotations=list(
lapply(USArrests$year, function(x) {
c(x, USArrests$murder[USArrests$year == x])
})
))
“`

Exit mobile version