I have a dataframe (full) like this:
obtained by merging a list of numeric ID codes and a dataframe (reproducible example):
library(plyr)
library(dplyr)
#Create example list: ID codes
l1 <- c(10, 100, 1500)
l2 <- c(45, 100)
l3 <- c(100, 1500, 3000, 4000)
l <- list(l1, l2, l3)
#Convert list into dataframe
ldf <- ldply(l, rbind)
#Create example dataframe
i <- data.frame(index = c(1, 3, 5))
#Merge the two dataframes
full <- merge(i, ldf, by = 'row.names', all = TRUE) %>% select(-Row.names)
I would like to reshape the dataframe as follows:
in order to get the sum of the index values for each ID code.
Any idea??

