Hi All,
I am having some trouble formatting x-axis data to plot in R.
The main problem I am having is that I would like the format the X axis as a grouping of 5 independent variables (X0, X1, X2, X3, X4).
Taken together, these 5 independent variables form a survey method. The fill variable should be the value taken on the survey Q (i.e. a value of 1-3), and the y-axis should be the count.
I wondered if it would be possible if someone could show me how to group/merge/melt the X's into the equivalent of a single variable that could be plotted on the x-axis?
Would be greatly appreciated.
X0 <- c(1,2,3,3,3,3,3,3,3,2,2,2,2,2,2,2,2,2,2,1,1,1,1)
X1 <- c(3,3,1,1,3,3,3,3,3,2,2,2,2,2,2,2,2,2,2,1,1,1,1)
X2 <- c(1,2,1,1,1,1,1,1,3,2,2,3,2,2,2,2,2,2,2,1,1,1,1)
X3 <- c(1,2,3,2,2,2,2,2,3,2,2,1,3,2,2,2,2,2,2,1,1,3,1)
X4 <- c(1,2,3,3,3,3,3,3,3,2,2,2,2,2,2,2,1,1,1,1,1,2,3)
dat <- data.frame(X0, X1, X2, X3, X4)
X0 X1 X2 X3 X4
1 1 3 1 1 1
2 2 3 2 2 2
3 3 1 1 3 3
4 3 1 1 2 3
5 3 3 1 2 3
6 3 3 1 2 3
7 3 3 1 2 3
8 3 3 1 2 3
9 3 3 3 3 3
10 2 2 2 2 2
11 2 2 2 2 2
12 2 2 3 1 2
13 2 2 2 3 2
14 2 2 2 2 2