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) #andmed$production_year=as.numeric(andmed$production_year) ggplot(andmed)+geom_point(aes(synniaasta, esmavanus), alpha=0.5) #ggsave("filmikogused6.png", width=25, height=20, units="cm")