Copy to Database (dplyr Databases)
Dr. Undómiel has decided to focus on the change in size of a few target rodent species over the course of the experiment(1977-2002). She has chosen Dipodymys spectabilis, Onychomys torridus, Perymiscus erimicus, Chaetodipus penicillatus.
Write a script that uses dplyr to:
- Connect to the
portal_mammals.sqlite. - Generate a data frame with
year,species_id, and the average weight per year (avg_weight) for each target species. You may find the%in% c()construction useful for yourfilter(). - Use
copy_to()to include your new data frame inportal_mammals.sqlite. Call it something informative so that Dr. Undómiel can find it easily. Make sure it remains after the connection is terminated usingtemporary = FALSE.