Getting "Error: attempt to use zero-length variable name" in Rmd file in RStudio

Viewed 38

In RStudio, I am getting 'Error: attempt to use zero-length variable name' in the following R code block:

```{r setup, include=FALSE}
# knitr::opts_chunk$set(echo = TRUE)
pb52_in <- read.csv("../data/pb52.csv", T)
pb52 <- pb52_in
```

This is the output:

Show in New Window
Error: attempt to use zero-length variable name
> # knitr::opts_chunk$set(echo = TRUE)
> pb52_in <- read.csv("../data/pb52.csv", T)
> pb52 <- pb52_in
> 
Error: attempt to use zero-length variable name

I haven't modified the file yet, and I am only running this code block. This is my first time using Rstudio and working with R, so I am a little lost. I checked for other similar questions, and they said to check for the correct formatting of ```; I tried that but without success.

1 Answers

I solved the issue. Hopefully, it will help others:

After the code block:

```{r setup, include=FALSE}
# knitr::opts_chunk$set(echo = TRUE)
pb52_in <- read.csv("../data/pb52.csv", T)
pb52 <- pb52_in
```

I have this:

---
title: "Title"
author: "Author"
date: "XX/XX/XXXX"
output: html_document
---

I added an empty line between the last "```" and "---", and that solved the issue

Related