注意:这是这个问题的后续。
首先是重现数据的代码:
mydf <- data.frame(year = c(rep(2000, 3), rep(2002, 3), rep(2004, 3), rep(2006, 3), rep(2008, 3), rep(2010, 3), rep(2012, 3), rep(2014, 3), rep(2016, 3)),
answer = rep(c("A great deal", "Hardly any", "Only some"), 9),
result = c(0.3015940, 0.1399303, 0.5584757, 0.2269548, 0.1792754, 0.5937698, 0.2955301, 0.1309859, 0.5734840, 0.3008197, 0.1344499,
0.5647303, 0.1919454, 0.2026290, 0.6054256, 0.1059793, 0.4190533, 0.4749674, 0.1190636, 0.3631279, 0.5178085, 0.1518314,
0.3181203, 0.5300483, 0.1424715, 0.3094615, 0.5480669))
mydf$year <- factor(mydf$year)
mydf$answer <- factor(mydf$answer)
triangles <- data.frame(year = c(2002, 2004, rep(2008, 2), rep(2010, 3), …Run Code Online (Sandbox Code Playgroud) 我想在一个图上绘制图表并绘制填充区域形状和条形图。然而,区域形状覆盖条。我无法更改元素的顺序。可以把酒吧带在前面吗?
data <- data.frame(years = c(2005,2006,2007), values1 = c(1,2,3), values2 = c(3,3,2))
plot_ly(data, x = data$years, y=data$values1, type = 'bar') %>%
add_trace(x=data$years, y=data$values2, type = 'scatter', mode = 'lines', fill = 'tozeroy')Run Code Online (Sandbox Code Playgroud)
SSH密钥是一个密钥文件;服务器没有基于字符串的密码。SSH主机和MySQL数据库位于同一服务器上。我需要通过 SSH 连接到服务器(代码如下),然后访问数据库。我尝试了许多不同的代码片段,下面是我所得到的最远的。
我的“最佳”代码:
library(ssh)
session <- ssh_connect("user@host", keyfile = "<local path>", verbose = 2)
print(session)
Run Code Online (Sandbox Code Playgroud)
这给出了错误:
ssh_pki_import_privkey_base64: Trying to decode privkey passphrase=false
ssh_connect: libssh 0.8.6 (c) 2003-2018 Aris Adamantiadis, Andreas Schneider and libssh contributors. Distributed under the LGPL, please refer to COPYING file for information about your rights, using threading threads_pthread
ssh_socket_connect: Nonblocking connection socket: 13
ssh_connect: Socket connecting, now waiting for the callbacks to work
socket_callback_connected: Socket connection callback: 1 (0)
ssh_client_connection_callback: SSH server banner: SSH-2.0-OpenSSH_7.4
ssh_analyze_banner: Analyzing …Run Code Online (Sandbox Code Playgroud) Dean Attali 提供了一个精彩的示例,介绍如何使用关闭按钮优雅地退出 Shiny 应用程序,该按钮既关闭浏览器窗口又结束 Shiny 会话。考虑以下示例(Dean 原始代码的修改):
这ui.r:
library(shiny)
library(shinyjs)
jscode <- "shinyjs.closeWindow = function() { window.close(); }"
ui <- fluidPage(
useShinyjs(),
extendShinyjs(text = jscode, functions = c("closeWindow")),
htmlOutput(outputId = "exitHeading"),
actionButton(inputId = "closeGUI", label = "Exit")
)
Run Code Online (Sandbox Code Playgroud)
这server.r:
library(shiny)
library(shinyjs)
server <- function(input, output, session) {
output$exitHeading <- renderText("Press the button below to exit the app")
observeEvent(input$closeGUI, {
js$closeWindow()
stopApp()
})
}
Run Code Online (Sandbox Code Playgroud)
并运行应用程序:
runApp(appDir = "/tmp")
Run Code Online (Sandbox Code Playgroud)
我的问题是关于如何以编程方式启动 Shiny 应用程序作为后台作业,以便在应用程序仍在运行时,RStudio 控制台可以免费进一步使用(甚至并行启动第二个 …
有没有更简单的方法在 R 中格式化货币。以下代码生成一个小表 -
library(dplyr)
set.seed(1)
data = sample(5000:1500000,10, replace = F)
data = tibble(data)
data %>% mutate(currency = scales::dollar(data))
data currency
<int> <chr>
1 457736 $457,736
2 129412 $129,412
3 1490098 $1,490,098
4 861017 $861,017
5 30172 $30,172
6 1348337 $1,348,337
7 1446261 $1,446,261
8 645774 $645,774
9 543190 $543,190
10 1323948 $1,323,948
Run Code Online (Sandbox Code Playgroud)
我想生成一个新列来格式化数据,以便 -
$457,736 will be $457K
$1,490,098 will be $1.5M
$30,172 will be $30K
Run Code Online (Sandbox Code Playgroud) 我目前正在使用 Rstudio 和 R markdown 创建 pdf。然而,每次我尝试编织这些错误消息时都会出现:
! Sorry, but C:\Users\AP\AppData\Local\Programs\MiKTeX\miktex\bin\x64\pdflatex.exe did not succeed.
! The log file hopefully contains the information to get MiKTeX going again:
! C:\Users\AP\AppData\Local\MiKTeX\miktex\log\pdflatex.log
Error: LaTeX failed to compile new-report.tex. See https://yihui.org/tinytex/r/#debugging for debugging tips. See c2089682-report.log for more info.
In addition: Warning message:
In has_crop_tools() :
Tool(s) not installed or not in PATH: ghostcript
-> As a result, figure cropping will be disabled.
Execution halted
Run Code Online (Sandbox Code Playgroud)
我尝试卸载/重新安装 MiKTex 并重新启动 Rstudio,但问题仍然存在。我该如何解决这个问题?
警告信息
In has_crop_tools() :
Tool(s) not installed or not in PATH: ghostcript
-> As a result, figure cropping will be disabled.
Run Code Online (Sandbox Code Playgroud)
当一个简单的 R Markdown 文档被编织为 PDF 时出现:
---
output: pdf_document
---

Run Code Online (Sandbox Code Playgroud)
该bar.png图像嵌入到PDF的所有权利,但它看起来像有一个名为拼写错误ghostcript命令(它不应该是鬼小号的名称后CRIPT Ghostscript的翻译吗?)。如何正确解决此警告消息?
我的xfun::session_info()输出:
R version 4.0.4 (2021-02-15)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19042), RStudio 1.4.1103
Locale:
LC_COLLATE=English_United States.1252 LC_CTYPE=English_United States.1252 LC_MONETARY=English_United States.1252
LC_NUMERIC=C LC_TIME=English_United States.1252
Package version:
base64enc_0.1.3 compiler_4.0.4 digest_0.6.27 evaluate_0.14 glue_1.4.2 graphics_4.0.4 grDevices_4.0.4
highr_0.8 …Run Code Online (Sandbox Code Playgroud) 我有一个相当大的 .RData 文件。它在我的硬盘上占用 1.10 GB,包含一个包含 100 个变量和 1200 万个观测值的数据框。现在,当我尝试加载它时,我可以打开任务管理器并观察内存使用量一直达到 7450 MB;此时我的 RAM 已完全耗尽,并且我收到“从连接读取错误”。我很确定内存不足就是问题所在,但怎么可能呢?正如我所说,.RData 只有 1.10 GB。
我正在使用 R x64 4.0.5。如果有任何线索的话,当我打开 32 位版本的 R (4.0.5) 时,它告诉我“错误:内存耗尽(已达到限制?)”,这加深了我对这是内存问题的怀疑。
我无法以任何其他方式访问数据,我必须使 .RData 文件正常工作,否则它就会消失。为什么 R 需要超过 8 GB 的 RAM 才能加载 1 GB 的工作区?
当我运行 R 命令时,出现以下错误:
qt.qpa.xcb: could not connect to display
qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "" even though it was found.
This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.
Available platform plugins are: eglfs, linuxfb, minimal, minimalegl, offscreen, vnc, wayland-egl, wayland, wayland-xcomposite-egl, wayland-xcomposite-glx, xcb.
Aborted (core dumped)
Run Code Online (Sandbox Code Playgroud)
我已经查看了所有其他回复,并“解决”了此问题的问题,但它们没有为我解决问题,而且我不知道如何为我的特定设备自行解决此问题。
有人可以指导我如何在不使用复杂语言的情况下解决这个问题吗?我不知道任何访问事物的命令,因此尝试使用在线答案非常困难。
这是我在 Pixelbook 上运行的系统信息
这是我运行 rstudio 时的完整输出:
QFactoryLoader::QFactoryLoader() checking directory path "/usr/lib/rstudio/plugins/platforms" ...
QFactoryLoader::QFactoryLoader() looking at …Run Code Online (Sandbox Code Playgroud) 我已经搜索了 stackoverflow 和整个网络,但我找不到这个看似简单的问题的好答案。
情况如下:
出现的问题如下:
需要解决方案
AirdatePickerInputShinywidgets 的具有此特定功能(update_on=c('change', 'close')。我需要的是我的 pickerInput仅在“关闭”时更新。这样结果值仅发送回服务器一次。示例:用户界面
ui <- fluidPage(
# Title panel
fluidRow(
column(2,
wellPanel(
h3("Filters"),
uiOutput("picker_a"),
uiOutput("picker_b"),
)
),
)
)
Run Code Online (Sandbox Code Playgroud)
服务器
server <- function(input, output, session) {
# Start values for each filter
all_values_for_a <- tbl(conn, "table") %>%
distinct(a) %>%
collect()
all_values_for_b <- tbl(conn, "table") %>%
distinct(b) %>%
collect()
output$picker_a <- renderUI({
pickerInput(
inputId = "picker_a",
label = "a:",
choices …Run Code Online (Sandbox Code Playgroud)