#' Function for finding out which columns are not present in some datasets
#'
#' @ inlist = input list containing dataframes
#' @ refcols = character vector with column names that must should be in every dataframe
# (usually taken from some reference dataframe)
#'
colcheck<-function(inlist,refcols){
# loop through datasets and extracts colnames
tmp1<-NULL
for (i in 1:length(dat)){
tmp<-data.frame(colname=names(inlist[[i]]),
Island=as.character(unique(inlist[[i]][,2])))
tmp1<-rbind(tmp,tmp1)
}
# insert an indicator to show whether column name is present
tmp1$counter<-1
# spread dataframe
tmp2<-spread(tmp1,Island,counter)
# merge with reference columns
refnames<-data.frame(id=1:length(refcols),colname=refcols)
# merge dataframe with reference columns
tmp3<-merge(tmp2,refnames)
# arrange by reference column id
tmp4<-arrange(tmp3,id)
# exclude column id
tmp5<-tmp4[,!names(tmp4) %in% c("id")]
# return result
return(tmp5)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.