Here are the diff code snippets and I attach my dataset which has a date. I want the X Axis to have monthly labels only
# this generates chart 1
ggplot(data = gaDataExt, mapping = aes(x = date, y = users),group = NULL ) +
geom_bar(stat = "identity") +
#scale_x_date(date_labels = "%Y-%m") +
facet_grid(deviceCategory ~ .) +
theme_bw() +
labs(title = "Deakin University (http://www.deakin.edu.au/) users by Device Category", x="Date", y="users") +
ylim(0,NA)
#one suggestion produces chart2
gaDataExt %>%
mutate(date = ymd(date),
month = month(date)) %>%
group_by(deviceCategory) %>%
summarise_all(funs(mean)) %>%
ggplot(aes(month, users)) + geom_point() +
facet_grid(deviceCategory~.) +
theme_bw() +
labs(title = "Deakin University (http://www.deakin.edu.au/) users by Device Category", x="Date", y="users") +
ylim(0,NA)
# gives error message:Error in seq.int(0, to0 - from, by) : 'to' cannot be NA, NaN or infinite
#In addition: Warning message:
#All formats failed to parse. No formats found.
gaDataExt %>% mutate(date = ymd(date)) %>%
ggplot(aes(date, users)) + geom_point() +
facet_grid(deviceCategory~.) +
theme_bw() +
labs(title = "Deakin University (http://www.deakin.edu.au/) users by Device Category", x="Date", y="users") +
ylim(0,10)
# this gives an error message … Error in `[[.default`(object, name, exact = TRUE) :# subscript out of bounds
ggplot(data = gaDataExt, mapping = aes(x = lubridate::floor_date(date, "month"), y = pageviews, group = 1, color = deviceCategory) ) +
geom_col() + theme_bw() +
labs(x = "date", y = "Pageviews by Device Category") +
labs(title = "Andy D) Users by Device Category", x="Date", y="Total Page views") +
ylim(0,NA)
I attach my r script and dataset iof you could take a look and tellme what im doing wrong id me very appreciative !
Cheers
AD
Virus-www.avg.com