Sum by Group in R (2 Examples) | Apply aggregate Function to Vector / Column / Variable

preview_player
Показать описание

R code of this tutorial:

data(iris) # Load iris data
head(iris) # First six rows

aggregate(x = iris$Sepal.Length, # Specify data column
by = list(iris$Species), # Specify group indicator
FUN = sum) # Specify function (i.e. sum)
Рекомендации по теме
Комментарии
Автор

Exactly what i was looking for. Thanks fir your amazing work this would have cost me days

simonstoffels
Автор

thanks and it was a very good explanation

jaikishank
Автор

Can we apply aggregate function to add two columns based on one list. If yes, plz enlighten me with the code.

preetidhiman
Автор

0:28 You don't need to double click, just click once to open a dataframe.

tsunetasora
Автор

The function is working for me. In a big data set it shows lot of groups, is there any way we can filter particular group?

robb
Автор

the video is helpful to perform the aggregate function for one variable. could you please specify the command for the sum of items from multiple columns( eg I have to compute the sum of items from VAR 6 from particular raw of Var 1 and then particular rows from Var 2. and then by Particular rows of VAR 5

josephravi
Автор

Hi, thanks for your video. I have one question. How can I have the sum of all the variables depending on the species?

carlestr
Автор

How do you use the 'max' (maximum value) for the function. It gives an error.

Janith