#' Aggregate by unique cases in column 1 (version 1)
#'
#' Version 1 aggregates by summing the numbers. Make sure the column on which agreegation is based is first from the left.
#'
#' @param df Input data frame to be aggregated.
#' @return Aggregated df
#' @export
#'
aggregate_by_unique_in_a_column_v1 = function(df){
df[,col] = as.character(df[,1])
u = unique(df[,1])
o = as.data.frame(matrix(nrow=1,ncol=ncol(df)-1))
for(i in 1:length(u)){
#print(paste("Processing ", u[i],sep = ""))
case = df[df[,1]==u[i],2:ncol(df)]
case = colSums(case)
o = rbind(o,case)
}
colnames(o) = colnames(df[,-1])
o = o[-1,]
rownames(o) = u
o
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.