0

I am working on a uni project and have downloaded tweets using rtweet. What I have is, one data frame per country on the WHOlist with tweets over one week, and one data frame that contains information on WHO_region, population, total confirmed cases, total deaths, area/km² and density/km² per country.
I want to combine the information from both data frames.

I have tried this

Azerbaijan_data <-  mutate(Azerbaijan_data,WHO_region = "Europe", country = "Azerbaijan", population = "10125041",  area_km²= "82658", density_km²= "122.66")

but the deaths and cases columns have date specific observations and adding them manually will take far too long.

I was hoping there is a way to automate the process. I would really appreciate it, if someone could help me out.

nikn8
  • 1,016
  • 8
  • 23
LSK
  • 1
  • 1
    Welcome to SO!!! Please always do share sample data using `dput(head(df))`. In your case you can join both tables using `merge` or `left_join`. [This](https://rstudio.com/wp-content/uploads/2015/02/data-wrangling-cheatsheet.pdf) should give you some idea. – nikn8 May 09 '20 at 13:31
  • Hi thanks for that. I'v had a look but my problem is that two data frames aren't the same length. Lets say I have 500 tweets (observations) from 04.05.20 in df1 which correspond to one row of observations in df2. And then I have another 300 tweets for the following day corresponding to the next row in df2. And I have that data for 100 countries. How can I join the data frames so that the info from df2 gets matched with the correct info from df1? – LSK May 10 '20 at 09:28

0 Answers0