mercredi 23 décembre 2020

recoding a few values within a few columns and leave everything else within those column intact

In my data.frame d2, I'm trying to recode a few values within a few columns and leave everything else within those column intact. Specifically, I want to do the following:

profic: replace 77s with 99s; cf.type: replace 15s with 99s; Length: replace 0s with 1s and replace 3s with 2s; graded: replace 88s with 99s.

I have tried the following but it seems I don't get the desired result (i.e., the other values in the recoded columns get deleted), is there a fix to this?

library(tidyverse)

d2 <- read.csv('https://raw.githubusercontent.com/rnorouzian/m/master/v13.csv')

d3 <- mutate(d2, profic = recode(profic, "77"="99"),
       cf.type = recode(cf.type, "15"="99"),
       Length = recode(Length, "0"="1", "3"="2"),
       graded = recode(graded, "88"="99")
       )

Aucun commentaire:

Enregistrer un commentaire