Answers for "add column value based on row index r"

R
0

add column value based on row index r

# We can use row_number() function in dplyr 
# We will test if the row is present in your vector and assign the value accordingly

library(dplyr)
sig = c(5, 10, 20)

genes %>%
mutate(Sig = ifelse(row_number() %in% sig, "YES", "NO"))
Posted by: Guest on February-24-2021

Code answers related to "add column value based on row index r"

Browse Popular Code Answers by Language