Before I get to my question, I should point out that I am new in R, and this question might be simplicity itself for an experienced user. I want to use ggplot2 to take full advantage of all the functionalities therein. However, I have encountered a problem that I have not been able to solve. If I have a data frame as follows:
df = as.data.frame(cbind(rnorm(100,35:65),rnorm(100,25:35),rnorm(100,15:20),rnorm(100,5:10),rnorm(100,0:5)))
header = c("A","B","C","D","E")
names(df) = make.names(header)
Plotting the data, where rows are Y and X is columns can readily be done in base R like e.g. this:
par(mfrow=c(2,0))
stripchart(df, vertical = TRUE, method = 'jitter')
boxplot(df)
The picture shows the stripchart & boxplot of the data
However, the same cannot readily be done in ggplot2, as x
and y
input are required. All examples I have found plots one column vs another column, or process the data into the column format. Yet, I want to set y
as the rows in my df
and the x
as the columns. How can this be accomplished?