0

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

Mukesh Kumar Singh
  • 623
  • 1
  • 10
  • 18
  • possible duplicate of [knitr: object cannot be found when converting markdown file into html](http://stackoverflow.com/questions/20364408/knitr-object-cannot-be-found-when-converting-markdown-file-into-html) – Thomas K Sep 29 '15 at 17:28
  • In order for your document to be reproducible, you should not do what you are attempting. – Thomas K Sep 29 '15 at 17:31
  • @ThomasK the same code is working for mtcars and other inbuilt data – Mukesh Kumar Singh Sep 29 '15 at 17:50
  • So what? All datasets like `iris` or `mtcars` are shipping with the base-package: `datasets`, which is automatically added to your search path, when you start `R`. Your object is not a built-in dataset, therefore a fresh `r-session` (which `knitr` uses to construct your document) won't find your object since `.GlobalEnv` will be empty. – Thomas K Sep 29 '15 at 18:00
  • You would need to define `ofp.1` somewhere in your `.Rmd` inside of a code-chunk. – Thomas K Sep 29 '15 at 18:03
  • 1
    @ThomasK I saved the data frame as .Rda file and loaded the same in Rmd file . Its working now. – Mukesh Kumar Singh Sep 30 '15 at 07:18

0 Answers0