I would like to create one vector of every MKT observation for when the dummy variable equals 1 and another vector when dummy equals 0.
This is how my dataframe looks:
CodePudding user response:
Easy solution with dplyr
:
df_new <- filter(SP500.df, dummy == 1)
CodePudding user response:
You can do this with base R as well.
## Case when dummy = 1
MKT_vector = SP500.df[SP500.df$dummy==1,]$MKT