I am trying to make a CSV export of a group of summary stats generated with (similar to):
group_sum <- tapply(df$value, df$group, summary)
I tried using this to export the batch of summary stats:
write.csv(t(as.matrix(group_sum)), file="name.csv")
Although the output is written to a CSV. It is not properly organized. Row1 lists the group names and Row2 includes ALL of the summary stats for each group.
What I need is a header row that lists the types of stats generated (i.e., Min, 1st Qu., Median, Mean, 3rd Qu., Max) and each set of summary stats listed on a separate row below the header row (labeled with the group names in a separate column). Any thoughts on how I can generate the CSV output this way?