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
Related
I was trying to re-render a Quarto document after adding some more code. The code previously rendered fine.
However, this time the render failed, with this error:
Error in yaml::yaml.load(meta, handlers = list(expr = parse_only)) :
Parser error: while parsing a block mapping at line 1, column 1 did not find expected key at line 2, column 27
Calls: .main ... FUN -> parse_block -> partition_chunk -> <Anonymous>
Execution halted
I thought this was referring to the YAML bit at the top, but I hadn't made any changes to that, and the document previously rendered fine. I simplified the YAML to the simplest case, but the error persisted.
---
title: "Test"
format: html
---
```{r}
#| label: tbl-exibble
#| tbl-cap: "Exibble Bla Bla")
gt::gt(exibble)
```
This was caused by a typo - I'm posting this and answering it here because I think the error message is not particularly helpful and it might mislead other people
The bug lies in the table caption chunk option, not in the YAML block at the start.
I had an extra ) at the end of the line; this fixed it:
---
title: "Test"
format: html
---
```{r}
#| label: tbl-exibble
#| tbl-cap: "Exibble Bla Bla"
gt::gt(exibble)
So if you get YAML parser errors similar to mine, please check your YAML; not only in the top part of the Quarto document, but also in your chunk options.
You do not even need ", e.g.
---
title: "Test"
format: html
---
```{r}
#| label: tbl-exibble
#| tbl-cap: Exibble Bla Bla)))))
gt::gt(mtcars)
```
inline code
---
title: "Test"
format: html
---
```{r}
#| label: tbl-exibble
#| tbl-cap: !expr paste0("mtcars")
gt::gt(mtcars)
```
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.
I am trying to create an R markdown file but when I do I get the following error:
Line 2:
Error in .Call(C_str Sub_replacement, str, from, to, NULL, value) :
Incorrect number of arguments (5), expecting 6 for 'C_str Sub Replacement'
Calls: <Anonymous> ... indir -> inline exec -> <Anonymous> -> str_sub<- -> .Call
I have tried searching the internet and can not find an answer to this specific error. I am running R-3.3.0 and using R Studio.
I have updated the packages - knitr, markdown and yaml.
The following is my set up:
---
title: "Setting up a DQASS PC"
author: "DKMillington"
date: "`r format(Sys.Date(), '%d/%m/%Y')`"
header-includes:
- \usepackage{amsmath}
output:
rmarkdown::html_vignette:
css: mystyle.css
toc: true
number_sections: true
---
```{r, echo = FALSE, message = FALSE}
knitr::opts_chunk$set(collapse = TRUE, comment = "#>")
library(dqass)
```
Thank you for your time in advance.
Dale
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
I am new to R markdown and knitr and haven't found the answer to this question:
I have R scripts where I've written functions and have assigned data to position 1 (.GlobalEnv). How do I access my data and run my functions within R markdown and generate the .html file with knitr?
Here's a trivial example. In a script file I generate:
some.x.data<-1:10
some.y.data<-1:10
toy.fn<-function(){
tot<-some.x.data + some.y.data
tot
}
toy.fn() works in the script file.
My R markdown file contains:
---
title: "trivial test"
author: "me"
date: "July 9, 2015"
output: html_document
---
```{r}
plot(some.x.data, some.y.data)
toy.fn()
```
When I click knit HTML, I get the following error:
Error in plot(some.x.data, some.y.data) : object 'some.x.data' not found
Calls: ... withCallingHandlers -> withVisible -> eval -> eval -> plot
Thanks
RStudio opens a new R session to knit() your Rmd file, so the objects in .GlobalEnv will not be available to that session (they are two separate sessions), so when you are knitring HTML there is not way to know what some.x.data, some.y.data and toy.fn is.
Either you need to recreate them in your Rmd file. If you don't want any output just do:
```{r, echo = FALSE, message = FALSE}
some.x.data<-1:10
some.y.data<-1:10
toy.fn<-function(){
tot<-some.x.data + some.y.data
tot
}
```
Full Rmd:
---
title: "trivial test"
author: "me"
date: "July 9, 2015"
output: html_document
---
```{r, echo = FALSE, message = FALSE}
some.x.data<-1:10
some.y.data<-1:10
toy.fn<-function(){
tot<-some.x.data + some.y.data
tot
}
```
```{r}
plot(some.x.data, some.y.data)
toy.fn()
```
Or
knit manually by yourself: library(knitr); knit('your_file.Rmd')