سؤال

I'm new to ggvis and have a fairly simple question. I want to display data points in a scatterplot as well as their labels. The individual plots are easily produced:

# Render as Points ...
mtcars %>% ggvis(~wt, ~mpg) %>% layer_points()
# or as labels of `wt`
mtcars %>% ggvis(~wt, ~mpg, text:=~wt) %>% layer_text()

But the combination of both does not work.

mtcars %>% ggvis(~wt, ~mpg, text:=~wt) %>% layer_text() %>% layer_points()

I get this error:

Error: Unknown properties: text.
Did you mean: stroke?

The documentation on layers did not help here (http://ggvis.rstudio.com/ggvis-basics.html#multiple-layers, http://ggvis.rstudio.com/layers.html).

هل كانت مفيدة؟

المحلول

I found a working solution using this stackoverflow question.

The proper way to do this is as follows:

mtcars %>% ggvis(~wt, ~mpg) %>% layer_text(text:=~wt) %>% layer_points()
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top