(na.r) what does it mean??/

Hi, Brothers

I want to ask you, what does this mean
summarize(mean_len = mean(len, na.r = T),.group = 'drop')

1 Like

That argument is for telling the mean() function whether to remove NA (missing values) before trying to calculate the mean or not.

If you set this to FALSE and your data contains missing vales, no mean is going to be calculated and you are going to get NA as output.

2 Likes

Thank you so much.

filtered_toothgrowth <- ToothGrowth %>%

  • filter(dose == 0.5) %>%
  • group_by(supp) %>%
  • arrange(len) %>%
  • summerize(mean_len = mean(len, na.r = T),.group = 'drop')

I am just wondering, what is (.r) and what does( drop) mean here?
and you said that (T) means, to remove the (N/A) values, right?

The argument's name is na.rm in the code you are showing it has been abbreviated to na.r, this works as long as there are no other arguments with similarly starting names. So .r has no meaning on its own.

Your data has been grouped by the supp variable and .group = 'drop' is just telling to drop the groping after summarizing the data so it has no effect on subsequent actions.

No, T stands for TRUE and it is simply a "logical" value, it performs no action by its own, in the code you are setting the value of the na.rm argument to be TRUE

I think you are approaching your learning path in a not very efficient way, I think you first need to study the basics of the dplyr syntax and then you can learn from specific coding examples. You can get the basics by reading this free ebook

3 Likes

Thank you for your help, I will read the book.

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.