Group the 'Species' using the group_by method and then sum the 'Weight' column and then plot the graph.
library(dplyr)
df %>%
group_by(Species) %>%
summarise(Weight = log(sum(Weight))) %>%
ggplot(aes(x = Species, y = Weight)) +
geom_col()
Or You can use base R
aggregate(Weight ~ Species, df, sum)
Then use the bar plot if needed.
barplot(rowsum(df$Weight, df$Species)[,1])
If you want to use the log then you can wrap with log, check out the code to do it:
barplot(log(rowsum(df$Weight, df$Species))[,1])
Data I have used is:
df <- structure(list(Species = c("Dog", "Cat", "Dog", "Dog", "Cat",
"Dog", "Cat"), Weight = c(7L, 2L, 5L, 4L, 3L, 9L, 2L)), class = "data.frame", row.names = c("1",
"2", "3", "4", "245", "246", "247"))
If you are a beginner and want to know more about Data Science the do check out the Data Science course