Hi, I am using mutate and replace to change something in a data frame. In the preview of the file in the notepad it shows me that what I want to be replaced is indeed replaced with the right thing but when I "View" the file or export it and open it with excel, it is not actually replaced. It is still the original thing.
Here is the code I am using to convert the file to a data frame (I imported it as .txt file)
Convert to data frame and include _df at end of file name.
Merge.CD8.Phenotype.Part.2_cell_seg_data_df <- data.frame(Merge.CD8.Phenotype.Part.2_cell_seg_data)
Mutate CD8 to CD8+
Merge.CD8.Phenotype.Part.2_cell_seg_data_df %>% mutate(Phenotype = as.character(Phenotype)) %>% mutate(Phenotype = replace(Phenotype, Phenotype == 'CD8', 'CD8+'))
Phenotype Cell.ID Total.Cells
Other 91 NA
CD8+ 92 NA
Other 93 NA
The column header is "Phenotype" and I want to change all the CD8 to CD8+. As I mentioned above, in the preview window in the notepad, it says CD8+, but when I "View" it or export it, it still says CD8. Can anyone help me figure out what I am doing wrong? Do you need more information, sorry, I am new to R. Thanks for your help, Aaron