我正在运行一些模拟,我想知道在一个漂亮的ggplot中绘制结果,但似乎ggplot无法处理列表对象.有谁知道如何将结果粘贴到ggplot图表中?
N <- 8619170
nn <- c(1000, 1200, 3000)
p <- .27
nsim <- 100
phat <- list()
for (i in 1:length(nn)) {
n <- nn[i]
x <- rhyper(nsim, N * p, N * (1 - p), n)
phat[[i]] <- x / n
}
Run Code Online (Sandbox Code Playgroud)
names(phat) <- paste("n=", nn)
stripchart(phat, method="stack")
abline(v=p, lty=2, col="red")
Run Code Online (Sandbox Code Playgroud) 我很难让flyspell在emacs中工作.我是Mac用户,但我没有使用Aquamacs,它似乎默认提供此功能.
Starting new Ispell process [/usr/local/bin/aspell::default] ...
ispell-init-process: Error: No word lists can be found for the language "en_US".
Run Code Online (Sandbox Code Playgroud) 在使用doMC和foreach在其核心之间分配进程时,我在计算机中遇到了一种奇怪的行为.有人知道为什么使用单核我比使用2核更好的性能?正如您所看到的,处理相同的代码而不注册任何核心(据称只使用1个核心)会产生更多的时间效率处理.虽然%do%似乎比%dopar%表现更好,但注册2个核心中的2个核心会产生更多时间.
require(foreach)
require(doMC)
# 1-core
> system.time(m <- foreach(i=1:100) %dopar%
+ matrix(rnorm(1000*1000), ncol=5000) )
user system elapsed
9.285 1.895 11.083
> system.time(m <- foreach(i=1:100) %do%
+ matrix(rnorm(1000*1000), ncol=5000) )
user system elapsed
9.139 1.879 10.979
# 2-core
> registerDoMC(cores=2)
> system.time(m <- foreach(i=1:100) %dopar%
+ matrix(rnorm(1000*1000), ncol=5000) )
user system elapsed
3.322 3.737 132.027
> system.time(m <- foreach(i=1:100) %do%
+ matrix(rnorm(1000*1000), ncol=5000) )
user system elapsed
9.744 2.054 11.740
Run Code Online (Sandbox Code Playgroud)
在少数试验中使用4个核心会产生截然不同的结果:
> registerDoMC(cores=4)
> system.time(m <- foreach(i=1:100) %dopar%
{ matrix(rnorm(1000*1000), ncol=5000) …
Run Code Online (Sandbox Code Playgroud) 尝试使用命令行检查程序包时出现以下问题。首先,我得到以下非常普遍的错误消息:
* checking PDF version of manual ... WARNING
LaTeX errors when creating PDF version.
This typically indicates Rd problems.
LaTeX errors found:
* checking PDF version of manual without hyperrefs or index … ERROR
Run Code Online (Sandbox Code Playgroud)
然后,当我检查Rdlatex日志时,发现以下错误:
Transcript written on Rd2.log.
Error in texi2dvi(file = file, pdf = TRUE, clean = clean, quiet = quiet, :
unable to run 'pdflatex' on 'Rd2.tex'
Error in running tools::texi2pdf()
You may want to clean up by 'rm -rf /var/folders/_q/_kj9kz0n0qq_gwkrv9qjvpxw0000gn/T//Rtmp7uzkmZ/Rd2pdf2a847787e63'
Run Code Online (Sandbox Code Playgroud)
由于某些原因,它无法运行pdflatex,尽管它已正确安装,如下所示。有谁知道如何解决这个问题?
system(“ pdflatex --version”)pdfTeX 3.14159265-2.6-1.40.15(TeX …
R CMD check
在我的包上运行时,我收到以下警告消息:
Found the following assignments to the global environment:
File ‘SciencesPo/R/describe.R’:
assign(as.character(substitute(data)), dataset, pos = 1)
Run Code Online (Sandbox Code Playgroud)
我试图通过使用, 和添加此处提到的环境来使其静音,但收到了相同的消息。envir = .SciencesPoEnv
envir = .GlobalEnv
有谁知道我该如何解决它?