Add New Variable to Data Frame Based On Other Columns in R (2 Examples) | $ Operator | transform()

Add New Variable to Data Frame Based On Other Columns in R (2 Examples) | $ Operator | transform()

Statistics Globe

2 года назад

26,150 Просмотров

Ссылки и html тэги не поддерживаются


Комментарии:

@rasengan9743
@rasengan9743 - 02.10.2022 17:29

Hey, great explaination
I have a question, like how can we transform data to have each statistic shown in one column?
I have a data set which requiring cleaning

Ответить
@nikhilrajgopal3999
@nikhilrajgopal3999 - 21.09.2022 20:53

hi how would you create averages between numbers instead of adding them together

Ответить
@3rdfriend
@3rdfriend - 13.08.2022 22:53

Hi! I got a question here, which I failed to find something online.
I have a huge database in which two questions are Yes/No-Questions.

Example:
Person | Q1 | Q2
1 Yes No
2 No Yes
3 Yes Yes
4 No No
5 No Yes

I want to create a dataframe which groups the participants in the possible combination of answers.
Y, Y = 1 = 20%
Y, N = 1 = 20%
N,Y = 2 = 40%
N,N = 1 = 20%

So I want to count the combination of possible answers and then add a column containing the percentage.
Does anyone have a clue how I can do this in one dataframe/table? I only was able to make three different ones and then see how many observations suit my criteria. I cannot display them yet.
Thanks in advance :-D

Ответить
@tanushreenagar3116
@tanushreenagar3116 - 07.08.2022 16:34

Nice

Ответить
@anuradhanayudu9367
@anuradhanayudu9367 - 05.08.2022 01:57

Thank you so much! This is so helpful!

Ответить
@Lello991
@Lello991 - 16.03.2022 15:22

Hi, and thanks for your videos! I'm just approaching R and I have a very simple problem here: let's imagine that there is some missing value (NA) in x1 or x2. When summing x1 and x2, in x3 we will find a NA, as 3+NA = NA.
How can I tell R to ignore the missing value, so that 3+NA = 3 ??
I found the na.rn=TRUE function, but I don't know where to put it. Could you please give me a hint?
Thanks in advance!

Ответить
@larissacury7714
@larissacury7714 - 20.02.2022 19:12

Thank you very much! I love your videos! For method 2: would it work with %>% from tidyverse? I believe we can do this with tidyverse, what would be the best method? I need to create a new df based on the collums from my actual df

Ответить
@Jao2k8
@Jao2k8 - 06.10.2021 19:21

Great video, thanks!

Ответить
@G_B_R
@G_B_R - 10.09.2021 17:51

A very clear useful video.thanks..

Ответить
@rodneyjones5066
@rodneyjones5066 - 28.08.2021 15:43

Thankyou for a very clear and concise explanation. Are there any circumstances when you would prefer one method to the other?

Ответить
@razorscythe7258
@razorscythe7258 - 28.08.2021 08:08

nice. we can also use mutate function in dplyr package

Ответить