How to upload data to Chunk?

1

I'm venturing into Rmarkdown, I found it a very interesting tool. It happens that I'm in trouble, I think it's basic beginner, when I complied Rmarkdown with knitr it gives the unknown object error:

   Quitting from lines 13-16 (doc.Rmd) 
   Error in inherits(x, "list") : objeto 'tab.genova' não encontrado
   Calls: <Anonymous> ... withCallingHandlers -> withVisible -> eval -> eval -> kable -> inherits
  Execução interrompida

I looked into, I saw that I had to import my data using the function read.csv() or source which is usually a problem that beginners usually run into.

I tried these commands and I can not, I think it's a mistake I'm making and not realizing.

The integrity of the codes present in the chunks, they are operating normally, because when giving run current chunk the graph and the table are plotted normally and without errors.

'''{r TabGenova, echo=FALSE}
library(knitr)
kable(tab.genova)

'''
    
asked by anonymous 14.03.2018 / 15:55

1 answer

4

Using rmarkdown to create a report means merging the textual part of the analysis with the codes in R . Therefore, it is necessary to explicitly load each package or file needed to perform the analysis. So do the following:

  • Copy the file .csv with your data into the same directory as the file .Rmd

  • Inside the RStudio, go to the menu Session > Set Working Directory > To Source File Location

  • Add the following chunk to your code, somewhere before the first test to be performed:

  • (text placed because of a bug in the OS)

    '''{r LeituraDeDados, echo=FALSE}
    tab.genova <- read.csv(file="ArquivoComOsDados.csv")
    head(tab.genova) # para conferir as seis primeiras linhas e ver se deu certo
    '''
    
  • If the item command above gives you a problem, you may need to add the argument sep=";" or sep="\t" to read.csv to tell you which column separator is correct. Find this by opening ArquivoComOsDados.csv in some text editor.
  • 14.03.2018 / 17:58