Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

same data: Data Frame A Data Frame B Country Algeria Brazil Columbia Country Algeria Algeria Brazil Data Frame C Columbia Columbia Brazil Here are


same data: Data Frame A Data Frame B Country Algeria Brazil Columbia Country Algeria Algeria Brazil Data

Finally, the analyst needs to specify which are the variables to be gathered. For instance, it hardly makes  

same data: Data Frame A Data Frame B Country Algeria Brazil Columbia Country Algeria Algeria Brazil Data Frame C Columbia Columbia Brazil Here are three data frames, A, B, and C, with different organizations of the Year 2000 2001 Algeria Brazil 12 14 Y2000 7 12 16 Year 2000 2001 2000 2001 2000 2001 1. Comparing each of the following pairs of tables, is one considered "wider" as described in the chapter? If so, say which is wider; if not, explain. o A versus C o B versus C o A versus B 2. Which table format do you think would make it easiest to find the change from 2000 to 2001 for each country. How would you do it? 3. Suppose you have another table, ContinentData, which gives the continent that each country is in. Which table format do you think would make it easiest to find the sum of the values for each continent for each of the years? How would you do it? Columbia 16 Y2001 H Value Finally, the analyst needs to specify which are the variables to be gathered. For instance, it hardly makes sense to gather subject with the other variables; it will remain as a separate variable in the narrow result. Values in subject will be repeated as necessary to give each case in the narrow format its own correct value of subject. Here's how to gather variables from BP_wide and convert the result into BP_narrow. BP wide XX gather (key E when, value= sbp, before, after ) #alternative syntax; note the required quotes when specifying new column names BP wide %>% pivot_longer(cols= c(before, after), names_to= "when", values_to= "sbp") Again, the names of the key and value arguments are given as arguments. These are the names invented by the data analyst; those names are not part of the wide input to gather (). Arguments after the key and value are the names of the variables to be gathered. Example: Gender-neutral names In "A Boy Named Sue", country singer Johnny Cash famously told the story of a boy toughened in life by being given a girl's name. Indeed, Sue is given to about 300 times as many girls as boys according to Table 12.4. BabyNames %>% filter (name an "Sue") %>% group_by (name, sex) %>% Summarise (total = sum(count)) name sex total Sue F 144410 Sue M 519 Ta

Step by Step Solution

3.50 Rating (157 Votes )

There are 3 Steps involved in it

Step: 1

Comparing table formats 1 Comparing width A vs C A is wider Each year has its own column in A while ... 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

Fundamentals of Ethics for Scientists and Engineers

Authors: Edmund G. Seebauer, Robert L. Barry

1st Edition

9780195698480, 195134885, 195698487, 978-0195134889

More Books

Students also viewed these Accounting questions

Question

What research background do you have?

Answered: 1 week ago