Chat with us, powered by LiveChat Tidy Data and More on Data Transformation Worksheet - Essayabode

Tidy Data and More on Data Transformation Worksheet

Instructions.

Use R Markdown to create an html document with the homework tasks.
•As always, any plots should have appropriate axis and overall labels.

1 Data
Data for this HW assignment come from a randomized experiment to study the efficacy of acupuncture for treating headaches. Results of the trial were published in the British Medical Journal in 2004. You may view the paper at the following link: http://www.bmj.com/content/328/7442/744.full. The data set includes 301 cases, 140 control (no acupuncture) and 161 treated (acupuncture). Participants were randomly assigned to groups.
Variable names and descriptions are as follows:
age; age in years
sex; male = 0, female = 1
migraine; diagnosis of migraines = 1, diagnosis of tension-type headaches = 0
chronicity; number of years of headache disorder at baseline
acupuncturist; ID for acupuncture provider
group; acupuncture treatment group = 1, control group = 0
pk1; headache severity rating at baseline
pk5; headache severity rating 1 year later
Import the data using read_csv() and call it acu. Note that the data have a header row.
Homework problems:
1. Create a new version of the data called acu2 that are sorted by treatment group, age, and baseline headache severity (pk1), in that order.
2. Create a subset of the data called acu3 that only includes particpants who were in the acupuncture group and were over 30 years of age.
3. Plot baseline vs one year headache severity in a scatterplot with different colors for treatment group and different regression lines by treatment group in ggplot2. What do the regression lines suggest about the efficacy of the acupuncture treatment?

4. Note that pk1 and pk5 are both measures of the same outcome variable taken at two different times (baseline and one year). Pivot the data from wide to long format so that pk1 and pk5 appear in a single column called severity. When pivoting, you
should create a new variable called time with values 0 or 1 depending on whether the observation was taken at baseline (= 0) or at 1 year (= 1). Note that it’s ok to do this in multiple steps or with piped mutate() calls; both will work. For example, when
you pivot, if you use names_prefix = “pk”, you will get a factor with levels 1 and 5. Then, you would need to change to numeric and change the levels to 0 and 1.
5. We only covered pivot_longer(). Figure out how to use pivot_wider() to get your data back from long format into wide format (i.e., restore them to their original form).

Our website has a team of professional writers who can help you write any of your homework. They will write your papers from scratch. We also have a team of editors just to make sure all papers are of HIGH QUALITY & PLAGIARISM FREE. To make an Order you only need to click Ask A Question and we will direct you to our Order Page at WriteDemy. Then fill Our Order Form with all your assignment instructions. Select your deadline and pay for your paper. You will get it few hours before your set deadline.

Fill in all the assignment paper details that are required in the order form with the standard information being the page count, deadline, academic level and type of paper. It is advisable to have this information at hand so that you can quickly fill in the necessary information needed in the form for the essay writer to be immediately assigned to your writing project. Make payment for the custom essay order to enable us to assign a suitable writer to your order. Payments are made through Paypal on a secured billing page. Finally, sit back and relax.

Do you need an answer to this or any other questions?