Limited Offer Get 25% off — use code BESTW25
No AI No Plagiarism On-Time Delivery Free Revisions
Claim Now
Prices start at $5 per page · plagiarism-free papers · free revisions for 14 days 24/7 support: support@bestwriters.com
Uncategorized

Write function that takes a year & outputs a data frame

  • Posted
  • Authoradmin
  • Length260 words
  • Reading time2 min
Write My Assignment FREE

1.1. Explain why the data in its current form is not considered to be in ‘tidy’ format. (1 mark)
1.2. Write a function that takes a year and outputs a dataframe with one or more rows, where each row
shows the obesity rate of Male and Female in a country of that given year along with its 95%
confidence interval values. The returned dataframe should have 6 columns (Country, Year, Sex, Rate,
MinCI, MaxCI).
a) Load the data from the worksheet of the given year into a dataframe. (1 mark)
b) Drop the column ‘Both sexes’. (1 mark)
c) Add a new column named ‘Year’ filled all rows with the given year. (1 mark)
d) Use the gather() function to transform the data in the two columns Male and Female to become
rows. After this step, your dataframe now should have 4 columns: Country, Year, Sex, Rate.
(2 marks)
e) Split the Rate column into 3 columns named Rate, MinCI, MaxCI. Your dataframe should have 6
columns after this step: Country, Year, Sex, Rate, MinCI, MaxCI (2 marks)
f) Check and make necessary changes to make sure the data type of Rate, MinCI and MaxCI is
numeric. Print the summary of the dataframe. (1 mark)
g) Find and display rows with any invalid data, e.g. the rate value is not in the range of MinCI and
MaxCI, MinCI is larger than MaxCI, etc. If they exist, change the MinCI and MaxCI values in these
rows into NA. Print the summary of the dataframe.

The post Write function that takes a year & outputs a data frame appeared first on My Assignment Online.

Plagiarism Free Assignment Help

Expert Help With This Assignment — On Your Terms

✓ Native UK, USA & Australia writers ✓ Deadline from 3 hours ✓ 100% Plagiarism-Free — Turnitin included ✓ Unlimited free revisions ✓ Free to submit — compare quotes

admin

Academic writer and editor at BestWriters.

Get your paper off your plate tonight

Post your instructions for free. Prices start at $5 per page.

Place an order