Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
aaltodimensions
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Repository Analytics
Value Stream Analytics
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Tuija Sonkkila
aaltodimensions
Commits
73613f5d
Commit
73613f5d
authored
Feb 06, 2018
by
Tuija Sonkkila
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added plotly heatmap
parent
0ea2e1d6
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
37 additions
and
8 deletions
+37
-8
server.R
server.R
+37
-8
No files found.
server.R
View file @
73613f5d
...
...
@@ -4,7 +4,7 @@ function(input, output, session) {
# When school is selected, filter data with it
schoolData
<-
reactive
({
if
(
input
$
school
==
"A
ll
"
)
return
(
data
)
else
data
[
data
$
parent
%in%
input
$
school
,
]
if
(
input
$
school
==
"A
alto University
"
)
return
(
data
)
else
data
[
data
$
parent
%in%
input
$
school
,
]
})
...
...
@@ -14,7 +14,7 @@ function(input, output, session) {
observe
(
updateSelectInput
(
session
,
inputId
=
'dept'
,
choices
=
if
(
input
$
school
==
"A
ll
"
)
"Select school first"
else
c
(
"All"
,
sort
(
unique
(
schoolData
()
$
name
)))
choices
=
if
(
input
$
school
==
"A
alto University
"
)
"Select school first"
else
c
(
"All"
,
sort
(
unique
(
schoolData
()
$
name
)))
)
)
...
...
@@ -48,19 +48,19 @@ function(input, output, session) {
})
output
$
plotly
<-
renderPlotly
({
output
$
scatter
<-
renderPlotly
({
df
<-
deptData
()
colors
<-
df
$
color
df
$
xx
<-
df
[[
input
$
xc
]]
df
$
yy
<-
df
[[
input
$
yc
]]
title
<-
if
(
is.null
(
input
$
dept
)
||
input
$
dept
==
"Select school first"
||
input
$
dept
==
"All"
)
input
$
school
else
paste0
(
input
$
school
,
", "
,
input
$
dept
)
p
<-
plot_ly
(
df
,
type
=
"scatter"
,
x
=
~
xx
,
y
=
~
yy
,
x
=
~
get
(
input
$
xc
)
,
y
=
~
get
(
input
$
yc
)
,
mode
=
"markers"
,
colors
=
colors
,
color
=
I
(
colors
),
...
...
@@ -69,11 +69,40 @@ function(input, output, session) {
marker
=
list
(
size
=
10
,
opacity
=
0.7
),
hovertext
=
~
text
)
%>%
layout
(
xaxis
=
list
(
title
=
input
$
xc
),
yaxis
=
list
(
title
=
input
$
yc
)
)
yaxis
=
list
(
title
=
input
$
yc
),
title
=
title
)
})
output
$
heatmap
<-
renderPlotly
({
if
(
is.null
(
input
$
dept
)
||
input
$
dept
==
"Select school first"
||
input
$
dept
==
"All"
)
return
()
dept_data
<-
f_means
%>%
filter
(
name
==
input
$
dept
)
rnames
<-
dept_data
[[
"field_name"
]]
mat_data
<-
data.matrix
(
dept_data
[,
c
(
4
:
8
)])
rownames
(
mat_data
)
<-
rnames
plot_ly
(
type
=
"heatmap"
,
x
=
colnames
(
mat_data
),
y
=
rownames
(
mat_data
),
z
=
mat_data
,
key
=
mat_data
,
source
=
mat_data
)
%>%
layout
(
title
=
paste0
(
"Mean metrics by field in "
,
input
$
dept
),
xaxis
=
ax
,
yaxis
=
ay
,
showlegend
=
FALSE
,
autosize
=
F
,
width
=
w
,
height
=
h
,
margin
=
m
)
})
output
$
datatable
<-
DT
::
renderDataTable
({
dat
<-
datatable
(
makedata
(),
...
...
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