I have a file with 30 variables and 2000 individual. But a summary would be something like as:
Name Farm milk protein fat dim data
1110 PE 10.3 3,7 3.6 146 06/07/20
3322 PE 18.3 3,3 3.9 158 06/03/20
1125 PE 22.3 3,4 4.6 210 12/04/20
1777 PE 14.3 3,0 4.2 100 28/04/20
8970 PE 17.3 3,2 3.6 185 14/06/20
I need:
- Calculate for all the variables mean, median, min, max, quartiles and group all the results into a unique/single table, I used three options:
sapply (fenotipi2, summary) R ##print only two columns with all values together
library(purrr)
library(dplyr)
phenotype2 %>%
map (~ summary (.)) %>%
rbind.data.frame
## Error in rbind.data.frame(.):
## invalid list argument: all variables should have the same length
library(dplyr)
library(tidyr)
phenotype2 %>%
pivot_longer(everything()) %>%
summarize_at(vars (value), list(Min = min, Mean = mean,
Max = max, Sd = sd))
## A tibble: 1 x 4
## Min Mean Max Sd <dbl> <dbl> <dbl> <dbl> 1 NA NA NA NA
- I must also do all the histograms and distributions for continuous variables in one step, I used
require(MVN)
result = mvn(data = fenotipi2 [-4], subset = "Species", mvnTest = "hz",
univariateTest = "AD", univariatePlot = "histogram",
multivariatePlot = "qq", multivariateOutlierMethod = "adj",
showOutliers = TRUE, showNewData = TRUE)
I don't get the desired results.
summary
output depends on the class of the column. In the code, there are two datasetsphenotype2
andfenotipi2
. which one of them is the data showed – akrunHmisc::describe(fenotipi2)
– akrundfSummary
fromsummarytools
package very useful for quick exploration of many variables – Waldicapture.output(Hmisc::describe(fenotipi2), file = "yourfile.txt")
– akrun