#' Inserts a column into a dataframe
#'
#' Inserts a column or dataframe y into a dataframe x at the
#' specified position
#'
#' @param x dataframe
#' @param y dataframe
#' @param where integer
#'
#' @return dataframe
#' @export
#' @examples
#' df1<-data.frame(a=3,b=4,c=5)
#' df2<-data.frame(X=1,Y=2)
#' insert_into(df1, df2, where=1)
#'
insert_into<-function(x,y,where=1){
if (where==1){
cbind(y,x)
} else if (where>ncol(x)){
cbind(x,y)
} else {
lhs<-1:(where-1)
cbind(x[lhs],y,x[-lhs])
}
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.