library(RMySQL) library(tidyverse) library(animation) yhendus<-dbConnect(dbDriver("MySQL"), user='mart', password='ajutine1234', host='localhost', dbname='mart' ) saveGIF({ for(minkogus in c("0", "5", "20", "100", "200")){ # print(minkogus) paring<-dbSendQuery(yhendus, paste0(" SELECT title, COUNT(*) AS kogus FROM (SELECT efis_film_type_translation.title, efis_film_type.id AS tyybi_id FROM efis_film_type JOIN efis_film_type_translation ON efis_film_type_translation.film_type_id=efis_film_type.id AND efis_film_type_translation.language='et' WHERE efis_film_type.id IN (33, 6, 56)) AS tabel1 LEFT JOIN (SELECT COUNT(efis_film_role_person.id) AS naitlejaid, efis_film_type_rel.film_type_id, efis_film.id AS filmi_id FROM efis_film JOIN efis_film_type_rel ON efis_film_type_rel.film_id=efis_film.id LEFT JOIN efis_film_role_person ON efis_film_role_person.film_id=efis_film.id WHERE film_type_id IN (56, 33, 6) GROUP BY efis_film.id HAVING naitlejaid >=", minkogus, " AND naitlejaid<=300 ) AS tabel2 ON tabel1.tyybi_id=tabel2.film_type_id GROUP BY title ")) andmed=fetch(paring, n=-1) #andmed=andmed %>% filter(kymnend>=1910 & kymnend<=2010) #print(andmed) p=ggplot(andmed, aes(title, kogus)) + geom_col() print(p) } }, movie.name="kogused6.gif", interval=1)