EdR.merge <- function(dfs, vs, newcolname) {
#Example: data3 = EdR.merge(list("data1", "data2"), list("first", "second"), "version")
#Check the input lengths and types as much as possible
stopifnot(
is.list(dfs) && length(dfs) > 1,
is.list(vs) && length(vs) == length(dfs),
is.character(newcolname) && length(newcolname) == 1
)
#Start to form the result
result <- as.data.frame(dfs[1])
curr_v <- as.character(vs[1])
result[,newcolname] = curr_v
# Add the rest of the data frames with their appropriate values
for(i in 2:length(dfs)) {
curr_df <- as.data.frame(dfs[i])
curr_v <- as.character(vs[i])
curr_df[,newcolname] = curr_v
result <- rbind(result, curr_df)
}
# Return the result
return(result)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.