我对 R/RStudio 比较陌生。直到今天,我才能成功安装软件包。每次尝试安装软件包时,都会收到以下错误:
警告:构建 R 包需要 Rtools,但当前未安装。在继续之前,请下载并安装适当版本的 Rtools:https ://cran.rstudio.com/bin/windows/Rtools/ 将 软件包安装到 'C:/Users/my. Name/Documents/R/win-library/3.6'(因为 'lib' 未指定)正在尝试 URL ' https://cran.rstudio.com/bin/windows/contrib/3.6/openintro_1.7.1.zip '内容类型' application/zip' 长度 3136068 字节 (3.0 MB) 下载 3.0 MB
Rtools 已经安装在我的机器上,所以我不确定为什么它不被识别。
我尝试卸载并重新安装 rtools,但似乎无法解决问题。这里的任何见解将不胜感激!
几个月前,我在使用 R studio 时遇到了一个问题:有时,当我运行代码(整个块或仅单行)并在数据框中进行更改时,R studio 会自动打开操作/生成的数据框,而不会提示这样做View(dataframe)或类似。我无法检测到任何模式,即它似乎是随机发生的,与所使用的操作或功能无关。通常,每当同一行在同一会话中再次运行时,它就会再次发生,但有时如果重新启动会话,则会停止。
我最近更新了 R 和 R studio,并在 macOS 13.2.1 上使用 R 版本 4.2.3 (2023-03-15) 和 R studio 版本 2023.03.0+386 (2023.03.0+386)。
有没有办法阻止 R studio 在运行脚本时自动打开数据帧?
我正在绘制每个主题对两个块(A 块和 B 块)中“相同”或“不同”刺激的反应比例,这意味着每个主题都绘制了 4 个数据点。两个用于 A 块(相同和不同),两个用于 B 块(相同和不同)。也意味着有 4 行数据包含每个主题的响应比例。
我想将每个主题的“相同”和“不同”数据点与块内的一条线连接起来(例如,“相同”的数据点和“不同”的数据点通过 A 块内和 B 块内的线连接每个主题的块)。
我尝试使用 geom_line() 附带的“group = subject”,但是当我只想连接每个块内的数据点时,它会连接所有主题的数据点。
testplot <- ggplot(df, aes(x=block, y=prop, shape=con, colour=con)) +
geom_point(position=position_dodge(width=.1)) +
xlab("Block") + ylab("Prop of responses") +
theme_bw(base_size = 13) +
theme(legend.position="top")
plot(testplot)
Run Code Online (Sandbox Code Playgroud)
样本数据集:
subj = c(1, 1, 2, 2, 3, 3, 4, 4, 1, 1, 2, 2, 3, 3, 4, 4)
prop = c(0.5, 0.8, 0.3, 0.7, 0.9, 0.4, 0.1, 0.5, 1, 0.5, 0.9, 0.2, 0.7, 0.4, 0.8, …Run Code Online (Sandbox Code Playgroud) 最近,管道操作符的 RStudio 快捷方式%>%停止工作。这似乎是随机发生的,因为我没有更新任何内容。有谁知道发生了什么事以及我该如何解决这个问题?
> sessionInfo()
R version 4.1.0 (2021-05-18)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19042)
Matrix products: default
locale:
[1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United States.1252
[3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C
[5] LC_TIME=English_United States.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] dplyr_1.0.7
loaded via a namespace (and not attached):
[1] rstudioapi_0.13 knitr_1.34 magrittr_2.0.1 tidyselect_1.1.1
[5] R6_2.5.1 rlang_0.4.11 fastmap_1.1.0 fansi_0.5.0
[9] tools_4.1.0 xfun_0.25 utf8_1.2.2 cli_3.0.1
[13] DBI_1.1.1 htmltools_0.5.2 ellipsis_0.3.2 yaml_2.2.1 …Run Code Online (Sandbox Code Playgroud) 我正在使用 RStudio IDE 开发闪亮的应用程序。启动应用程序时,我通常使用 RunApp 按钮:在窗口中运行。这将在具有特定宽度和高度的窗口中打开应用程序。
有没有办法改变这个窗口的宽度,所以每次我启动应用程序时都会在更宽的窗口中显示?
使用BoostC 语言开发一个小的 Rcpp 包和它的一些几何函数。
完成了函数的编写,一切运行良好。Clean and Rebuild最后一次测试一切正常(并测试功能),然后再推送到 GitHub。一旦我仔细检查了该目录是否全部干净地存储在 GitHub 中,我就从本地计算机中删除了该目录。还应该注意的是,我有 Roxygen2 在此运行并管理NAMESPACE文件。
克隆回目录后,Clean and Rebuild出现以下错误:
==> Rcpp::compileAttributes()
* Updated R/RcppExports.R
==> R CMD INSTALL --preclean --no-multiarch --with-keep.source MinimumRcpp
* installing to library ‘/Library/Frameworks/R.framework/Versions/3.5/Resources/library’
* installing *source* package ‘MinimumRcpp’ ...
clang++ -std=gnu++11 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I"/Library/Frameworks/R.framework/Versions/3.5/Resources/library/Rcpp/include" -I/usr/local/include -fPIC -Wall -g -O2 -c RcppExports.cpp -o RcppExports.o
** libs
clang++ -std=gnu++11 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I"/Library/Frameworks/R.framework/Versions/3.5/Resources/library/Rcpp/include" -I/usr/local/include -fPIC -Wall -g -O2 -c findParetoSet.cpp -o findParetoSet.o
clang++ -std=gnu++11 -I"/Library/Frameworks/R.framework/Resources/include" …Run Code Online (Sandbox Code Playgroud) 我使用 RStudio,昨天我将 R 更新为以下版本:
R version 4.0.0 (2020-04-24) -- "Arbor Day"
Copyright (C) 2020 The R Foundation for Statistical Computing
Platform: x86_64-w64-mingw32/x64 (64-bit)
Run Code Online (Sandbox Code Playgroud)
现在,我无法连接到任何 CRAN 镜像(我已经尝试了 4 个不同的镜像)或安装软件包。当我启动 RStudio 时,我在启动时收到以下错误:
Error in tools::startDynamicHelp() : internet routines cannot be loaded
Warning: namespace ‘lme4’ is not available and has been replaced
by .GlobalEnv when processing object ‘lmer1’
Warning: namespace ‘ggplot2’ is not available and has been replaced
by .GlobalEnv when processing object ‘plot1’
Warning: namespace ‘emmeans’ is not available and has been …Run Code Online (Sandbox Code Playgroud) 如何添加将回归方程连接到 x 轴上的特定点和 y 轴上的相应值的线?
这是一个可重现的示例:
library(ggplot2)
library(ggpmisc)
x<-c(1,2,3,5,10,12,15,20,22,25,30,33,37)
y<-c(1000,800,100,10,1,0.3,0.25,0.2,0.1,0.1,0.03,0.05,0.03)
myformula<-y ~ poly(x,3)
df <- data.frame(x, y)
ggplot(df, aes(x,y)) +
stat_smooth(method = lm, formula = myformula) +
geom_point() +
stat_smooth(method = lm, formula = myformula) +
stat_poly_eq(formula = myformula, eq.with.lhs = "italic(psi)~`=`~",
eq.x.rhs = "~italic(theta)",
aes(label = paste(..eq.label.., ..rr.label..,
sep = "~~~~")), label.x=0.15, parse = TRUE)+
xlim(0, 40)+
ylim(0, 2000)+
scale_y_log10(breaks = c(0, 0.1,10,1000), labels= c(0,0.1, 10,1000))
Run Code Online (Sandbox Code Playgroud)
我尝试在 Windows 计算机上下载最新版本(4.2.0)的 R,并在尝试打开该程序时收到此错误消息。“致命错误:‘R_TempDir’包含空格”。有没有人遇到过这个问题或对如何解决它有任何想法?我尝试重新安装该程序并移动该程序的存储位置,但没有成功。