r - rstudio manipulate: how to make a variable picker? -
i have info frame (df) next structure:
id time var1 var2 truc 4 2 30 truc 10 4 60 truc 40 6 90 bidule 4 5 12 bidule 10 15 13 bidule 40 45 14 i utilize manipulate take variable (var1 or var2) plot. here tried:
manipulate( ggplot(df, aes(x=time, y=y.factor, color=id))+ geom_point(), y.factor=picker(var1, var2) )
you should utilize characters within picker() function (names in quotes) , within ggplot() phone call utilize aes_string() because y.factor contains name of variable y values , not actual y values. see within aes_string() names time , id in quotes y.factor isn't.
manipulate( ggplot(df, aes_string(x="time", y=y.factor, color="id"))+ geom_point(), y.factor=picker("var1", "var2") ) r ggplot2 rstudio
No comments:
Post a Comment