Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please use routines from base R. Create the following data frame called data. With respect to variables x1, x3 and x4, please use sequences. Finally,

  1. Please use routines from base R.

    1. Create the following data frame called data. With respect to variables x1, x3 and x4, please use sequences. Finally, check the data structure and data types of data.

image text in transcribed

  1. Create a new binary (1 or 0) variable x5 that is part of data object "data". Assign value 1 to x5 if values of variable x2 are equal or greater than 100 AND less than 200 AND if x4 does not equal 2020. Otherwise, assign 0 to x5.

  2. Please cut the numeric variable x2 into a new ordinal variable x6 with following three categories (breaks): (0-200], [201-300], [301-400]. You may use the cut-function. Check if x6 is really an ordinal variable.

  3. Replace the value of second and fifth observation (rows) of variable x1 by value 20.

  4. Replace the value of variable x4 by 2018 if x5 equals 1 OR if x2 is equal or less 150.

  5. Drop variables x3, x5 and store selection in new data object data2.

  6. Rename the variables of data2 the following: x1 = age, x2 = income, x4 = year, x6 = income_bracket.

  7. Given the data object data2, please re-arrange the variables into following order: year, age, income, income_bracket.

  8. Sort data2 by multiple columns. Sort first by income and then by age, both variables in descending order.

x1 x2 x3 X4 1 25 278 A 2019 2 27 113 B 2019 3 29 294 C 2019 4 31 217 D 2019 5 33 398 E 2020 6 35 328 F 2020 7 37 343 G 2020 8 39 113 H 2020 9 41 2521 2021 10 43 189) 2021

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

More Books

Students also viewed these Databases questions

Question

Explain the nature of human resource management.

Answered: 1 week ago

Question

Write a note on Quality circles.

Answered: 1 week ago

Question

Describe how to measure the quality of work life.

Answered: 1 week ago