2021-02-26

Create proportion of responses across columns

Hello lovely folks of stack overflow:

i am a beginner in R and at the moment i'm trying to create a proportion for each participant in my study of how many close friends they have who are different from them over their total number of friends.

My data from qualtrics is arranged so that participants were able to categorize up to 20 friends as "same" or "different", these responses are arranged in columns from Q34_1_44 to Q34_20_63. Of course not every participant had/rated the whole available 20 close friends, so many columns are almost all empty. Regardless i am trying to create another column that contains a numerical value that is equal to number of different friends/total (so blanks don't matter). i have tried the following (but got stuck as i realized this wasn't an appropriate function (or at least as far as i know):

    dataset.clean2 <- mutate(dataset.clean1, diff.friend=ifelse(Q34_1_44=="Different race",))

if anyone knows an easy to understand (no matter how tedious) way to find each participant's percentage of different friends your answers would be highly appreciated!

Thanks you so much in advance <3



from Recent Questions - Stack Overflow https://ift.tt/2Mq18zc
https://ift.tt/eA8V8J

No comments:

Post a Comment