Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Image Data Explorer
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
7
Issues
7
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kimberly Isobel Meechan
Image Data Explorer
Commits
5527d4f5
Commit
5527d4f5
authored
Jan 10, 2019
by
Kimberly Isobel Meechan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Saving & loading settings
parent
53ee89ce
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
182 additions
and
0 deletions
+182
-0
functions/io/data_io.R
functions/io/data_io.R
+41
-0
functions/io/settings.R
functions/io/settings.R
+8
-0
server.R
server.R
+69
-0
ui.R
ui.R
+64
-0
No files found.
functions/io/data_io.R
0 → 100644
View file @
5527d4f5
read_data
<-
function
(
path
,
header
,
sep
,
quote
)
{
tryCatch
(
{
df
<-
read.csv
(
path
,
header
,
sep
,
quote
)
},
error
=
function
(
e
)
{
## return a safeError if a parsing error occurs
stop
(
safeError
(
e
))
}
)
return
(
df
)
}
save_settings
<-
function
(
settings
,
path
)
{
json_settings
=
toJSON
(
settings
)
print
(
path
)
# if (!grepl('.*\\.json$', json_settings) ) {
# path = paste0(path,'.json')
# }
write
(
json_settings
,
path
,
append
=
FALSE
)
print
(
'downloaded'
)
}
read_settings
<-
function
(
path
){
json_data
<-
fromJSON
(
file
=
path
)
return
(
json_data
)
}
test_settings_io
<-
function
()
{
path
=
'C:/Users/meechan/Documents/settings.json'
save_settings
(
c
(
'a'
,
'b'
),
path
)
read_settings
(
path
)
}
functions/io/settings.R
0 → 100644
View file @
5527d4f5
getSettings
<-
function
(
s
)
{
if
(
exists
(
"s"
)
&&
!
is.null
(
s
)
)
{
return
(
s
)
}
else
{
return
(
NULL
)
}
}
\ No newline at end of file
server.R
View file @
5527d4f5
library
(
RJSONIO
)
library
(
rjson
)
source
(
'./functions/io/data_io.R'
)
source
(
'./functions/io/settings.R'
)
server
<-
function
(
input
,
output
)
{
data
<-
reactive
({
if
(
is.null
(
input
$
datafile
))
return
(
NULL
)
## After the user selects and uploads a data file,
## the content of the data file will be shown.
req
(
input
$
datafile
)
read_data
(
input
$
datafile
$
datapath
,
header
=
input
$
header
,
sep
=
input
$
sep
,
quote
=
input
$
quote
)
})
settings
<-
reactive
({
if
(
is.null
(
input
$
settings_file
))
return
(
NULL
)
## After the user selects and uploads a data file,
## the content of the data file will be shown.
req
(
input
$
settings_file
)
read_settings
(
input
$
settings_file
$
datapath
)
})
output
$
content
<-
renderDT
(
data
(),
server
=
TRUE
)
output
$
Paths
<-
renderUI
({
checkboxGroupInput
(
inputId
=
"ImagePaths"
,
label
=
"Select Image columns"
,
choices
=
names
(
data
()),
selected
=
getSettings
(
settings
())
)
})
output
$
downloadData
<-
downloadHandler
(
filename
=
function
()
{
return
(
'Settings'
)
},
# This function should write data to a file given to it by
# the argument 'file'.
content
=
function
(
file
)
{
print
(
file
)
save_settings
(
input
$
ImagePaths
,
file
)
}
)
output
$
selected_paths
=
renderPrint
({
s
=
input
$
ImagePaths
if
(
length
(
s
))
{
cat
(
'These variables were selected:\n\n'
)
cat
(
s
,
sep
=
', '
)
print
(
str
(
input
$
ImagePaths
))
}
})
}
ui.R
View file @
5527d4f5
library
(
'shiny'
)
ui
<-
navbarPage
(
""
,
tabPanel
(
"Load"
,
fluidRow
(
## Input: Select a file
fileInput
(
"datafile"
,
"Select data file (in CSV format)"
,
multiple
=
FALSE
,
accept
=
c
(
"text/csv"
,
"text/comma-separated-values,text/plain"
,
".csv"
)),
## Horizontal line
tags
$
hr
(),
## Input: Checkbox if file has header
checkboxInput
(
"header"
,
"File has header"
,
TRUE
),
## Input: Select separator
radioButtons
(
"sep"
,
"Separator"
,
choices
=
c
(
Comma
=
","
,
Semicolon
=
";"
,
Tab
=
"\t"
),
selected
=
"\t"
),
## Input: Select quotes
radioButtons
(
"quote"
,
"Quote"
,
choices
=
c
(
None
=
""
,
"Double Quote"
=
'"'
,
"Single Quote"
=
"'"
),
selected
=
'"'
),
tags
$
hr
()
),
fluidRow
(
DTOutput
(
"content"
)
),
fluidRow
(
title
=
'settings'
,
fileInput
(
"image"
,
"Select an image file:"
,
multiple
=
FALSE
,
accept
=
c
(
'.png'
,
'.jpg'
,
'.tif'
,
'.jpeg'
)),
uiOutput
(
"Paths"
),
downloadButton
(
'downloadData'
,
'Download'
),
verbatimTextOutput
(
'selected_paths'
),
fileInput
(
"settings_file"
,
"Select settings json file:"
,
multiple
=
FALSE
,
accept
=
c
(
'.json'
))
)
),
tabPanel
(
"Plot"
)
)
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment