So I am an R code beginner. It seems to me that there is a quick and dirty way to calculate the mean of a set of n rows within a column, but is there something similar for standard deviation (or standard error)? I'd like to avoid looping if possible because this is only a small part of the increasingly unwieldy (for a beginner) code I am building. Here is a simplified example of the dataset I will be working with:
Canopy Species Date Pa
1 Maple BETH 4/26/2014 -0.1162607263
2 Maple BETH 4/26/2014 -0.2742194706
3 Maple BETH 4/26/2014 -0.1864006372
4 Maple BETH 4/26/2014 -0.0739905518
5 Maple BETH 4/26/2014 -0.0751169983
6 Maple BETH 4/26/2014 -0.0782771938
7 Maple BETH 4/26/2014 -0.1671646757
8 Maple BETH 4/26/2014 -0.2464696338
9 Maple BETH 4/26/2014 -0.2176720386
10 Maple BETH 4/26/2014 -0.2283216397
11 Maple BETH 4/26/2014 -0.1152989165
12 Maple BETH 4/26/2014 -0.2720884764
13 Maple BETH 4/26/2014 -0.1849383730
14 Maple BETH 4/26/2014 -0.0734205199
15 Maple BETH 4/26/2014 -0.0745294634
16 Maple BETH 4/26/2014 -0.0776640601
17 Maple BETH 4/26/2014 -0.1658603785
18 Maple BETH 4/26/2014 -0.2445047320
19 Maple BETH 4/26/2014 -0.2159337593
20 Maple BETH 4/26/2014 -0.2264833266
and here is an example piece of code I was referring to for means. This one finds the mean for every 10 rows in the Pa column:
mu<-colMeans(matrix(Table$Pa, nrow=10))
Thank you in advance for your help and please let me know if there is any more information I should provide.
Here is a mixed base R/dplyr solution: First I created a column named fac_to_spli which is the factor to use to calculate the standard deviations and then with group_by and mutate of dplyr I did the calculations.