I am trying to calculate the number of samples, mean, standard deviation, coefficient of variation, lower and upper 95% confidence limits, and quartiles of this data set across each column and put it into a new data frame.
The numbers below are not necessarily all correct & I didn't fill them all in, just provides an example. These values will be used to create a box plot, hence the need for the quartiles. Rows and columns would be headers in the end. See example below.
Here is the structure:
B1 <- c(8, 6, 13, 6, 27, 104, 18, 3)
B2 <- c(2, 13, 1, 64, 127, 24, 4, 3)
B3 <- c(8, 16, 113, 680, 227, 310, 138, 30)
B4 <- c(238, 46, 613, 69, 7, 14, 4, 8)
x <- data.frame(B1, B2, B3, B4)
> head(x)
B1 B2 B3 B4
1 8 2 8 238
2 6 13 16 46
3 13 1 113 613
4 6 64 680 69
5 27 127 227 7
6 104 24 310 14
Desired output:
> y
B1 B2 B3 B4
n 8 8 8 8
mean 23 30 190 125
Stand dev 5 2 34 2
CoeffofVariation 0.3 0.4 0.7 1.3
LowerConfInterval 2 20 35 45
UpperConfInterval 50 120 122 120
LowerQuartile
Median
Upper Quantile
Inter Quartile Range
Minimum
Maximum
Regression equation