我在knitr中遇到了子文件的问题.缓存工作正常,但依赖项不起作用.我的沙箱示例如下所示:
\documentclass{article}
\begin{document}
<<setup, cache=FALSE>>=
opts_chunk$set(cache=TRUE, autodep=TRUE)
dep_auto() # figure out dependencies automatically
@
<<a>>=
x <- 14
@
<<b>>=
print(x)
@
<<child, child='child.Rnw', eval=TRUE>>=
@
\end{document}
Run Code Online (Sandbox Code Playgroud)
随着'child.Rnw'看起来像这样:
<<child>>=
print(x)
@
Run Code Online (Sandbox Code Playgroud)
当我现在编译代码,然后在块a中更改x然后再次编译它:chunk b正确反应,但是孩子没有.我做错了什么吗?
谢谢您的帮助!
我的问题如下一个位置,了解如何改变顶点的框架宽度的igraph.
随着igraph的更新,建议的解决方案似乎不再起作用.有没有人有解决方案(或者可能知道另一个为网络提供可变顶点框架宽度的软件包?)
谢谢!
我希望你能再次帮助我,因为我偶然发现了Shiny中的另一个问题:
我想要一个图形在点击它的那一刻改变.这是一个最小的例子:
ui.R(显示可点击的图形和文本框架)
shinyUI(fluidPage(
titlePanel("Title"),
sidebarLayout(
sidebarPanel(
),
mainPanel(
plotOutput("graph", width = "100%", click = "plot_click"),
verbatimTextOutput("click_info")
)
)
)
)
Run Code Online (Sandbox Code Playgroud)
server.R(图形只包含"A","B","C","D",点击我得到文本框中最近的字母)
shinyServer(function(input, output, session) {
# Visualization output:
observe({
output$graph <- renderPlot({
data <- data.frame(x=c(1,2,1,2), y=c(1,1,2,2),
values=c("A","B","C","D"), stringsAsFactors=FALSE)
plot(data$x, data$y, pch=data$values)
})
})
# interaction click in graph
observe({
click <- c(input$plot_click$x, input$plot_click$y)
data <- data.frame(x=c(1,2,1,2), y=c(1,1,2,2),
values=c("A","B","C","D"), stringsAsFactors=FALSE)
nearest_point <- which.min(apply(data[,1:2], 1, function(a) sum(((click-a)^2))))
id <- data$values[nearest_point]
output$click_info <- renderPrint({
id
})
})
})
Run Code Online (Sandbox Code Playgroud)
现在我想要的是标记我在图表中点击的字母,例如另一种颜色.但到目前为止我所有的尝试都失败了
我找不到可以获得所有条目列表的列表?这是一个简单的例子,列表o列出:
listoflists <- list("A"=list(c(1,2,3),c(2,34,2)), "B" = list(c(1,2),c(2,3,2,1)), "C" = list(c("sdf",3,2)))
$A
$A[[1]]
[1] 1 2 3
$A[[2]]
[1] 2 34 2
$B
$B[[1]]
[1] 1 2
$B[[2]]
[1] 2 3 2 1
$C
$C[[1]]
[1] "sdf" "3" "2"
Run Code Online (Sandbox Code Playgroud)
我只是通过使用for循环找到了这种悲伤的方式:
listofvectors <- list()
for (i in 1:length(listoflists)) {listofvectors <- c(listofvectors, listoflists[[i]])}
Run Code Online (Sandbox Code Playgroud) 是否有可能在闪亮的情况下具有反应区大小?
这是一个小例子,我希望它如何工作。但是,由于反应表达式不在输出内部,因此会产生错误。
ui.R,您可以在其中选择宽度和两个绘图输出:
shinyUI(pageWithSidebar(
headerPanel("Title"),
sidebarPanel(
selectInput("width", "Choose width:",
choices = c("200", "400"))
),
mainPanel(
plotOutput(outputId = "main_plot", width = "100%"),
plotOutput(outputId = "main_plot2", width = "100%")
)
))
Run Code Online (Sandbox Code Playgroud)
server.R,其中第二个图应具有输入宽度:
shinyServer(function(input, output) {
x <- 1:10
y <- x^2
width <- reactive({
switch(input$direction,
'200' = 200,
'400' = 400)
})
output$main_plot <- renderPlot({
plot(x, y)}, height = 200, width = 400)
output$main_plot2 <- renderPlot({
plot(x, y) }, height = 200, width = width() )
})
Run Code Online (Sandbox Code Playgroud) 我在Oracle SQL中有一个问题.
为了简化我的问题,假设我有两个表:
TAB1: TAB2:
Usr Fruit Fruit Calories
1 A A 100
1 A B 200
1 A C 150
1 C D 400
1 C E 50
2 A
2 A
2 E
Run Code Online (Sandbox Code Playgroud)
在TAB1中有双重条目非常重要.现在我想知道usr的卡路里1.但是加入两个表
SELECT TAB2.calories from TAB1
JOIN TAB2 ON TAB1.Fruit = TAB2.Fruit
WHERE TAB1.Usr = 1;
Run Code Online (Sandbox Code Playgroud)
我得到双重条目的双重结果.我当然可以在标题中使用distinct,但是有可能直接在连接中区分值(到A和C)吗?我相信这会改善我(更大)的表现.
谢谢!