Calculate Mean of Data Frame Column in R (6 Examples) | mean, summarise of dplyr, colMeans & na.rm

preview_player
Показать описание
R code of this video:

x2 = 9:5,
x3 = 5)

mean(data$x2) # Apply $-operator

mean(data[["x2"]]) # Apply square brackets

mean(data[ , 2]) # Specify index position

library("dplyr") # Load dplyr

summarise(data, my_mean = mean(x2)) # Apply summarise function

colMeans(data) # Apply colMeans function

data_NA <- data # Create example data with NA
data_NA$x2[c(1, 3)] <- NA

Follow me on Social Media:
Рекомендации по теме
Комментарии
Автор

I invested too many hours watching R videos with 'hundred-thousands views' and alas, your video solved my puzzle. Thank you

j-beryl
Автор

I just recently discovered your channel and I have to say, I love the content. I've learned a lot because you explain everything in detail and go through examples. You have my subscription lol I hope to continue learning more from you!!

juanvega
Автор

Thanks a lot for your content !!!! You are helping a lot of data professionals and data students.

bmh
Автор

Thanks a million sir,
For the effort, time invested and the VALUE you are ADDING to us!

Adeyeye_seyison
Автор

Thank you for your videos they are so helpful and you teach so well however in my data frame, my rows have 5 treatments and in each treatment, I have 3 results - how can I calculate the mean per treatment without having to separate each treatment - thank you and best regards

dominiquebarrette
Автор

Hello! Thanks for the video. I have a dataset with just 4 rows which I want to average, but across thousands of columns. Is there a way to simultaneously average all rows under each column, so that I have just one row of means under my thousands of columns?

ElDominator
Автор

thanks for your tutorials. I watched several of them but am still unsure how to calculate the mean for specific levels of different factors. for example, I want the mean of reaction_time for task A (in the factor task which is a column in data just the participants who did A ), and for correct trials(there is another factor called to answer and I want only the correct one to be calculated not wrongs). I would appreciate you introducing a function.

sabaamir
Автор

This is pretty good even for revision of learned concepts...

shivamshinde
Автор

I would have a question. What if i want to calculate several means within one column.
For example i have following dataset:

Colour Number
Black 2
Black 4
Brown 6
Brown 3
Black 6
Brown 3

And i want to calculate the mean for Black and for Brown.
Thx in advance!

lorenzkarl
Автор

what if I want to calculate mean of particular item from the column "word" in 2 different conditions, for example
cond word rt
A 8 10
B 8 19

zakjay
Автор

Thank you very much! However, what if I need to calculate the mean of two collumns like this:

(Same task, two teachers)

Teacher 1 Teacher 2 MEAN

5 6 5.5
6 7 6.5
7 8 7.5

larissacury
Автор

How to calculate the mean of selected column ?
I have 5 columns but I want the mean of last 3 columns

arthygunam
Автор

Why dont you show how to exclude few columns and take the means of the rest seperately? And other thing is getting the mean of only numerics. And the laat thing is combinjng the two?

alestamegayat
Автор

If I go to heaven, I will take you with me!

danishrizwan
Автор

Wanna Create Only Deviations from Mean for Entire Column❓️

Hassan_MM.