I have a large dataset called “inputs”. One of the columns in the dataset is a flag called “constrained” with either “Y” or “N”. I want to create two datasets where one is the rows where the flag is “Y” and one is the rows where the flag is “N”.
I tried:
ifelse(inputs$constrained == "N",unconstrained <- inputs,constrained <- inputs)
but both datasets unconstrained and constrained are identical to inputs.
What am I doing wrong?
If you wanted to use “[” you could do this:
Both of that second option might have entries where ‘constrained’ is NA, due the screwy way that R handles NA conditionals although it would not be a faithful reflection of those rows. (I admit I did not sure what the split method does with NA’s.) I just tested the split method and it might be superior, since (like
subset) it does not return theis.na(input$constrained)rows.