February 23, 2014

Food diary with rCharts and Google drive

Food diary with rCharts and Google drive I'm interested in not only global issues, but also personal issues, especially health issues.
Since last week, I have kept a food diary in spreadsheet of Google drive.
Here is a plot of Food frequency and average energy for a week.



# read data from Google Drive

s <- "https://docs.google.com/spreadsheet/pub?key=0AroiXQuUrfhwdG0zUE9LbTFvQ3hQNUx5bk5tMEtPaGc&output=csv"
x <- getURL(s, ssl.verifypeer = FALSE, .encoding = "UTF-8")
mydata <- read.csv(text = x, as.is = TRUE)

# data cleaning

mydata$energy <- as.numeric(mydata$energy)
mydata_summary_food <- mydata %.% group_by(food_en) %.% summarise(avg = mean(energy), 
    freq = n(), size = 7)

# visualize

h1 <- hPlot(x = "freq", y = "avg", data = mydata_summary_food, type = "bubble", 
    group = "food_en", size = "size")
h1$show("iframesrc", cdn = TRUE)

No comments:

Post a Comment

Popular Posts