Embed presentation




![rapply()UsageUsing Loops!> avg <- numeric (8)> avg[1] 0 0 0 0 0 0 0 0> for(i in 1:8)+ avg[i]<-mean(state.x77[,i])> avg[i][1] 70735.88> avg[1] 4246.4200 4435.8000 1.1700 70.8786 7.3780[6] 53.1080 104.4600 70735.8800](https://image.slidesharecdn.com/3-5applyfunctions-100122124158-phpapp02/75/R-Apply-Functions-5-2048.jpg)





Apply functions allow executing a function repeatedly on each row, column, or element of a matrix, data frame, or list without using loops. Common apply functions include sapply(), lapply(), apply(), mapply(), and tapply(). Apply functions provide a more efficient way to perform operations across data compared to traditional loops. tapply() allows breaking a vector into pieces and applying a function to each piece, similar to sapply() but allowing customization of how the breakdown occurs.




![rapply()UsageUsing Loops!> avg <- numeric (8)> avg[1] 0 0 0 0 0 0 0 0> for(i in 1:8)+ avg[i]<-mean(state.x77[,i])> avg[i][1] 70735.88> avg[1] 4246.4200 4435.8000 1.1700 70.8786 7.3780[6] 53.1080 104.4600 70735.8800](https://image.slidesharecdn.com/3-5applyfunctions-100122124158-phpapp02/75/R-Apply-Functions-5-2048.jpg)



