Replacing values from a column using a condition in R

后端 未结 2 945
迷失自我
迷失自我 2020-11-28 06:19

I have a very basic R question but I am having a hard time trying to get the right answer. I have a data frame that looks like this:

 ind<-re         


        
2条回答
  •  南方客
    南方客 (楼主)
    2020-11-28 06:29

    I arrived here from a google search, since my other code is 'tidy' so leaving the 'tidy' way for anyone who else who may find it useful

    library(dplyr)
    iris %>% 
      mutate(Species = ifelse(as.character(Species) == "virginica", "newValue", as.character(Species)))
    
    

提交回复
热议问题