diff options
Diffstat (limited to 'inst')
-rw-r--r-- | inst/GUI/mkinGUI.R | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/inst/GUI/mkinGUI.R b/inst/GUI/mkinGUI.R index 921daea7..f5c30767 100644 --- a/inst/GUI/mkinGUI.R +++ b/inst/GUI/mkinGUI.R @@ -301,6 +301,34 @@ new_dataset_handler <- function(h, ...) { update_ds_editor()
}
+new_ds_from_csv_handler <- function(h, ...) {
+ tmpfile <- normalizePath(svalue(h$obj), winslash = "/")
+ tmpd <- try(read.table(tmpfile, sep = "\t", header = TRUE))
+ tmpdw <- mkin_wide_to_long(tmpd)
+ if (class(tmpd) != "try-error") {
+ ds.cur <<- as.character(1 + length(ds))
+ ds[[ds.cur]] <<- list(
+ study_nr = NA,
+ title = "New upload",
+ sampling_times = sort(unique(tmpd$t)),
+ time_unit = "NA",
+ observed = unique(tmpdw$name),
+ unit = "NA",
+ replicates = max(aggregate(tmpdw$time,
+ list(tmpdw$time,
+ tmpdw$name),
+ length)$x),
+ data = tmpdw)
+ ds[[ds.cur]]$data$override <<- "NA"
+ ds[[ds.cur]]$data$err <<- 1
+ update_ds.df()
+ ds.gtable[,] <- ds.df
+ update_ds_editor()
+ } else {
+ galert("Uploading failed", parent = "w")
+ }
+}
+
empty_grid_handler <- function(h, ...) {
obs <- strsplit(svalue(ds.e.obs), ", ")[[1]]
sampling_times <- strsplit(svalue(ds.e.st), ", ")[[1]]
@@ -345,6 +373,9 @@ gbutton("Copy dataset", cont = ds.e.2, handler = copy_dataset_handler) gbutton("Delete dataset", cont = ds.e.2, handler = delete_dataset_handler)
gbutton("New dataset", cont = ds.e.2, handler = new_dataset_handler)
+gfile(text = "Select csv file", cont = ds.e.2,
+ handler = new_ds_from_csv_handler)
+
# Line 3 with forms {{{4
ds.e.forms <- ggroup(cont= ds.editor, horizontal = TRUE)
|