I've searched, so please forgive me if I'm missing something.
Let's assume a dataframe that contains Name, Date, Calories, where Calories is the total number of calories that person consumed that day.
Name Date Calories
Amy 1/1/01 1500
Amy 1/2/01 1600
Amy ... ...
Sue 1/1/01 1450
Sue 1/1/02 1500
Sue ... ...
Jim ... ...
What I'd like to do is to use ggvis to plot calories for each person (Name). I know I can use dplyr's group_by, and get this on a single plot, but that will be too busy. And I know I could use dplyr's filter and filter out each person and make a graph for each person, but that doesn't scale.
Is there a way to have ggvis spit out a plot of calories per day for each person automatically?
Note that I tried creating a function like the below:
makeCharts <- function(myName){
myTbl %>% filter(Name == myName) %>% ggvis(~Date, ~Calories)
}
It works great when you call it manually:
makeCharts("Amy")
But when you call it via sapply:
sapply(levels(myTbl$Name), makeCharts)
The output looks like this:
Amy Sue Jim John Sally Frank Sandy etc...
marks List,0 List,0 List,0 List,0 List,0 List,0 List,0 List,0 List,0 List,0 List,0 List,0 List,0 List,0 List,0
data List,1 List,1 List,1 List,1 List,1 List,1 List,1 List,1 List,1 List,1 List,1 List,1 List,1 List,1 List,1
props List,1 List,1 List,1 List,1 List,1 List,1 List,1 List,1 List,1 List,1 List,1 List,1 List,1 List,1 List,1
reactives List,0 List,0 List,0 List,0 List,0 List,0 List,0 List,0 List,0 List,0 List,0 List,0 List,0 List,0 List,0
scales List,0 List,0 List,0 List,0 List,0 List,0 List,0 List,0 List,0 List,0 List,0 List,0 List,0 List,0 List,0
axes List,0 List,0 List,0 List,0 List,0 List,0 List,0 List,0 List,0 List,0 List,0 List,0 List,0 List,0 List,0
legends List,0 List,0 List,0 List,0 List,0 List,0 List,0 List,0 List,0 List,0 List,0 List,0 List,0 List,0 List,0
controls List,0 List,0 List,0 List,0 List,0 List,0 List,0 List,0 List,0 List,0 List,0 List,0 List,0 List,0 List,0
connectors List,0 List,0 List,0 List,0 List,0 List,0 List,0 List,0 List,0 List,0 List,0 List,0 List,0 List,0 List,0
handlers List,0 List,0 List,0 List,0 List,0 List,0 List,0 List,0 List,0 List,0 List,0 List,0 List,0 List,0 List,0
options List,0 List,0 List,0 List,0 List,0 List,0 List,0 List,0 List,0 List,0 List,0 List,0 List,0 List,0 List,0
cur_data ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?
cur_props List,2 List,2 List,2 List,2 List,2 List,2 List,2 List,2 List,2 List,2 List,2 List,2 List,2 List,2 List,2
cur_vis NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL