Help with importing data into R studio

Very new to R studio! I'm having an issue getting a .csv file into R studio. I have have included an image of the code I've used to insert the data but the data won't actually appear! Anyone know what I'm doing wrong?

Screenshot 2020-08-24 at 13.05.42

I think the problem I'm having is that the variable will not display the csv table. Anyone know how to fix this?

It looks like you have this code in RMarkdown document in the setup chunk, which has the option include=FALSE set. This means that you won't see output from that chunk.

You can learn more about how chunks work in RMarkdown here:

For example, here's the section on include:

include : Whether to include anything from a code chunk in the output document. When include = FALSE , this whole code chunk is excluded in the output, but note that it will still be evaluated if eval = TRUE . When you are trying to set echo = FALSE , results = 'hide' , warning = FALSE , and message = FALSE , chances are you simply mean a single option include = FALSE instead of suppressing different types of text output individually.

I'd suggest only using the setup chunk for setting knitr options, etc., and then putting your other code in other chunks. When you create a new RMarkdown document, it usually has multiple chunks inside of it in the example document created. But, essentially, chunks are bound by three backticks (```) with the "engine" or language declared in the opening (this is better described in the section on R code chunks I linked to above:

```{r}
library(here)
library(tidyverse)
# etc. whatever code you want in here
```

You can also use the keyboard shortcut to insert a new chunk if you're working in RStudio.
For Windows and Linux: Ctrl+Alt+I
For Mac: Cmd+Option+I

1 Like

Brilliant! Yes that has solved the problem. Thank you very much Mara. The video I watched actually specifically said to run that code in the template code chunk and it seemed to work for them which is strange.

1 Like

If your question's been answered (even by you!), would you mind choosing a solution? It helps other people see which questions still need help, or find solutions if they have similar problems. Here’s how to do it:

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.