Edit Lines in Dataset

Hi everyone,

do you know how i can change the names in the column "sex_upon_outcome" to "Male" and "Female" in order to check my hypothesis test if male animals have to stay longer in a shelter than femal animals:

dataset_1 <- read.csv(file = "aac_intakes_outcomes.csv")
dataset_1 <- subset(x = dataset_1,
                    select = c(dob_year,
                               animal_type,
                               sex_upon_outcome,
                               intake_year,
                               time_in_shelter_days,
                               age_upon_intake_.years.))

tally(~sex_upon_outcome, dataset_1)
Intact Female   Intact Male Neutered Male          NULL Spayed Female 
         9308          9732         28293             1         25549 
      Unknown 
         6789 

I don't need the destinction of Intact, Neurered, Spayed oder Unknown.

Thank you in advance.

You can use fct_recode() frome forcats package with something like this

fct_recode(dataset_1,
           Female = "Intact Female",
           Female = "Spayed Female",
           Male = "Intact Male",
           Male =  "Neutered Male")

Its not clear what you want to do with NULL and Unknown but you can follow the same logic

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.