Search code examples
rdataframetibble

R: How do I replace a column with another column from a different dataframe?


I want to replace the 6th column of the ped dataframe with the Phenotype column from bipolar_ctl dataframe.

My attempt:

dplyr::mutate_at(ped, vars(-one_of("bipolar_ctl$Phenotype")))

Solution

  • Using base R,

    ped[,6] = bipolar_ctl$Phenotype