On Github Sarahfogel / DataProductsCP
by Sarah F
This app uses data from the "Orange" data set in the R package datasets. It first calculates a linear model predicting circumference based on age of the orange trees. Then it uses the following features:
A slider input allows the user to select an age within the age range of the data, in multiples of 10 The app outputs the following:The code used in the app does the following:
data(Orange) lm.1<-lm(circumference~age, data=Orange) predict.lm.1<- function( age ) { as.vector(lm.1$coef[1])+as.vector(lm.1$coef[2])*age }
Input an age of 850
predict.lm.1(850)
## [1] 108.1544
plot(circumference~age, data=Orange) abline(lm.1); abline(v=850, col="red", lwd=3); abline(h=predict.lm.1(850), col="blue", lty=2)
You need this app for the following reasons: