diff options
author | jranke <jranke@edb9625f-4e0d-4859-8d74-9fd3b1da38cb> | 2013-11-06 15:25:16 +0000 |
---|---|---|
committer | jranke <jranke@edb9625f-4e0d-4859-8d74-9fd3b1da38cb> | 2013-11-06 15:25:16 +0000 |
commit | feb851104393f67d14148a471501e59361853914 (patch) | |
tree | 890bd305e9aaf368b301c981d362876bf5d8fc84 /inst | |
parent | a9eb52cdf8547094521e7a42a422321687f00fde (diff) |
Start to enable the import of CSV files.
git-svn-id: svn+ssh://svn.r-forge.r-project.org/svnroot/kinfit/pkg/mkin@143 edb9625f-4e0d-4859-8d74-9fd3b1da38cb
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 921daea..f5c3076 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)
|