【发布时间】:2016-09-23 17:49:40
【问题描述】:
根据properties and scales reference 和this SO post,我应该能够使用如下所示的 props(prop()) 调用来创建图表。不过,我遇到了一个难以理解的错误。
test_df <- data.frame(cbind(x_vals = letters[1:5],
y_vals = 1:5))
图表正确:
test_df %>% ggvis(x = ~x_vals, y = ~y_vals) %>%
layer_points()
有错误:
x_val_variable <- "x_vals"
test_df %>% ggvis(y = ~y_vals) %>%
props(prop("x", as.name(x_val_variable)) %>%
layer_points()
谁能帮我告诉我我做错了什么?
【问题讨论】:
-
props()的东西看起来确实令人困惑。我很确定你不能加入%>%链。它应该在ggvis()~ orlayer_points()` 调用中。我无法让它工作,但我确实让test_df %>% ggvis(x=as.name(x_val_variable), y = ~y_vals) %>% layer_points()工作。这似乎做你想做的事。 -
我想通了。你是正确的
props()不属于链。我今天花了 5 个小时在这上面!