mjfii
2015-01-20
The Calorie-Burner Shiny App lets you accomplish 3 things:
lbs2kg<-function(pounds) {pounds/2.2;}
getmets<-function(activity) {
switch(activity,
'Watching TV'=1,
'Reading'=1.3,
'Walking'=3.25,
'Sking'=5,
'Jogging'=7);
}
getcalories<-function(weight,activity,duration) {
x<-lbs2kg(weight)
y<-getmets(activity)
z<-duration/60
x*y*z
}
The app has 3 very simple inputs, and using the prior three functions, the algorithm can determine estimate calories burned. In order calculate calories, we can use the below example:
getcalories(150,'Walking',90)
[1] 332.4
or, another example:
getcalories(225,'Jogging',60)
[1] 715.9
Using the prior first example, we get the below graphic. For example, the 322 calculated calories burns off approximately 61% of a Big Mac.