I have a dataframe of many variables (soil properties) for 11 legumes in 2 different locations. first few columns of the data is shown below.
SPECIES LOCATION pH NO3 NH4 P Organic_C K Cu Mn Zn BD X.Sand X.Silt X.Clay
1 C. comosa Gauteng 5.40 8.24 1.35 1.10 0.95 94.40 3.36 84.40 4.72 1.45 68.0 12 9
2 C. comosa Gauteng 5.25 8.36 1.37 1.20 0.99 94.87 3.39 84.87 4.77 1.36 76.0 16 13
3 C. comosa Gauteng 5.55 8.19 1.32 1.11 0.94 94.01 3.35 84.01 4.68 1.54 78.0 14 14
4 C. comosa Mpumalanga 5.84 4.05 3.46 3.04 1.55 130.40 0.28 25.43 2.00 1.66 73.6 9 10
5 C. comosa Mpumalanga 5.49 4.45 3.48 3.09 1.53 131.36 0.27 25.35 2.12 1.45 76.5 11 16
6 C. comosa Mpumalanga 6.19 4.43 3.44 3.04 1.58 129.95 0.29 25.45 2.14 1.87 74.9 13 16
7 C. distans Gauteng 5.48 8.88 1.96 3.33 0.99 130.24 0.99 40.01 3.94 1.55 70.0 8 11
8 C. distans Gauteng 5.29 8.54 1.99 3.28 0.99 130.28 0.95 40.25 3.89 1.48 79.0 12 15
9 C. distans Gauteng 5.67 8.63 1.93 3.39 1.02 130.30 0.98 40.12 3.97 1.62 79.0 10 16
10 C. distans Mpumalanga 5.61 6.02 2.65 4.45 2.58 163.25 1.79 53.11 6.11 1.68 72.0 8 10
11 C. distans Mpumalanga 5.43 6.58 2.55 4.49 2.59 163.55 1.78 52.89 6.04 1.63 78.0 15 14
12 C. distans Mpumalanga 5.79 6.24 2.59 4.41 2.59 163.27 1.75 53.03 6.19 1.73 75.0 16 12
13 E. cordatum Gauteng 4.38 16.29 5.76 4.77 3.25 175.38 1.11 35.87 8.54 1.53 33.0 9 40
14 E. cordatum Gauteng 4.05 16.15 5.63 4.73 3.29 175.90 1.23 34.34 8.61 1.42 45.0 13 50
15 E. cordatum Gauteng 4.71 15.89 5.99 4.80 3.25 174.54 1.19 36.44 8.58 1.64 42.0 14 54
for each location, i want to summarize the data such that the soil properties are in the first column while the legumes are the other columns and each value reported as the mean ± SD. something like the table below.
i am thinking dcast
but i am not sure how to get the values as mean ± SD