here is my r df: financialyear companycode maxqty maxexp opselbus CPIH unitcost…
- User
here is my r df:
financialyear companycode max_qty max_exp op_sel_bus CPIH unit_cost total_penetration 1 2017 AFW 3689.000 259000.00 optant 1.000000 70.20873 0.5332044 2 2017 ANH 8569.000 2043000.00 optant 1.000000 238.41755 0.8116085 3 2017 BRL 4551.000 1436000.00 optant 1.000000 315.53505 0.5105836 4 2017 DVW 907.000 150000.00 optant 1.000000 165.38037 0.6149640 5 2017 NES 23358.000 7006000.00 optant 1.000000 299.94006 0.4607484 6 2017 NWT 36615.000 10443458.79 optant 1.000000 285.22351 0.4185225 7 2017 PRT 2470.000 749000.00 optant 1.000000 303.23887 0.3042767 8 2017 SES 2524.000 858000.00 optant 1.000000 339.93661 0.5380738 9 2017 SEW 2193.000 482000.00 optant 1.000000 219.79024 0.8333559 10 2017 SSC 6163.000 1755276.59 optant 1.000000 284.80879 0.4320451 11 2017 SVT 32484.000 5123000.00 optant 1.000000 157.70841 0.4440263
- Assistant
Based on the given data, it appears to be a dataframe with the following columns:
- financialyear: year of financial data
- companycode: code/name of the company
- max_qty: maximum quantity
- max_exp: maximum expense
- op_sel_bus: operational selected business
- CPIH: Consumer Price Index for Housing
- unit_cost: cost per unit
- total_penetration: total penetration ratio
The data seems to be related to financial and operational metrics for different companies in the given financial year.
- User
correct this code:
optants_data2 <- optants_data %>% mutate(selective_installs = case_when(op_sel_bus = "Selective" ~ 1, TRUE ~ 0))
- Assistant
The code you provided seems to be correct. It is using the dplyr package to mutate a new variable called "selective_installs" in the dataframe "optants_data2". The new variable is created based on the values in the "op_sel_bus" column. If the value is "Selective", the corresponding value in "selective_installs" will be 1, otherwise it will be 0.