I was trying to get descriptive stat for my data. I went through many suggestions. However I just want to know if there is any package(s) to perform descriptive stats on the data format provided below.
head(mydata)
X A1 A2 A3 M1 M2 M3 U1 U2 U3
1 A A A M M M U U U
2 X1 100 200 250 200 230 400 400 100 200
3 X2 600 300 400 300 550 750 800 900 540
4 X3 500 300 200 200 200 100 500 400 600
The data has samples on the column and variables on rows. First row is samples name, second row is groups (A, M, U). I want to get descriptive statistics for each group. For example mean, sd.... for group A (A1, A2, A3). Could anyone please let me know how can I do this. I have seen most of the answers on descriptive stats and they are for columns. Please let me know if the question is not clear. Thank you for your help.
Higgs
@Phil is dead right with his recommendation.
One of the key principles you'll learn in Hadley's book is the tidy data principle (very basically: variables in columns, individual observations in rows). If you want a quick introduction to tidy data, try this vignette.
There are multiple ways to go about fixing and analysing your data, but here is an example using tools from the 'tidyverse'.
Convert to a tidy dataframe
Now summarise the data.
Update: 10 May 2018 following query about adding the coefficient of variation.
Coefficient of variation is not a base R function, so create a user-defined function.
Re-execute the summary with added summary functions
Created on 2018-05-10 by the reprex package (v0.2.0).