很抱歉没有包含我的问题的任何示例数据.我找不到轻松生成示例形状文件的方法.希望有经验的用户ggplot可以从下面的描述中看到我想做的事情.
我有:
一个data.frameX与约样地信息(plotid,var1,var2,var3,var4,...)
Y具有样本图的空间信息的多边形shapefile
导入shapefile Y(with maptools)和fortifying as data.frame Z(ggplot2)可以正常工作.melt荷兰国际集团X以X_melted作品同样精致.merge-ing Z并X_melted以mapdf作品为好.
这意味着,现在我们有一个data.frame长形式的空间信息和var1,var2,var3,...
现在我想绘制这样的数据框:
pl1 <- ggplot(mapdf,aes(long,lat),group=group)
pl1 <- pl1 + geom_polygon(aes(group=group,fill=value),colour="black")
pl1 <- pl1 + facet_grid(variable ~ .)
pl1 <- pl1 + coord_equal(ratio = 1)
pl1
Run Code Online (Sandbox Code Playgroud)
结果是一个很好的情节,每个变量有一个面板.面板的地图是相同的,但填充颜色随变量的值而变化.到目前为止,一切都像魅力......有一个问题: …
我试图用来geom_point说明我的数据计数.我还想在图表中注明一些要点geom_text.当我添加调用时geom_text,它似乎正在绘制图例中点下方的内容.我试过扭转层的顺序无济于事.我无法理解为什么会这样做.谁看过这个吗?
set.seed(42)
df <- data.frame(x = 1:10
, y = 1:10
, label = sample(LETTERS,10, replace = TRUE)
, count = sample(1:300, 10, replace = FALSE)
)
p <- ggplot(data = df, aes(x = x, y = y, size = count)) + geom_point()
p + geom_text(aes(label = label, size = 150, vjust = 2))
Run Code Online (Sandbox Code Playgroud)

我正在寻找一些基于JavaScript的组件作为课程安排程序,它将是Google日历和登录时间之间的交叉.我不知道这个是正确的术语是课程安排程序,但我将在这里更详细地描述.
课程安排程序
小工具将用于输入课程的日期和时间,例如,如果我每周7天,星期一,星期三和星期三每天运行编程课程,每天上午7:00至上午9:00,每天2小时9月1日至11月30日.我可以回答各种问题,课程数据将显示在日历中.它还允许基于非模式的计时,其中每周与其他周不同等.
问题
那么我最终会从零开始创建一些东西吗?为此使用Google Calendar API是否明智?我在谷歌搜索了一些小部件,但我相信我需要更好的关键字,因为我找不到任何接近我想要的东西.有小费吗?商业图书馆也适合我.谢谢.
我开始使用R Markdown,我不知道如何生成更大的图.通过今天的屏幕,情节可以更大.
如何在Markdown报告中控制图的宽度/高度?
谢谢您的帮助.
使用代码块时,Knitr会生成一个很好的语法高亮代码,如下所示.
```sql
SELECT column
FROM table
```
Run Code Online (Sandbox Code Playgroud)
有可能实现相同的东西,但sql代码存储在文件中?就像是:
```sql
read_chunk('mycode.sql')
```
Run Code Online (Sandbox Code Playgroud) 我有以下种类的字符串:
A B C Company
XYZ Inc
S & K Co
Run Code Online (Sandbox Code Playgroud)
我想删除这些字符串中仅在1个字母长度的单词之间的空格.例如,第一个字符串中我想删除之间的空隙A B和C,但不会之间C和公司.结果应该是:
ABC Company
XYZ Inc
S&K Co
Run Code Online (Sandbox Code Playgroud)
为此使用正确的正则表达式是什么gsub?
我正在尝试生成一些分形,并在R中使用ggplot对边距有疑问.我使用以下代码生成分形.
library(ggplot2)
library(grid)
max_iter=25
cl=colours()
step=seq(-2,0.8,by=0.005)
points=array(0,dim=c(length(step)^2,3))
t=0
for(a in step) {
for(b in step+0.6) {
x=0;y=0;n=0;dist=0
while(n<max_iter & dist<4) {
n=n+1
newx=a+x^2-y^2
newy=b+2*x*y
dist=newx^2+newy^2
x=newx;y=newy
}
if(dist<4) {
color=24 # black
} else {
color=n*floor(length(cl)/max_iter)
}
t=t+1
points[t,]=c(a,b,color)
}
}
df=as.data.frame(points)
ggplot(data=df, aes(V1, V2, color=cl[V3]))+
geom_point() +
theme(panel.background=element_blank(),
panel.grid.major=element_blank(),
panel.grid.minor=element_blank(),
panel.margin = unit(c(0, 0, 0, 0), "cm"),
axis.ticks=element_blank(),
axis.text.x=element_blank(),
axis.text.y=element_blank(),
axis.title.x=element_blank(),
axis.title.y=element_blank(),
plot.background = element_rect(fill = "transparent",colour = NA),
plot.margin = unit(c(0, 0, 0, 0), "cm"),
legend.position = 'none') …Run Code Online (Sandbox Code Playgroud) 我使用XML包来获取此URL的链接.
# Parse HTML URL
v1WebParse <- htmlParse(v1URL)
# Read links and and get the quotes of the companies from the href
t1Links <- data.frame(xpathSApply(v1WebParse, '//a', xmlGetAttr, 'href'))
Run Code Online (Sandbox Code Playgroud)
虽然这种方法非常有效,但我使用rvest并且在解析网络时看起来更快XML.我试过html_nodes和html_attrs,但我不能得到它的工作.
我有一个闪亮的应用程序,其中绘图需要根据用户输入调整高度.基本上,该图可以有一个,两个或四个子图.当有一个或两个时,一切都很好,但有四个,子图被压扁到太小的尺寸.我试过用一个反应函数给我一个服务器的计算高度,但是我得到了这个错误:
Error in .getReactiveEnvironment()$currentContext() :
Operation not allowed without an active reactive context. (You tried to do something that can only be done from inside a reactive expression or observer.)
Run Code Online (Sandbox Code Playgroud)
我试图做的一个非常简化的版本是:
library(shiny)
ui <- fluidPage(
fluidRow(
column(2,
radioButtons( inputId = 'plotcount', label = 'Plot Count',
choices = c('1' = 1,
'2' = 2,
'4' = 4
),
selected = '1'
)
),
column(10,
plotOutput( outputId = 'plots' )
)
)
)
server <- function(input, output) {
PlotHeight = reactive(
return( …Run Code Online (Sandbox Code Playgroud) 我有一个全局~/.Rprofile文件和另一个.Rprofile位于我项目当前工作目录中的文件,它们都具有以下内容:
.First() <- function() {
options(rstudio.markdownToHTML =
function(inputFile, outputFile) {
system(paste("pandoc", shQuote(inputFile), "-s --webtex -o", shQuote(outputFile)))
}
)
}
Run Code Online (Sandbox Code Playgroud)
不幸的是,当我打开RStudio应用程序时,它们似乎都没有工作.我正在尝试做的目的是使"Knit HTML"按钮渲染Markdown文件,该文件具有内联LaTeX,使用webtex作为LaTeX渲染器通过Pandoc进行处理.
有谁知道我如何检查我的.Rprofile文件是否在启动时加载?
谢谢你的帮助!
POST ANSWER EDIT(在Josh的回答之后):
为了清楚起见,我的工作项目的.Rprofile文件(有效)现在如下所示:
options(rstudio.markdownHTML =
function(inputFile, outputFile) {
system(paste("pandoc", shQuote(inputFie), "-s --webtex -o", shQuote(outputFile)))
}
)
\\ you will need to end with a blank carriage return underneath
Run Code Online (Sandbox Code Playgroud)