I have an exceptionally large dataset (50+ Sites, 100+ Solutes) and I would like to quickly generate a summary table of descriptive statistics for the data and be able export it as a .csv file.
Sample code (a very small subset of my data):
Site <- c( "SC2", "SC2" , "SC2", "SC3" , "SC3" ,"SC3", "SC4", "SC4" ,"SC4","SC4","SC4")
Aluminum <- as.numeric(c(0.0565, 0.0668 ,0.0785,0.0292,0.0576,0.075,0.029,0.088,0.076,0.007,0.107))
Antimony <- as.numeric(c(0.0000578, 0.0000698, 0.0000215,0.000025,0.0000389,0.0000785,0.0000954,0.00005447,0.00007843,0.000025,0.0000124))
stats_data <- data.frame(Site, Aluminum, Antimony, stringsAsFactors=FALSE)
stats_data_gather =stats_data %>% gather(Solute, value, -Site)
table_test = stats_data_gather %>%
group_by(Site, Solute) %>%
get_summary_stats(value, show = c("mean", "sd", "min", "q1", "median", "q3", "max"))
This results in a dataframe that calculates the required statistics BUT, results are truncated to only three decimal places (i.e. what should be something like 0.00000057 appears as 0.000).
I have tried variations of using:
options(digits = XX),
format(DF, format = "e", digits = 2),
format.data.frame(table_test, digits = 8)
I have tried these and other sample code found online but none will reproduce a summary dataframe that includes all necessary zeros for small number results (i.e. 0.00000057, not 0.000). I would even be fine with scientific notation but I haven't been successful in finding an example that will work.
This is my first post. I hope I have provided enough detail for help! Thanks!