Search code examples
rggvis

Error: length(x) not equal to 1


I'm trying to plot some data for eventual statistical analysis. Currently I am using ggvis to plot the data because I saw some cool interactivity and ease of use the function has.

Anyways, this is the code that is giving me the error Error: length(x) not equal to 1:

ggvis(myfile, myfile$Shipment.Date, myfile$Act.Ctns)

sample data

          Shipment.Date                  Act.Ctns
3326      3/3/2015  Wm Eu Apple 2L       60
3327      3/3/2015 Tp Euro 2 Layer      420
3328      3/3/2015     Tpe 3-Layer       80
3329      3/3/2015        14/3 Bgs      145
3330      3/4/2015             T/P      196
3331      3/4/2015  Wm Eu Apple 2L    1,260
3332      3/4/2015 Tp Euro 2 Layer      360
3333      3/4/2015        14/3 Bgs    1,355

here is some sample data, I just printed myfile and took a copy of it. I'm completely new to R unclear how to fix this issue. Please let me know if I need to convert a variable or do something else for ggvis to work. Thanks!

I've looked at ?ggvis, but it appears I've met all the criteria for the funtion, and watched someone do the exact same thing with a similar time series data set in another video.


Solution

  • You're specifying the aesthetics incorrectly. Try

    ggvis(myfile, ~Shipment.Date, ~Act.Ctns)
    

    as in:

    ggvis(mtcars, ~mpg, ~wt)