You can omit the caps in the first column and then fill.
Option 1: base Raggregate()
with(df, aggregate(list(y = y, z = z), list(x = tolower(x)), sum))
Alternatively, a method of the formula can also be used.
aggregate(. ~ x, transform(df, x = tolower(x)), sum)
Option 2: data.table. It also preserves the order that you show as a result.
library(data.table)
as.data.table(df)[, lapply(.SD, sum), by = .(x = tolower(x))]
, keyby by
3: R xtabs()
xtabs(cbind(y = y, z = z) ~ tolower(x), df)
(, , , ), , x .
:
df <- tructure(list(x = structure(c(1L, 2L, 3L, 6L, 4L, 5L), .Label = c("rain",
"Rain", "RAIN", "Snow", "SNOW", "Wind"), class = "factor"), y = c(2L,
4L, 7L, 8L, 3L, 11L), z = c(40L, 50L, 25L, 10L, 9L, 25L)), .Names = c("x",
"y", "z"), class = "data.frame", row.names = c(NA, -6L))