I have a question about plotting in ggplot, or r in general.
If I have a data frame that looks something like this:
df <- data_frame(Patients = c(1:10),
test1 = sample(c(0,1), 10, replace = TRUE),
test2 = sample(c(0,1), 10, replace = TRUE),
test3 = sample(c(0,1), 10, replace = TRUE),
test4 = sample(c(0,1), 10, replace = TRUE))
Then the output looks like this.
# A tibble: 10 x 5
Patients test1 test2 test3 test4
<int> <dbl> <dbl> <dbl> <dbl>
1 1 0 1 1 0
2 2 1 0 1 1
3 3 1 0 0 1
4 4 1 1 0 1
5 5 1 0 1 1
6 6 1 0 0 1
7 7 1 1 1 0
8 8 1 0 0 1
9 9 1 0 1 1
10 10 0 1 0 1
How can I make a graph where the patients are on the x-axis as discrete entries, and the y axis has four discrete entries, one for each test?
For example:
I would also like to order the x axis by the number of matching tiles, like this.
Thanks very much for you time.