I was able to use pander successfully this morning on one computer, but now I am trying to do it on my own computer, and I am having some weird issues.
Here is my very elementary R Pander code:
library("pander")
library("knitr")
test<-Pandoc$new("My Name","Test")
test$add.paragraph('# Welcome to Test')
test$add.paragraph('*****')
#works so far but here it won't work
test$add(3+3)
#here I get error in dev.control(displaylist = "enable"):
# dev.control() called without an open grpahics device
# In addition: Warning message:
#In png("plots/....png", width=480,height=480,res=72, : failed to load cairo DLL
I literally can't use $add to add R code, and I don't understand why. I would greatly appreciate if someone could help.
Regards
edit:
R version 3.2.1 (2015-06-18)
Platform: x86_64-apple-darwin13.4.0 (64-bit)
Running under: OS X 10.10.4 (Yosemite)
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] knitr_1.10.5 rmarkdown_0.7 rapport_0.51 yaml_2.1.13 plyr_1.8.3 lattice_0.20-33 pander_0.5.2 brew_1.0-6
loaded via a namespace (and not attached):
[1] htmltools_0.2.6 tools_3.2.1 Rcpp_0.12.0 reshape_0.8.5 grid_3.2.1 digest_0.6.8
It appears I did not have XQuartz installed. I installed it and everything works so thank you and köszönöm for the help.
Related
I find myself confronted with a problem for which I fail to find a clue to a solution - which makes it very hard to actually deal with it.. Here goes: In R (with R-Studio) I try to create a Date object with the library lubridate:
library(lubridate)
ymd(20161001)
which results in an error:
Error in as.POSIXlt.POSIXct(x, tz) :
(converted from warning) unknown timezone 'GMT'
A second run (and any subsequent runs) of the last command yields the correct result:
ymd(20161001)
[1] "2016-01-01"
until I restart my R-session, when again the first run triggers an error. I've checked several settings, but can't find anything changing from the first to the second run. Here's, for instance, the output of my sessionInfo():
R version 3.3.2 (2016-10-31)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 7 x64 (build 7601) Service Pack 1
locale:
[1] LC_COLLATE=Dutch_Netherlands.1252 LC_CTYPE=Dutch_Netherlands.1252 LC_MONETARY=Dutch_Netherlands.1252 LC_NUMERIC=C
[5] LC_TIME=Dutch_Netherlands.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] lubridate_1.6.0
loaded via a namespace (and not attached):
[1] magrittr_1.5 tools_3.3.2 stringi_1.1.2 stringr_1.1.0
Sys.timezone() says [1] "Europe/Berlin", and Sys.getenv('TZ') is empty: ""
I do find others stumbling upon the same warning, such as this blogpost or here, but these problems have to do with times, whereas I would prefer to ignore times altogether, and deal with dates only.
I was getting the same error today. My code was in an Rmarkdown file set to output as a tufte_html document. I was loading the following packages:
library(lubridate)
library(tidyverse)
library(stringr)
library(extrafont)
library(extrafontdb)
library(tufte)
To get my code working I did the following:
First, I got off my company's VPN, suspecting that maybe it was the problem, but I was still getting the error when using my home wifi and no VPN. Next, I updated all my packages but was still getting the error.
Then, I shut down my Macbook and rebooted but was still getting the error.
Finally, I changed my script to no longer load tidyverse as a whole but instead load:
library(lubridate)
library(tibble)
library(dplyr)
library(readr)
library(extrafont)
library(extrafontdb)
library(tufte)
Then my Rmarkdown file rendered to html without the unknown timezone error. Unfortunately, I cannot pinpoint what exactly fixed the error or why loading parts but not the whole tidyverse seemed to do the trick for me. Did you ever solve your problem?
My session info when it worked:
R version 3.4.2 (2017-09-28)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: macOS High Sierra 10.13.1
Matrix products: default
BLAS: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/3.4/Resources/lib/libRlapack.dylib
locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] tufte_0.2 extrafontdb_1.0 extrafont_0.17 stringr_1.2.0
[5] readr_1.1.1 dplyr_0.7.4 tibble_1.3.4 lubridate_1.7.1
loaded via a namespace (and not attached):
[1] Rcpp_0.12.13 Rttf2pt1_1.3.4 knitr_1.17 bindr_0.1
[5] magrittr_1.5 hms_0.3 R6_2.2.2 rlang_0.1.4
[9] tools_3.4.2 htmltools_0.3.6 yaml_2.1.14 rprojroot_1.2
[13] digest_0.6.12 assertthat_0.2.0 bindrcpp_0.2 glue_1.2.0
[17] evaluate_0.10.1 rmarkdown_1.8 stringi_1.1.6 compiler_3.4.2
[21] backports_1.1.1 pkgconfig_2.0.1
The answer to this question worked for me.
I added Sys.setenv(TZ='America/Detroit') to my script, for example.
The solution presented here R error: unknown timezone with as.POSIXct()
In my case, after including Sys.setenv(TZ="America/Lima") at the beginning of the code everything works fine.
Please check the list of valid TZ values at https://en.wikipedia.org/wiki/List_of_tz_database_time_zones
I think this is a newly introduced bug. At the very least, it bugged previously working code.
library(glmmADMB)
epil2$subject <- factor(epil2$subject)
fm <- glmmadmb(y~Base*trt+Age+Visit+(Visit|subject),
data=epil2, family="nbinom")
VarCorr(fm)
Produces the following error:
Error in glmmADMB::VarCorr(fm) :
could not find symbol "rdig" in environment of the generic function
VarCorr from nlme still works fine:
library(nlme)
nlme::VarCorr(fm) ##WORKS
glmmADMB::VarCorr(fm) ##Still doesn't work.
Here is my systemInfo if that helps:
> sessionInfo()
R version 3.2.3 (2015-12-10)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 7 x64 (build 7601) Service Pack 1
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] nlme_3.1-125 glmmADMB_0.8.1 MASS_7.3-45
loaded via a namespace (and not attached):
[1] Matrix_1.2-3 plyr_1.8.3 magrittr_1.5 tools_3.2.3
[5] coda_0.18-1 Rcpp_0.12.3 stringi_1.0-1 grid_3.2.3
[9] stringr_1.0.0 R2admb_0.7.13 lattice_0.20-33
I found a solution to my problem. I used the installation code provided here:
http://glmmadmb.r-forge.r-project.org/ . I am not sure if it was necessary but before running the below code I navigated to my ~R/R-3.2.3/library folder and deleted the glmmADMB folder.
Then I ran the code below.
install.packages("R2admb")
install.packages("glmmADMB",
repos=c("http://glmmadmb.r-forge.r-project.org/repos",
getOption("repos")),
type="source")
This updated my glmmADMB to version 0.8.3.3 which corrected the error (by turning it into a warning).
Since yesterday, I cannot load some common used packages, e.g. reshape2 and stringr through library command.
Step to reproduce my problem:
1) Start a new session in Rstudio server (Version 0.99.467). I also kill the active-sessions in Rstudio server.
2) Run these codes
library(ggplot2)
library(stringr)
3) Get an error message:
Error in unloadNamespace(package) :
namespace ‘stringr’ is imported by ‘reshape2’ so cannot be unloaded
Show Traceback
Rerun with Debug
Error in library(stringr) : “stringr” version 0.6.2 cannot be unloaded.
But I don't get error if stringr is loaded before ggplot2. How should I fix this problem. Thanks for any suggestions.
I may have to update R to 3.2
My R session info:
R version 3.1.3 (2015-03-09)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu precise (12.04.5 LTS)
locale:
[1] LC_CTYPE=en_AU.UTF-8 LC_NUMERIC=C LC_TIME=en_AU.UTF-8 LC_COLLATE=en_AU.UTF-8
[5] LC_MONETARY=en_AU.UTF-8 LC_MESSAGES=en_AU.UTF-8 LC_PAPER=en_AU.UTF-8 LC_NAME=C
[9] LC_ADDRESS=C LC_TELEPHONE=C LC_MEASUREMENT=en_AU.UTF-8 LC_IDENTIFICATION=C
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] ggplot2_1.0.0
loaded via a namespace (and not attached):
[1] colorspace_1.2-4 digest_0.6.4 grid_3.1.3 gtable_0.1.2 MASS_7.3-39 munsell_0.4.2 plyr_1.8.1
[8] proto_0.3-10 Rcpp_0.11.2 reshape2_1.4 scales_0.2.4 stringr_0.6.2 tools_3.1.3
I resolved my problem through updating R and all R packages.
I guess the problem is caused by old version of stringr or reshape2 as I install the same packages in different places (system folder or personal library). R tried to load a old version of package.
Even though it is a good practice to update R for me it was not necessary to solve the same issue. The problem can result from few .libPaths(). With .libPaths("C:/Program Files/R/R-3.4.3patched/library") you can point out one folder. After that just reinstall of packages, and it should work.
My code:
> .libPaths()
[1] "L:/My Documents/R/win-library/3.4" "C:/Program Files/R/R-3.4.3patched/library"
> .libPaths("C:/Program Files/R/R-3.4.3patched/library")
> packages<-c('ggplot2','data.table','knitr','xtable')
> install.packages(packages)
> lapply(packages,library,character.only=T)
Even though the issue is solved I hope it will help someone.
After upgrading to R 3.0.X, I've started getting pretty frequent, unreproducible segfault errors like those found by this asker. I never had one of these errors before with R 2.X.X. For example, this is the session info for a long block of code that just caused a fault. However, after R crashed, I ran the entire block of code again and there was no error.
R version 3.0.1 (2013-05-16)
Platform: x86_64-apple-darwin10.8.0 (64-bit)
locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] klaR_0.6-8 ggplot2_0.9.3.1 labdsv_1.5-0 MASS_7.3-26 mgcv_1.7-22
[6] cluster_1.14.4 sparcl_1.0.3 FD_1.0-11 vegan_2.0-7 permute_0.7-0
[11] geometry_0.3-3 magic_1.5-4 abind_1.4-0 ape_3.0-8 ade4_1.5-2
[16] plyr_1.8
loaded via a namespace (and not attached):
[1] class_7.3-7 colorspace_1.2-2 dichromat_2.0-0 digest_0.6.3
[5] e1071_1.6-1 grid_3.0.1 gtable_0.1.2 labeling_0.1
[9] lattice_0.20-15 Matrix_1.0-12 munsell_0.4 nlme_3.1-109
[13] proto_0.3-10 RColorBrewer_1.0-5 reshape2_1.2.2 scales_0.2.3
[17] stringr_0.6.2
Sometimes R freezes completely and I have to do a force quit, but other times, it allows me to exit with options for a core dump or saving the workspace.
Someone in another post suggested setting options(CBoundsCheck=T) and that seemed to work for a while but I am still getting frequent faults.
I don't think these faults are related to any specific kind of calculation or function as I got one the other day after starting a new session and only setting my working directory and options. The code that triggered the fault and the system info would look like this:
#Set my working directory
setwd("~/Documents/School Spring 2013/Quaternary Dissasembly/Functional Diversity Basefile 3")
#Keep getting segfaults all the time. This might fix it
options(CBoundsCheck=T)
sessionInfo()
R version 3.0.1 (2013-05-16)
Platform: x86_64-apple-darwin10.8.0 (64-bit)
locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
attached base packages:
[1] stats graphics grDevices utils datasets methods base
Any help anyone could give me to find and fix the bug or the incorrect settings I have would be greatly appreciated. Thank you.
-M
I have a data frame "df1" of the following kind:
set.seed(2)
df1 = data.frame(Var1=rep(c('a','b','c','d'),3),
Var2=rep(c('aa','bb','cc'),each=4),
value=rnorm(12))
I try to create this plot:
ggplot(df1) + geom_bar(aes(x=Var2,y=value),stat="identity") + facet_wrap(~Var1)
and I get the following error message that I don't understand:
formal classes cannot be used without the methods package
What's wrong ? I can't find a package called methods by the way.
Here is my sessionInfo()
R version 3.0.1 (2013-05-16)
Platform: x86_64-apple-darwin10.8.0 (64-bit)
locale:
[1] fr_CH.UTF-8/fr_CH.UTF-8/fr_CH.UTF-8/C/fr_CH.UTF-8/fr_CH.UTF-8
attached base packages:
[1] utils graphics methods stats base
other attached packages:
[1] agricolae_1.1-4 reshape2_1.2.2 lattice_0.20-15 ggplot2_0.9.3.1 data.table_1.8.8
loaded via a namespace (and not attached):
[1] colorspace_1.2-2 datasets_3.0.1 dichromat_2.0-0 digest_0.6.3 grDevices_3.0.1 grid_3.0.1 gtable_0.1.2
[8] labeling_0.1 lme4_0.999999-2 MASS_7.3-26 Matrix_1.0-12 munsell_0.4 nlme_3.1-109 plyr_1.8
[15] proto_0.3-10 RColorBrewer_1.0-5 scales_0.2.3 stats4_3.0.1 stringr_0.6.2 tools_3.0.1
Thank you
I encountered the same error message and found a solution but in a different context.
The error happened while running an R script on a cluster. Interestingly the same script worked fine on a laptop (during testing with a subset of the data).
The solution in my context was to import the package with which the data was preprocessed. What I mean is that I previously saved an RDS file created using the package "Seurat". When reading the RDS file in a new session the package "Seurat" would load automatically when ran on a local machine. However on the cluster I had to specifically load the package with the library() command, before reading the RDS file. This is what solved the problem and stopped the obfuscated error message.