Hi , I want to make a histograms, which I did but bars are runnin horizontally,
how to change them to vertical but leaving axises intact ?
data <- structure(list(
Lp = c(
"1", "2", "3", "4", "5", "6", "7", "8",
"9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19",
"20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30",
"31", "32"
), Group = structure(c(
1L, 1L, 2L, 2L, 1L, 1L, 2L,
2L, 1L, 1L, 2L, 2L, 1L, 1L, 2L, 2L, 1L, 1L, 2L, 2L, 1L, 1L, 2L,
2L, 1L, 1L, 2L, 2L, 1L, 1L, 2L, 2L
), levels = c(
"Radiowaves",
"Soniccurrents"
), class = "factor"), Gender = structure(c(
1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L
), levels = c(
"K",
"M"
), class = "factor"), Time = structure(c(
1L, 1L, 1L, 1L, 2L,
2L, 2L, 2L, 3L, 3L, 3L, 3L, 4L, 4L, 4L, 4L, 1L, 1L, 1L, 1L, 2L,
2L, 2L, 2L, 3L, 3L, 3L, 3L, 4L, 4L, 4L, 4L
), levels = c(
"before_treatment",
"two_procedures", "three_procedures", "after_treatment"
), class = "factor"),
Value_measured = c(
3, 5, 3, 7, 1, 5, 3, 5, 3, 1, 5, 7, 0,
5, 1, 5, 2, 4, 1, 4, 2, 5, 4, 6, 2, 5, 4, 2, 2, 4, 6, 1
)
), class = c(
"grouped_df",
"tbl_df", "tbl", "data.frame"
), row.names = c(NA, -32L), groups = structure(list(
Gender = structure(c(
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L
), levels = c("K", "M"), class = "factor"),
Time = structure(c(
1L, 1L, 2L, 2L, 3L, 3L, 4L, 4L, 1L, 1L,
2L, 2L, 3L, 3L, 4L, 4L
), levels = c(
"before_treatment", "two_procedures",
"three_procedures", "after_treatment"
), class = "factor"),
Group = structure(c(
1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L,
1L, 2L, 1L, 2L, 1L, 2L
), levels = c("Radiowaves", "Soniccurrents"), class = "factor"), .rows = structure(list(
1:2, 3:4, 5:6,
7:8, 9:10, 11:12, 13:14, 15:16, 17:18, 19:20, 21:22,
23:24, 25:26, 27:28, 29:30, 31:32
), ptype = integer(0), class = c(
"vctrs_list_of",
"vctrs_vctr", "list"
))
), row.names = c(NA, -16L), class = c(
"tbl_df",
"tbl", "data.frame"
), .drop = TRUE))
and the rest of the code:
lst3 <- split(data, data[c("Time", "Group", "Gender")], drop = TRUE)
mydf0 <- do.call(rbind, unname(Map(cbind, colour = names(lst3), lst3)))
ggplot(mydf0) +
geom_histogram(aes(y = Value_measured, fill = "red"), fill = "#E61EEB", orientation = "y") +
scale_x_continuous(breaks = seq(0, 10, by = 1), limits = c(0, 11)) +
scale_y_continuous(breaks = seq(0, 10, by = 1), limits = c(0, 11)) +
facet_wrap(~colour, scales = "free") +
labs(x = "Counts") +
labs(y = "VRNS scale values") +
theme(panel.background = element_rect(
fill = "#64D2AA", color = "#64D2AA"))+
theme(legend.position = "none")
Any help will be greatly appreciated,
thank you.