rstudio / ggvis

Interactive grammar of graphics for R
Other
713 stars 171 forks source link

layer_lines does not accept "data=" argument #440

Open git-er opened 9 years ago

git-er commented 9 years ago

The following statement fails (using layer_lines): ggvis() %>% layer_lines(data = dfb, x= ~date_b , y= ~val_b, stroke := "red") ## Error in func() : attempt to apply non-function

However the same logic works in this case using layer_paths: ggvis() %>% layer_paths(data = dfb, x= ~date_b , y= ~val_b, stroke := "red")

Here is the mock data used to test the two cases above: dfb <- data.frame( date_b = seq(from= as.Date("2015-07-02"), to= as.Date("2015-07-15"), by= 1), val_b = c(3250.75429, 3505.43477, 3208.69141, -2.08175, -27.30244, 3324.62348, 2820.91075, 3250.75429, 3505.43477, 3208.69141, -2.08175, -27.30244, 3324.62348, 2820.91075) )

pbulsink commented 8 years ago

To add to this, using this same mock data piped into ggvis() doesn't work either:

dfb %>% ggvis() %>% layer_lines(x= ~date_b , y= ~val_b, stroke := "red") Error in UseMethod("as.lazy") : no applicable method for 'as.lazy' applied to an object of class "NULL"

dpeterson71 commented 7 years ago

+1 This is still a problem in December 2016, "The Year of ggvis".

McCartneyAC commented 5 years ago
dfb %>% 
  ggvis(x= ~date_b , y= ~val_b, stroke := "red" ) %>% 
  layer_paths()

works perfectly fine for me?

shirewoman2 commented 5 years ago

This is still not working in March 2019. In the RStudio ggvis example using data from Minard's famous graph of Napoleon's army's retreat in 1812 http://ggvis.rstudio.com/data-hierarchy.html, this works:

     ggvis(data = NULL, x = ~long, y = ~lat) %>%
      layer_points(size = ~survivors, stroke = ~direction, data = Minard.troops) %>%
      layer_text(text := ~city, dx := 5, dy := -5, data = Minard.cities)

but this generates the error "Error in x$cur_data() : attempt to apply non-function":

ggvis(data = NULL, x = ~long, y = ~lat) %>%
      layer_lines(size = ~survivors, stroke = ~direction, data = Minard.troops) %>%
      layer_text(text := ~city, dx := 5, dy := -5, data = Minard.cities)