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), 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(synniaasta>=1985) vanad=andmed %>% filter(synniaasta<=1955) t.test(noored$esmavanus, vanad$esmavanus)