나는 R 반짝이와 ggplot2를 통해 데이터 세트의 간단한 그래프를 만들려고합니다. 플롯이 문제가없는 동안 부드럽게하기 위해 체크 상자를 클릭하면 그래프에 아무런 변화가 없습니다. 여기에 stat_smooth()를 사용하고 있습니다. 이 문제와 관련없는 다른 문제는 사용자가 대용량 파일을 업로드 할 수 있도록 'options (shiny.maxRequestSize = -1)'옵션을 추가 했더라도 프로그램이 5보다 큰 값을 업로드하려고하면 오류가 발생한다는 것입니다 MB (그냥 충돌). 이것에 대한 아이디어가 있습니까? , 지금은 줄거리를 오프라인으로 확인하는 것은 당신이 생각하고있는 제일 먼저 알고ggplot2 내 부드러운 기능이 작동하지 않는 이유는 무엇입니까?
ui.R
dataset <- list('Upload a file'=c(1))
shinyUI(pageWithSidebar(
sidebarPanel(
fileInput('file', 'Data file'),
radioButtons('format', 'Format', c('CSV', 'TSV')),
checkboxInput('smooth', 'Smooth')
)
mainPanel(
plotOutput("plot")
)
)
server.R 나는 해결책을 발견
library(ggplot2)
#Increase max upload size
options(shiny.maxRequestSize=-1)
shinyServer(function(input, output, session) {
data <- reactive({
if (is.null(input$file))
return(NULL)
else if (identical(input$format, 'CSV'))
return(read.csv(input$file$datapath))
else
return(read.delim(input$file$datapath))
})
observe({
df <- data()
str(names(df))
if (!is.null(df)) {
updateSelectInput(session, 'x', choices = names(df))
updateSelectInput(session, 'y', choices = names(df))
}
})
output$plot <- renderPlot({ #Basic Plot
if (is.null(data()))
return(NULL)
p <- ggplot(data(), aes_string(x=input$x, y=input$y)) +
geom_point(size = 3)
if (input$smooth)
p <- p + stat_smooth()
print(p)
})
}
플롯이'stat_smooth()'로 오프라인으로 작동하는지 확인 했습니까? – Marius
터미널에서 말합니까? (저는 R 스튜디오를 사용하고 있습니다). 터미널을 통해 테스트하는 방법을 모르겠습니다. – jeffrey
아니요, 저는 Shiny를 통해 실행하는 것에 대해 걱정하지 않고 오프라인에서 예제 데이터를 사용하여 원하는 종류의 플롯을 얻을 수 있다는 것을 확신했습니다. 쉬운 수정을 배제하려고합니다. – Marius