0
votes

I have the following data frame. The annotation column is of factor type, departing is numeric, the month is of date type.

> dfMerge3
        month departing       Annotation
1  2012-04-01      1244       4th Lowest
2  2012-08-01      1801             <NA>
3  2011-12-01      4030             <NA>
4  2012-12-01         0 Lowest departure
5  2012-02-01      1627             <NA>
6  2012-01-01      2589             <NA>
7  2012-07-01      1107       3rd Lowest
8  2012-06-01      1255       5th Lowest
9  2012-03-01      1104       2nd Lowest
10 2012-05-01      1500             <NA>
11 2011-11-01      1745             <NA>
12 2012-11-01      3327             <NA>
13 2012-10-01      2387             <NA>
14 2012-09-01      2044             <NA>

I was trying to create a gvisAnnotationChart thru this code.

A2 <- gvisAnnotationChart(dfMerge3, datevar="month",
                          numvar="departing", 
                          titlevar="Title", annotationvar="Annotation",
                          options=list(displayAnnotations=TRUE, 
                                       width=600, height=350,
                                       scaleType='allmaximized')
)
plot(A2)

I keep getting the following error. Error in (function (..., row.names = NULL, check.rows = FALSE, check.names = TRUE, : arguments imply differing number of rows: 14, 0

I checked my dimensions and they are 3 by 14.

> dim(dfMerge3)
[1] 14  3

What am I missing here?

1

1 Answers

0
votes

You are passing a column which does not exist in your data (Title). This works for me.

library(googleVis)
A2 <- gvisAnnotationChart(df, datevar="month",
                          numvar="departing", annotationvar="Annotation",
                          options=list(displayAnnotations=TRUE, 
                                       width=600, height=350,
                                       scaleType='allmaximized')
)
plot(A2)

enter image description here