Adding md2csv and tab2md functions.
This commit is contained in:
@@ -0,0 +1,7 @@
|
||||
md2csv<-function(text, rm_blank=T){
|
||||
text<-strsplit(text, "\n")[[1]]
|
||||
text<-gsub("^[ |]*|[|][ ]*$","",text)
|
||||
if(rm_blank){text<-gsub(" ","",text)}
|
||||
text<-gsub("[|]",",",text)
|
||||
return(cat(text,sep = "\n"))
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
tab2md<-function(table){
|
||||
samples_csv<-table
|
||||
table<-apply(table, 1, paste, collapse="|")
|
||||
table<-gsub("^","|",table)
|
||||
table<-gsub("$","|",table)
|
||||
table<-c(paste0("|",paste(colnames(samples_csv), collapse="|"),"|"),
|
||||
paste0("|",paste(rep("---",ncol(samples_csv)), collapse="|"),"|"),
|
||||
table)
|
||||
cat(table, sep="\n")
|
||||
}
|
||||
Reference in New Issue
Block a user