New to markdown and knit, so...
In RStudio, this markdown code does well
## 'r': razão entre opções
```{r}
round(apply(rst0[,c('rstQ','rstV','rstMkt','rstMkt2','rstAntiMkt')],2,mean),3)
```
rstQ rstV rstMkt rstMkt2 rstAntiMkt
81.408 111.098 0.012 0.007 0.005
But when I click knit button, I get error:
Line 20 Error in apply(rst0[,c('rstQ','rstV','rstMkt','rstMkt2','rstAntiMkt')], : object 'rst0' not found Calls: <Anonimous> ... withCallingHandlers -> withVisible -> eval -> eval -> apply
But knit('../gap.Rmd') successfully generates the gap.md file.
Related
Based on this Q&A , this code defines a package containing an active binding to the value 1. It passes devtools::check():
my_function <- function() 1
#' return 1
#' #usage my_active_binding
#' #name my_active_binding
NULL
.onLoad <- function(libname, pkgname) {
ns <- asNamespace(pkgname)
makeActiveBinding("my_active_binding", my_function, env = ns)
namespaceExport(ns, "my_active_binding")
}
However if my active binding fails by default (in my use case it should be used in a specific context),
then devtools::check() is not happy anymore.
Edit: actually if I use print() or message() rather than stop() I run into the same issues
my_function <- function() stop("stop!!!")
#' stop!!!
#' #usage my_active_binding
#' #name my_active_binding
NULL
.onLoad <- function(libname, pkgname) {
ns <- asNamespace(pkgname)
makeActiveBinding("my_active_binding", my_function, env = ns)
namespaceExport(ns, "my_active_binding")
}
See below :
-- R CMD check results ---------------------------------- abtest 0.0.0.9000 ----
Duration: 21s
> checking DESCRIPTION meta-information ... WARNING
Non-standard license specification:
GPL3
Standardizable: FALSE
> checking S3 generic/method consistency ... WARNING
Error in (function () : stop!!!
Calls: <Anonymous> -> Filter -> unlist -> lapply -> FUN -> <Anonymous>
Ex�cution arr�t�e
See section 'Generic functions and methods' in the 'Writing R
Extensions' manual.
> checking for code/documentation mismatches ... WARNING
Error in (function () : stop!!!
Calls: <Anonymous> ... Filter -> unlist -> lapply -> FUN -> get -> <Anonymous>
Ex�cution arr�t�e
> checking dependencies in R code ... NOTE
Error in (function () : stop!!!
Ex�cution arr�t�e
> checking foreign function calls ... NOTE
Error in (function () : stop!!!
Calls: <Anonymous> -> lapply -> FUN -> get -> <Anonymous>
Ex�cution arr�t�e
See chapter 'System and foreign language interfaces' in the 'Writing R
Extensions' manual.
> checking R code for possible problems ... NOTE
Error in (function () : stop!!!
Calls: <Anonymous> ... withCallingHandlers -> do.call -> <Anonymous> -> get -> <Anonymous>
Ex�cution arr�t�e
> checking Rd \usage sections ... NOTE
Error in (function () : stop!!!
Calls: <Anonymous> ... Filter -> unlist -> lapply -> FUN -> get -> <Anonymous>
Ex�cution arr�t�e
The \usage entries for S3 methods should use the \method markup and not
their full name.
See chapter 'Writing R documentation files' in the 'Writing R
Extensions' manual.
0 errors v | 3 warnings x | 4 notes x
Erreur : R CMD check found WARNINGs
Ex�cution arr�t�e
Exited with status 1.
How can I do to integrate this active binding in my package and satisfy devtools::check() / R CMD check ?
Im trying to run the following rmarkdown code:
https://docs.google.com/document/d/164VZx3_cZ4tBa1Um39VH1cQ4zqRuCvpCTj-B50Vq2gk/edit?usp=sharing
But Im getting the following error when I knit the code:
Quitting from lines 26-47 (demo.Rmd)
Error in (function (file = "", code = NULL, env = globalenv(), embeddedR = TRUE, :
Error 1 occurred building shared library.
Calls: <Anonymous> ... block_exec -> in_dir -> engine -> do.call -> <Anonymous>
In addition: Warning message:
No function return type found for Rcpp::export attribute at file1af863722d6.cpp:4
Execution halted `
When I replace {Rcpp} with {rcpp} I get to run it but its not giving the output. How do I get it to run and give the output?
I have an example bookdown project with gitbook output
index.Rmd:
---
title: "An Example Project"
author: "Coderoo"
output:
bookdown::gitbook: default
pandoc_args: ["--lua-filter=hello.lua"]
documentclass: book
---
Some text {{helloworld}}
hello.lua is taken straight from the pandoc lua-filter doc:
return {
{
Str = function (elem)
if elem.text == "{{helloworld}}" then
return pandoc.Emph {pandoc.Str "Hello, World"}
else
return elem
end
end,
}
}
But when I try to build the book:
Rscript -e "bookdown::render_book('index.Rmd','bookdown::gitbook')"
I get this error:
Error in yaml::yaml.load(..., eval.expr = TRUE) :
Scanner error: mapping values are not allowed in this context at line 5, column 16
Calls: <Anonymous> ... parse_yaml_front_matter -> yaml_load -> <Anonymous> -> .Call
Please delete _main.Rmd after you finish debugging the error.
Execution halted
If I replace bookdown::gitbook default in the YAML metadata with html_document then everything works fine.
Crossposted here as well: https://community.rstudio.com/t/how-to-use-lua-filter-with-gitbook-output/48256
EDIT: Answered in the rstudio forum.
i am trying (invane) to load a png file in my Rmd file.
I save both the Rmd and the png in the same folder on my main drive (I tested i can read/write files in there with R).
When i run the following code
---
title: "Determinants of profitability"
author: "Daniele Frison"
date: "26 November 2015"
output:
html_document:
fig_height: 10
fig_width: 10
---
```{r}
![aaa](prof_vs_costs.png)
```
I get inexorably this error message:
|................................ | 50%
ordinary text without R code
|.................................................................| 100%
label: unnamed-chunk-1
processing file: test.Rmd
Quitting from lines 13-16 (test.Rmd)
Error in parse(text = x, srcfile = src) : <text>:2:2: unexpected '['
1:
2: ![
^
Calls: <Anonymous> ... <Anonymous> -> parse_all -> parse_all.character -> parse
Execution halted
I can't find what is the problem with this parse.
Thanks in advance for your kind help
Created a Data Frame ofp.1 which contains 13 rows and 2 columns using normal R file. The Data Frame is present in memory .
Now I want to use this table in xtable to print in R Markdown file.
`---
title: "abc"
output: html_document
---
<table border = 1 align='center'>
<tr>
<td style='text-align:center'>
```{r include=FALSE}
library(xtable)
```
```{r results='asis', echo=FALSE}
print(xtable(ofp.1),type='html',include.rownames=F)
```
</td>
</tr>
</table>
I am getting error Error in xtable(ofp.1) : object 'ofp.1' not found
Calls: <Anonymous> ... withCallingHandlers -> withVisible -> eval -> eval -> print -> xtable
Execution halted
what i Can figure out is that Markdown cannot find my Table though it is present in memory. Need Help .Thanks