I split a data frame and recombined using the ddply function. I applied the fivenum function so that I could see min, first, median, third, max values of each variable.
d <- ddply(sara_data_gathered, "Variable", summarise, fivenum = fivenum(Percent))
I'm wondering now how I can spread this data frame so that each value (min, first, median...) is presented as its own variable. So I'm looking for a table with six total columns. I thought tidyr might be a good place to look but I don't think I have a labeled column for this. So first I'm trying to label a new column...
I tried using mutate and the rep command but you can see from the output it's not working :/
d <- d %>%
mutate(Position = rep(c("Minimum", "First Quartile", "Median", "Third Quartile", "Maximum"), each = 5))
d
Variable fivenum Position
Aromatics 1.0 Minimum
Aromatics 19.0 Minimum
Aromatics 28.0 Minimum
Aromatics 41.0 Minimum
Aromatics 67.0 Minimum
Asphaltenes 0.0 First Quartile
Asphaltenes 1.0 First Quartile
Asphaltenes 8.0 First Quartile
Asphaltenes 30.5 First Quartile
Asphaltenes 93.0 First Quartile