===================================================================================== # RETTE DI REGRESSIONE x <- c(1,2,3,4,5) y <- c(0.5, 0.6, 0.7, 0.75, 0.8) plot(x,y) model1 <- lm(y~x) coefficienti <- coef(model1) abline(coefficienti[1], coefficienti[2]) ===================================================================================== # PIE CHARTS (1) # Esempio Pie Chart slices <- c(10, 12,4, 16, 8) lbls <- c("US", "UK", "Australia", "Germany", "France") pie(slices, labels = lbls, main="Pie Chart of Countries") (2) # Pie Chart CON PERCENTUALI slices <- c(10, 12, 4, 16, 8) lbls <- c("US", "UK", "Australia", "Germany", "France") pct <- round(slices/sum(slices)*100) lbls <- paste(lbls, pct) # add percents to labels lbls <- paste(lbls,"%",sep="") # ad % to labels pie(slices,labels = lbls, col=rainbow(length(lbls)), main="Pie Chart of Countries") (3) pie Chart INSENSATI slices <- c(30,45,10,15) etichette <- c("100%", "200%", "300%", "500%") pie(slices, labels=etichette) ====================================================================================== # ISTOGRAMMI (esplorazione per scegliere visivamente il miglior binsize (via breaks) BMI<-rnorm(n=1000, m=24.2, sd=2.2) hist(BMI) histinfo<-hist(BMI) hist(BMI, breaks=5, main=”Breaks=5″) hist(BMI, breaks=c(17,20,23,26,29,32), main="Breaks is vector of breakpoints")