library(tidyverse) isikud=read_csv("http://www.tlu.ee/~jaagup/andmed/muu/estonia_reisijad.txt") isikud %>% ggplot(aes(Age)) + geom_histogram(binwidth = 10) + facet_wrap(~Category, nrow = 2) isikud %>% ggplot(aes(Age)) + geom_histogram(binwidth = 10) + facet_grid(Sex~Category) isikud %>% filter(Country %in% c("Estonia", "Sweden")) %>% ggplot(aes(Age)) + geom_histogram(binwidth = 10) + facet_grid(Sex~Country) isikud %>% filter(Country %in% c("Estonia", "Sweden")) %>% ggplot(aes(Age, fill=Sex)) + geom_histogram(binwidth = 10, position = "dodge") + facet_grid(Category~Country) isikud %>% group_by(Sex) %>% summarise(kogus=n()) #Koostage facet_wrap eesti, soome ja rootsi isikute vanuste histogrammi kohta #Koostage facet_grid eesti, soome ja rootsi isikute #vanuste ja sugude histogrammi kohta #Koostage sugude sektordiagramm vastavalt kodakondsusele (4 levinumat (+ muud)) #Lisage facet_wrap kategooria kaupa #Lisage facet_grid soo kaupa isikud %>% filter(Country %in% c("Estonia", "Sweden")) %>% ggplot(aes(x="", y=length(Country), fill=Country)) + geom_col( position = "fill")+coord_polar("y")+ theme(axis.text = element_blank(), axis.ticks = element_blank(), panel.grid = element_blank())+ xlab("")+ylab("") + facet_grid(Sex~Category) sonad=read_csv("http://www.tlu.ee/~jaagup/andmed/keel/kunglarahvas_lambipirn_pikkused_haalikud.txt") ecom <- readr::read_csv('https://raw.githubusercontent.com/rsquaredacademy/datasets/master/web.csv') ggplot(ecom, aes(x = n_pages, y = duration)) + geom_point() + geom_abline(slope=20, intercept=0)+ geom_abline(slope=0, intercept=300) + geom_smooth(method="lm") ecom %>% filter(n_pages>1) %>% ggplot(aes(x = n_pages, y = duration)) + geom_point() + geom_abline(slope=20, intercept=0)+ geom_abline(slope=0, intercept=300) + geom_smooth(se=FALSE) ecom %>% group_by(device) %>% summarise(kogus=n()) %>% ggplot(aes(device, kogus)) + geom_col() + coord_flip() ecom %>% group_by(device) %>% summarise(kogus=n()) %>% ggplot(aes(device, kogus)) + geom_col() + geom_hline(yintercept = c(150, 200, 250)) + geom_vline(xintercept = 1.7, color="red")+coord_flip() ggplot(mtcars, aes(disp, mpg, label = rownames(mtcars))) + geom_label() ggplot(mtcars, aes(disp, mpg, label = rownames(mtcars))) + geom_text( check_overlap = TRUE) ggplot(mtcars, aes(x = disp, y = mpg, size = disp)) + geom_point() Joonise katsetus Pange eri tunnused näitama suurust, kuju, värvi Katsetage pealkirjade teksti omadustega ecom %>% filter(n_pages>1) %>% ggplot(aes(n_pages, duration)) + geom_point() ecom %>% filter(n_pages>1) %>% ggplot(aes(n_pages, duration, shape=device, color=referrer)) + geom_point()+ ggtitle("Veebikasutus", subtitle = "eelmisel aastal")+ theme(plot.title=element_text(face = "italic")) + scale_shape_manual("Seade", values=c("laptop"=12, "mobile"=22, "tablet"=25))