1
이것은 내가에 이전에 요구했다 질문에 관련 : 지금 여러 반짝 플롯을 생성하고이를 다운로드 한Shiny (R) pt에서 png 다운로드 중입니다. 2
Downloading png from Shiny (R)
하지만 maptools 패키지를 사용하여 플롯, 난 그냥 빈 PNG를 얻을 수 .
Shiny의 버그입니까? 아니면 여기에 제 코드에 문제가 있습니까? 여기
내 서버 파일에서 관련 발췌 :plotInput2 <- function(){
my.data<-DataInput()
sub <- subset(DataInput(), as.character(DataInput()[,2])==input$var1)
a = which(names(sub)==input$var2)
x_lab <- as.numeric(sub[,a])
Country <- as.character(sub[,1])
mapdata <- data.frame(Country=Country,Perc=x_lab)
percent_map <- function(data) {
# world <- map_data("world")
data(wrld_simpl)
world <- fortify(wrld_simpl,region='NAME')
names(world) <- list("long","lat","order","hole","piece","group", "Country")
world$Country <- tolower(world$Country)
data$Country <- tolower(data$Country)
world$Country <- tolower(world$Country)
choro <- merge(world, data, by=c("Country"),all=TRUE)
choro <- choro[order(choro$order), ]
choro$Perc <-as.numeric(as.character(choro$Perc))
## PLOT MAP IN GREY ##
ggplot() + geom_polygon(aes(long,lat,group=group),data=world, fill=NA) +
## PLOT DATA ##
geom_polygon(aes(long, lat, group = group, fill=Perc),data = choro)
}
percent_map(mapdata)
}
output$mapjoon <- renderPlot({
print(plotInput2())
})
output$downloadPlot2 <- downloadHandler(
filename = "Shinyplot2.png",
content = function(file) {
png(file)
plotInput2()
dev.off()
})
@Mikael Jumppanen, 고맙습니다. 나는 여전히 왜 그런지 잘 모르겠다. 위의 코드는 다른 플롯에서 잘 작동했다. 막대 그래프, 막대 그래프 또는 산점도. 그 이유에 대해 통찰력이 있다면, 나는 알고 싶어 할 것입니다. – sba
원래 답변에 설명을 추가했습니다. –