我正在使用R中的传单构建地图,以部署为Shiny应用程序.Shiny应用程序在RStudio中运行良好,但是当我在Web浏览器中打开它时,多边形会失去颜色.其他一切都很好,基本地图就在那里,多边形都在那里,你可以将鼠标悬停在多边形上以查看信息等.唯一的变化是多边形从彩色变为灰色.没有警告或错误消息.
我正在使用最新版本的R(3.3.3)和Rstudio(1.0.136)的mac(Sierra),我的所有软件包都是最新的.我尝试了两种结果相同的浏览器(Chrome,Firefox).特别奇怪的是,我尝试在Windows机器上打开应用程序并遇到相反的情况:Rstudio中没有颜色,而是Web浏览器中的全彩色(Firefox).
我猜这个问题是专门没有在addPolygons()中读取fillColor选项,但我不知道为什么这个选项有问题,为什么它有时会工作而不是其他工作.如果有人有任何想法,我很乐意听到它!
PS,我认为我的问题类似于这个(未答复的)问题,但同样,令人费解的是,在我的情况下,它适用于Rstudio但不适用于网络浏览器(或者显然在Windows机器上相反!).
下面是一些代码(为了清晰起见,我正在使用和修剪的不同数据集,但产生与上述完全相同的行为):
library(leaflet)
library(rgdal)
library(shiny)
server <- function(input,output){
output$map <- renderLeaflet({
# Example data (borrowed from a tutorial at https://rpubs.com/walkerke/leaflet_choropleth)
tmp <- tempdir()
url <- "http://personal.tcu.edu/kylewalker/data/mexico.zip"
file <- basename(url)
download.file(url, file)
unzip(file, exdir = tmp)
mexico <- readOGR(dsn = tmp, layer = "mexico", encoding = "UTF-8")
leaflet(mexico) %>%
addTiles() %>%
addPolygons(weight = 1.2, label = ~name,
fillColor = topo.colors(4), fillOpacity = .5,
highlightOptions = highlightOptions(color = "black", weight = 2, bringToFront = TRUE, fillOpacity = …Run Code Online (Sandbox Code Playgroud) 我正在写一篇关于R markdown的论文,需要用学术期刊提供的.cls文件对其进行格式化.
最小的.tex文件与上面的cls文件完美匹配.
我的.tex文件(在ShareLaTeX上编译并clv3.cls保存在同一目录中):
\documentclass[shortpaper]{clv3}
\usepackage[utf8]{inputenc}
\title{Paper title}
\author{Name Surname}
\date{May 2018}
\begin{document}
\maketitle
\section{Introduction}
Some text.
\end{document}
Run Code Online (Sandbox Code Playgroud)
但是,使用相同cls文件的R markdown中的可比较的最小文档无法在Rstudio中编译,并出现以下错误: ! Package geometry Error: \paperwidth (0.0pt) too short.
我的Rmd文件(clv3.cls文件保存在同一目录中):
---
title: "Paper title"
author: "Name Surname"
documentclass: clv3
classoption: shortpaper
output: pdf_document
---
# Introduction
Some text.
Run Code Online (Sandbox Code Playgroud)
当我尝试将此类文件与R markdown文档一起使用时,为什么会出现此错误?如何解决?
我已经尝试在YAML标题中手动指定页面宽度设置,但我真的不知道我在做什么.这似乎是不合需要的,因为普通的LaTeX文档在没有它的情况下工作正常(当然页面宽度应该由日志指定,而不是由作者手动覆盖).