简体   繁体   中英

Setting up input to an R application using Shiny

I have a table like this:

Students(id, grade_course_a, grade_course_b, grade_course_c)

I would like to create a frequency test in R to see the correlation between any two courses. I know how to get the frequencies using table function in R. Now I would like the user to be able to select the courses via drop-down menus. From what I have seen, I need a UI file and a server file, but I have trouble understanding how to do it. Can you point me in the right direction?

For a simple visual inspection an interactive plot might be sufficient? The traces can be hidden by clicking on the legend.

library(reshape2)
library(plotly)

Students <- data.frame(stud_id=seq(30), grade_course_a=round(runif(30, 1, 6)), grade_course_b=round(runif(30, 1, 6)), grade_course_c=round(runif(30, 1, 6)))

moltenStudents <- melt(Students, "stud_id", 2:ncol(Students))
moltenStudents$grade <- LETTERS[moltenStudents$value]

plot_ly(moltenStudents,
        x = ~stud_id,
        y = ~value,
        color = ~variable,
        text = ~grade,
        type = 'scatter',
        mode = 'lines'
)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM