Add another variable B to dataset and use ifelse function where you get 0 for “N”and 1 for “Y” values
Dataset$B <- ifelse(Dataset$A=="N",0,1)
or you can use ifelse function on same variable as
Dataset$A <- ifelse(Dataset$A=="N",0,1)
More Related Contents:
- How to prevent ifelse() from turning Date objects into numeric objects
- Does ifelse really calculate both of its vectors every time? Is it slow?
- Nested ifelse statement
- Interpreting “condition has length > 1” warning from `if` function
- Why can’t R’s ifelse statements return vectors?
- Vectorized IF statement in R?
- Can dplyr package be used for conditional mutating?
- The condition has length > 1 and only the first element will be used
- else if(){} VS ifelse()
- Replace negative values by zero
- if/else constructs inside and outside functions
- if-else vs ifelse with lists
- if – else if – else statement and brackets
- Cumulative sum until maximum reached, then repeat from zero in the next row
- Unexpected ‘else’ in “else” error
- Create column with grouped values based on another column
- dplyr if_else() vs base R ifelse()
- Using ifelse in R
- Difference between if() and ifelse() functions
- if else condition in ggplot to add an extra layer
- Create new column based on 4 values in another column
- Assign a value, if a number is in between two numbers
- Adding new column with conditional values using ifelse
- How do I create a new column based on multiple conditions from multiple columns?
- Return a matrix with `ifelse`
- Looping over a Date or POSIXct object results in a numeric iterator
- Unordered combinations of all lengths
- How can I create a correlation matrix in R?
- Remove empty documents from DocumentTermMatrix in R topicmodels?
- How to pass column name as argument to function for dplyr verbs?