library(RMySQL) library(tidyverse) yhendus<-dbConnect(dbDriver("MySQL"), user='mart', password='ajutine1234', host= 'localhost', dbname='mart' ) paring<-dbSendQuery(yhendus, "SELECT first_name, last_name, YEAR(date_of_birth) AS synniaasta, MIN(production_year) AS esmafilmiaasta, MIN(production_year)-YEAR(date_of_birth) AS esmavanus FROM efis_film_maker JOIN efis_people ON efis_film_maker.people_id=efis_people.id JOIN efis_film ON efis_film_maker.film_id=efis_film.id WHERE YEAR(date_of_birth) IS NOT NULL AND length(production_year)=4 AND efis_film_maker.classificator_code='FILM_MAKER_DIRECTOR' GROUP BY efis_people.id") andmed=fetch(paring, n=-1) noored=andmed %>% filter(esmafilmiaasta>=1985) vanad=andmed %>% filter(esmafilmiaasta<=1985) t.test(noored$esmavanus, vanad$esmavanus, conf.level=0.8) ggplot(noored, aes(esmavanus))+geom_histogram(color="green", bins=10)+ geom_histogram(data=vanad, color="blue", bins=10)