-
Notifications
You must be signed in to change notification settings - Fork 124
/
server.R
107 lines (94 loc) · 3.45 KB
/
server.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
require(shiny)
#library(pisa)
require(devtools)
#install_github('likert','kspeer')
require(likert)
data(pisaitems)
source('C:/Users/User/Dropbox/Github/likert/R/xtable.likert.R')#rm this when github syncs
items24 <- pisaitems[,substr(names(pisaitems), 1,5) == 'ST24Q']
names(items24) <- c(
"I read only if I have to.",
"Reading is one of my favorite hobbies.",
"I like talking about books with other people.",
"I find it hard to finish books.",
"I feel happy if I receive a book as a present.",
"For me, reading is a waste of time.",
"I enjoy going to a bookstore or a library.",
"I read only to get information that I need.",
"I cannot sit still and read for more than a few minutes.",
"I like to express my opinions about books I have read.",
"I like to exchange books with my friends.")
l24 = likert(items24)
l24g <- likert(items24, grouping=pisaitems$CNT)
items29 <- pisaitems[,substr(names(pisaitems), 1,5) == 'ST25Q']
names(items29) = c("Magazines", "Comic books", "Fiction", "Non-fiction books", "Newspapers")
l29 <- likert(items29)
l29g <- likert(items29, grouping=pisaitems$CNT)
# Define server logic
shinyServer(function(input, output) {
# Return the requested dataset #TODO have this switch between pisa items
datasetInput <- reactive({
switch(input$dataset,
"l24" = l24,
"l29" = l29)
})
# Generate a summary of the dataset
output$summary <- renderPrint({
dataset <- datasetInput()
summary(dataset,
center=input$center,
ordered=input$ordered)
})
output$print<-renderTable({
dataset<-datasetInput()
print(dataset)
})
# output$table<-renderTable({
# dataset<-datasetInput()
# xtab<-xtable(dataset)
# print(xtab, include.rownames=FALSE)
# })
# output$table<-renderTable({
# datasetInput()
# },
# caption=input$caption,
# include.rownames=FALSE,
# include.n=input$include.n,
# include.mean=input$include.mean,
# include.sd=input$include.sd,
# include.low=input$include.low,
# include.neutral=input$include.neutral,
# include.high=input$include.high,
# include.missing=input$include.missing
# #include.levels=input$include.levels
# )
output$table<-renderTable({
dataset <- datasetInput()
xtab<-xtable(dataset,
caption=input$caption,
include.n=input$include.n,
include.mean=input$include.mean,
include.sd=input$include.sd,
include.low=input$include.low,
include.neutral=input$include.neutral,
include.high=input$include.high,
include.missing=input$include.missing,
center=input$center,
ordered=input$ordered
#include.levels=input$include.levels
)
xtab
})
#add ,caption.placement='top',include.rownames=FALSE
output$plot <- renderPlot({
dataset <- datasetInput()
p<-plot(dataset,
include.center=input$include.center,
centered=input$centered,
ordered=input$ordered,
center=input$center,
wrap=input$wrap
)
print(p)
})
})