Question
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,
-
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, check the data structure and data types of data.
-
-
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.
-
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.
-
Replace the value of second and fifth observation (rows) of variable x1 by value 20.
-
Replace the value of variable x4 by 2018 if x5 equals 1 OR if x2 is equal or less 150.
-
Drop variables x3, x5 and store selection in new data object data2.
-
Rename the variables of data2 the following: x1 = age, x2 = income, x4 = year, x6 = income_bracket.
-
Given the data object data2, please re-arrange the variables into following order: year, age, income, income_bracket.
-
Sort data2 by multiple columns. Sort first by income and then by age, both variables in descending order.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started