1

According to the properties and scales reference and this SO post I should be able to use a props(prop()) call as shown below to create the graph. I'm getting an unintelligible error though.

test_df <- data.frame(cbind(x_vals = letters[1:5],
                            y_vals = 1:5)) 

Graphs correctly:

test_df %>% ggvis(x = ~x_vals, y = ~y_vals) %>% 
  layer_points() 

Has error:

x_val_variable <- "x_vals"

test_df %>% ggvis(y = ~y_vals) %>% 
      props(prop("x", as.name(x_val_variable)) %>% 
      layer_points()

Can anyone help me by telling me what I'm doing wrong?

Community
  • 1
  • 1
Jonathan H
  • 89
  • 9
  • That `props()` stuff does seem confusing. I'm pretty sure you can't have in in the `%>%` chain. It should either be in the `ggvis()~ or `layer_points()` call. I couldn't get it to work but I did get `test_df %>% ggvis(x=as.name(x_val_variable), y = ~y_vals) %>% layer_points()` to work. which seems to do what you want. – MrFlick Sep 23 '16 at 22:25
  • I figured it out. You are correct that `props()` doesn't belong in the chain. I spent a good 5 hours on this today! – Jonathan H Sep 24 '16 at 02:01

1 Answers1

2

I figured out the correct usage of prop(), it doesn't belong in the %>% chain, it's an argument of ggvis or layer_points(). I still don't understand when you would use props() though.

test_df <- data.frame(cbind(x_vals = letters[1:5],
                            y_vals = 1:5)) 

x_val_variable <- "x_vals"

#you can use either one of these, they are identical
p1 <- prop("x", as.name(x_val_variable))
p2 <- prop("x", parse(text = x_val_variable)[[1]])

test_df %>% ggvis(p1, y = ~y_vals) %>% layer_points()
Jonathan H
  • 89
  • 9