KH1990
KH1990

Reputation: 1

Cleaning data in two columns causes deletion as they logically are linked i.e. one is true the other has to be false

I am new to both here and RMarkdown (part of my undergrad psychology course this year). I'll explain my issue and hope I don't inadvertently commit some form of faux pas.

I have data analysis to do on a data set part of this process involves me mutating data to take certain values and then creating two groups one religious and the other not, I have managed this and it has successfully added the columns Believer and Non_believer.

further on in the task I am required to clean the data i.e. get rid of NA values from these columns and one other. Naturally though if one is a Believer they cannot be a Non_believer it defies logic so if I try drop_na etc it deletes all observations.

I somehow feel there probably is a simple solution and/or my code is just not efficient or I am being an idiot which is at least just as likely.

My code when using mutate:

demographics <- demo_dat %>% 
mutate(Believer = case_when(Belief_god == "I am sure that God really exists and is active in my life" ~ "Is Religious/Spiritual",
                                  Belief_god == "I describe my belief in God in another way" ~ "Is Religious/Spiritual"),
       Non_believer = case_when( Belief_god == "I don’t believe in a personal God" ~ "Is NOT Religous/Spiritual",
        ))

After this I tried to use drop_na to drop the values in each but that was never going to work now siting here I don't even know why I tried it.

any advise would be greatly appreciated also any recommendations on where I could learn more wouldn't go amiss.

as mentioned above I tried the usual ideas for dropping NA values but as two columns are logically linked if I do this it deletes all data.

Upvotes: 0

Views: 11

Answers (0)

Related Questions