uploaddata <- function(csvfile, ...){
if(substring(tolower(csvfile), nchar(csvfile)-3) != ".csv"){
stop('Uploaded data needs to be .csv file. When using MS Excel, try "Save As" and select type "CSV (comma delimited)"');
}
#read csv data
mydata <- read.csv(csvfile, row.names = NULL, stringsAsFactors=FALSE, ...);
#convert columns with 7 or less levels to factors
for(i in seq_along(mydata)){
if(length(unique(mydata[[i]])) < 8){
mydata[[i]] <- as.factor(mydata[[i]]);
}
}
#return dataset
return(mydata)
}
uploadtree <- function(phylofile, ...){
if(substring(tolower(phylofile), nchar(phylofile)-3) != ".phy"){
stop('Uploaded data needs to be newick file with extension *.phy.');
}
#read tree data
mytree <- read.tree(phylofile, ...);
#return dataset
return(mytree)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.