Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Can you write the syntax for the code? R There are two data files world_pop.csv and world_pop_metadata.txt which include the information about the world population

Can you write the syntax for the code? R

There are two data files world_pop.csv and world_pop_metadata.txt which include the information about the world population from 1960~2020 (downloaded from The world bank). The world_pop.csv file includes the population estimates for different countries and the world_pop_metadata.txt file includes the information about income and region of each country.

There are some missing values in both data sets and unfortunately the missing data structures are different in the two data sets. In this question, our goal is to transform these two data sets so that they contain no missing values while sharing the same countries.

(1 pt) Read world_pop.csv as a data frame and assign it to pop. There may be some redundant lines at the top of the file. Drop these lines. Print the first few lines of the data.

(1 pt) Read world_pop_metadata.txt as a data frame and assign it to pop.meta. Print the first few rows

(2 pts) Check if there are any missing values in pop and pop.meta.

(2 pts) Remove the missing values from pop and pop.meta and create new pop1 and pop.meta1 objects.

(2 pts) How many cases (countries) remain in each data, pop1, pop.meta1, respectively?

(2 pts) The two data sets currently may have different countries. How many observations in pop1 are not in pop.meta1? Similarly, how many observations in pop.meta1 are not in pop1?

Hint: both data frames have the same Country.Code variable.

(2 pts) Subset the data sets so that they contain the same countries and create new pop2 and pop.meta2 objects. Then, check the number of rows and columns.

(1 pt) Check if the countries in the two data sets (pop2, pop.meta2) are now the same using all() function.

(1 pt) Find the indexes (entries) that contain "Brazil", "India", "Nigeria", "United States", "Spain" in pop2.

(2 pts) Export the cleaned data sets to two csv files.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Managing Your Information How To Design And Create A Textual Database On Your Microcomputer

Authors: Tenopir, Carol, Lundeen, Gerald

1st Edition

1555700233, 9781555700232

More Books

Students also viewed these Databases questions

Question

How are the key biographical characteristics relevant to OB?

Answered: 1 week ago

Question

4. What would be the costs and benefits of taking these steps?

Answered: 1 week ago

Question

Do you think physicians should have unions? Why or why not?

Answered: 1 week ago