Skip to content
Snippets Groups Projects
Unverified Commit a79b4949 authored by Todor Kondic's avatar Todor Kondic
Browse files

Add basic tags manipulation functions

* R/shiny-ui-base.R(txt2tags,combine_tags): New functions.

Needed for shiny UI processing of mzml table.
parent 8916cc8d
No related branches found
No related tags found
No related merge requests found
......@@ -101,3 +101,22 @@ lst2rv_lst <- function(lst) {
if (class(lst) != "list")
lst else do.call(react_v,lapply(lst,lst2rv_lst))
}
txt2tags <- function(txt) {
## Turns a string into tags
x <- if (shiny::isTruthy(txt)) {
trimws(unlist(strsplit(txt, ",")))
} else list()
as.list(c("unspecified",x))
}
combine_tags <- function(df_tags,txt_tags) {
diff <- setdiff(df_tags,txt_tags)
for (x in diff) df_tags[df_tags %in% x] <- "unspecified"
df_tags <- factor(as.character(df_tags))
df_tags <- factor(as.character(df_tags),levels = unique(c('unspecified',levels(df_tags),txt_tags)))
df_tags
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment