Execution Halted in RMarkdown File

Please ask your questions about Quarto or R Markdown here.
I keep getting this message when I knit my Markdown file:

Quitting from Bellabeat-Capstone-Project.Rmd:57-67 [Importing data frames]
Execution halted

I have pasted the lines 57-67 below.

At first the Error message I got was: error: ! object 'dailyActivity_merged' not found Backtrace: ▆ 1. └─janitor::clean_names(dailyActivity_merged) Quitting from Bellabeat-Capstone-Project.Rmd:61-70 [Clean Names] Execution halted

Now execution is just halted

the 'path_to_file' insertion is from a previous user who faced a similar problem and he inserted 'path_to_file' which worked. I just don't know where he inserted it.
And I can't find the post

dailyActivity_merged <-path_to_file, read_csv('/cloud/project/mturkfitbit_export_4.12.16-5.12.16/Fitabase Data 4.12.16-5.12.16_dailyActivity_merged.csv)

dailyIntensities_merged <- path_to_file,  read_csv('/cloud/project/mturkfitbit_export_4.12.16-5.12.16/Fitabase Data 4.12.16-5.12.16_dailyIntensities_merged.csv)

dailySteps_merged <- path_to_file, read_csv('/cloud/project/mturkfitbit_export_4.12.16-5.12.16/Fitabase Data 4.12.16-5.12.16_dailySteps_merged.csv)

dailyCalories_merged <- path_to_file, read_csv('/cloud/project/mturkfitbit_export_4.12.16-5.12.16/Fitabase Data 4.12.16-5.12.16_dailyCalories_merged.csv)

sleepDay_merged <- path_to_file, read_csv('/cloud/project/mturkfitbit_export_4.12.16-5.12.16/Fitabase Data 4.12.16-5.12.16_sleepDay_merged.csv)

Hi, welcome to the forum.

It looks like you are missing that file dailyActivity_merged but there is not enough information that I, at least, can even make a guess why. That path_to_file looks suspicious and I think you have the syntax wrong.

It looks like you are trying to read in a .csv file and either the file does not exist or your path is incorrect.

What we need is a good bit of your actual Rmarkdown code. We don't need to see any of the actual text body. You can just throw in some random text as filler if you want between the code sections

What we need is the YAML (header information) and any R sections up to the R section where you are getting the error.

Copy the code and paste it here between

```

```

This should give us a nicely formatted output to work with.

Just for general information this may be helpfull though I am not sure it is directly applicable here https://forum.posit.co/t/faq-how-to-do-a-minimal-reproducible-example-reprex-for-beginners/23061

Thank you!

I have copied and pasted the YAML and all of the R code up to the point where I'm getting the error.

You're correct. The path_to_file is suspicious and I have the syntax all wrong.

I have also just run out of my compute hours so I'm unable to do a reprex.

Thank you once again,
Pula

| jrkrideau
July 23 |

  • | - |

Hi, welcome to the forum.

It looks like you are missing that file dailyActivity_merged but there is not enough information that I, at least, can even make a guess why. That path_to_file looks suspicious and I think you have the syntax wrong.

It looks like you are trying to read in a .csv file and either the file does not exist or your path is incorrect.

What we need is a good bit of your actual Rmarkdown code. We don't need to see any of the actual text body. You can just throw in some random text as filler if you want between the code sections

What we need is the YAML (header information) and any R sections up to the R section where you are getting the error.

Copy the code and paste it here between


title: "Bellabeat Capstone Project"
author: "Pula"
date: "2025-07-15"
output: html_document

knitr::opts_chunk$set(echo = TRUE)

Introduction to Bellabeat

Bellabeat is a tech-driven wellness company for women.

install.packages("tidyverse")
install.packages("here")
install.packages("skimr")
install.packages("janitor")
install.packages("dplyr")
install.packages("ggplot2")
install.packages("lubridate")
install.packages("readr")

library(tidyverse)
library(here)
library(skimr)
library(dplyr)
library(ggplot2)
library(lubridate)
library(readr)

Ah, thanks.
Yes, a little bit of a mess but nothing serious.

Problem 1 Do not install packages in an Rmarkdown document. Everything should be installed in the normal RStudio environment beforehand.

install.packages("tidyverse")
install.packages("here")
install.packages("skimr")
install.packages("janitor")
install.packages("dplyr")
install.packages("ggplot2")
install.packages("lubridate")
install.packages("readr")

library(tidyverse)
library(here)
library(skimr)
library(dplyr)
library(ggplot2)
library(lubridate)
library(readr)

Should be

library(tidyverse)
library(here)
library(skimr)
library(dplyr)
library(ggplot2)
library(lubridate)
library(readr)

Problem 2 You are missing the package {janitor} which gives you the function clean_names()

clean_names(dailyActivity_merged)

Style Issue: You do not need to load all those libraries The {tidyverse} package contains

library(dplyr)
library(ggplot2)
library(lubridate)
library(readr)

so including them all is redundant. This should be all you need

library(tidyverse)
library(here)
library(skimr)
library(janitor)
```.

This below should do what you want.  


title: "Bellabeat Capstone Project"
author: "Pula"
date: "2025-07-15"
output: html_document


```{r include =  FALSE}

library(tidyverse)
library(here)
library(skimr)
library(janitor)





```{r echo = FALSE}

dailyActivity_merged <-  read_csv('/cloud/project/mturkfitbit_export_4.12.16-5.12.16/Fitabase Data  4.12.16-5.12.16_dailyActivity_merged.csv') |> clean_names()

Notes

I dropped this simply because I don't like it. I find it is better to decide if you want to see the code or not in each R-section.

knitr::opts_chunk$set(echo = TRUE)

I prefer

{r echo = TRUE} or {r echo = FALSE} and so on in each section.

About the clean_names() function. I just chained it with the read_csv() function as it's tidier and saves a bit of typing.
Functionally

dat1 <- read_csv("eng.csv") |> clean_names()

is the same as

dat1 <- read_csv("eng.csv")
dat1 <- clean_names(dat1)

Forgot.
|> is cntl + shift + m if you want a shortcut.

Thank you!

I have to wait until my posit compute hours refresh on Aug 7th to try your suggestions out.

-Pula

Okay, good luck. If you have any questions just ask.

I am still getting the same error message that: "Quitting from Bellabeat-Capstone-Project.Rmd:48-58 [Importing data frames]
Execution halted"

And here's my reprex

library(tidyverse)
df <- data.frame(stringsAsFactors=FALSE,
Id ActivityDate TotalSteps TotalDistance TrackerDistance
1 1503960366 4/12/2016 13162 8.5 8.5
2 1503960366 4/13/2016 10735 6.97 6.97
3 1503960366 4/14/2016 10460 6.74 6.74
4 1503960366 4/15/2016 9762 6.28 6.28
5 1503960366 4/16/2016 12669 8.16 8.16
6 1503960366 4/17/2016 9705 6.48 6.48

             )

dailyActivity_merged <- read_csv('/cloud/project/mturkfitbit_export_4.12.16-5.12.16/Fitabase Data 4.12.16-5.12.16_dailyActivity_merged.csv) |> clean_names()

Welcome back.

As far as I can tell your problem is here in the file name:

'/cloud/project/mturkfitbit_export_4.12.16-5.12.16/Fitabase Data 4.12.16-5.12.16_dailyActivity_merged.csv"

Am I correct that this file is in cloud storage not on your hard drive? If so is it on Positron or somewhere else such as google cloud. Also is the data proprietary or could some on the forum try downloading it?

I don't use cloud storage so if it is there I am not sure if I would be much help.

I had a problem reading in your sample data so I did a bit of editing and here is my version of the data

dat2 <- structure(list(Id = c(1503960366L, 1503960366L, 1503960366L, 
1503960366L, 1503960366L, 1503960366L), ActivityDate = c("4/12/2016", 
"4/13/2016", "4/14/2016", "4/15/2016", "4/16/2016", "4/17/2016"
), TotalSteps = c(13162L, 10735L, 10460L, 9762L, 12669L, 9705L
), TotalDistance = c(8.5, 6.97, 6.74, 6.28, 8.16, 6.48), TrackerDistance = c(8.5, 
6.97, 6.74, 6.28, 8.16, 6.48)), class = "data.frame", row.names = c(NA, 
-6L))

I wrote it to disk and read it back in with no problem which is what makes me think the problem is in downloading that file.

write.csv(dat2, "example_data.csv", row.names = FALSE)


# Import "example_data.csv" and clean up names ----------------------------
# load packages -----------------------------------------------------------
library(tidyverse)
library(here)
library(skimr)
library(janitor)

mydata <- read.csv("example_data.csv") |> clean_names()
mydata

Hi John,
I've been trying to write to you for days now and I keep getting a message that my mail is undeliverable from GMAIL. So I am sorry for what is a tardy reply. I hope you get this message.
Thank you for your reply.
To answer your question the file is on my hard drive but the file path as it stands is from when I imported the file so it could be on posit cloud.
I hope that makes sense.
Thank you for editing my sample data. Not sure what to do with it though. Do I repost it?
I'm also unsure about what to do with the extra code you wrote in such as:

AND
mydata <- read.csv("example_data.csv") |> clean_names()
mydata

Ah, good to hear from you. No idea what gmail is doing.
To answer your question the file is on my hard drive but the file path as it stands is from when I imported the file so it could be on posit cloud.

Okay, if I understand this correctly that file path is no longer valid. If the file is now on your hard drive you need to find where it is and load it from there.

I have not worked with Windows in years but here is the equivalent Linux command for a file in a sub__folder named " datasets" in a folder named "Rjunk.

dat1 <- read.csv("/home/john/RJunk/datasets/eu.csv")
``

It is probably a lot easier to create an R  Project folder and copy the file there.  In RStudio you will see a **Project** tab in the upper right of your screen Just select *New Project *  then  *New Directory* and give the project a name.  Then copy the data file into it, give it a reasonable name and try to read it there.   You should be able to simply say

dat1 <- read.csv("Whatever the file name is.csv")

So you are using https://posit.cloud/ ?
path_to_file was most likely just a reference to the actual file location, not a piece of literal code you should include in your document.

Assuming that you downloaded dataset zip from

and uploaded that same(!) zip-file to your RStudio Cloud project, your import code could look something like this:

library(readr)
dailyActivity_merged <- read_csv("Fitabase Data 4.12.16-5.12.16/dailyActivity_merged.csv")

In your example you are most likely missing one / from file path, but without knowing how exactly did you upload that dataset or if / how you modified that zip locally it's difficult to guess.

If you feel confused about paths, you can also trigger data import through file pane when clicking on a csv file:

It generates code for import step that you should include in your document, otherwise knitting will not work:

Here's a quick demo project with already uploaded dataset - posit.cloud/content/10744860 - it should be accessible for all Posit Cloud users and knits into this: Gist HTML Preview

Ah, @ margusl I see it now, thanks. I had not considered it as a kaggle dataset. My suspicion is that " path_to_file " is a package {here} link since the original code loads the package {here}.
If we decompress the "mturkfitbit_export_3.12.16-4.11.16.zip" file I think we can do:

# load packages -----------------------------------------------------------
library(tidyverse)
library(here)
library(janitor)

# Set file path ---------------------------------------------------------------

mydata <-  here("mturkfitbit_export_3.12.16-4.11.16", "Fitabase Data 3.12.16-4.11.16", "dailyActivity_merged.csv")

# Load data  and tidy up names  ------------------------------------------------------------

dat1 <-  read_csv(mydata) |>  clean_names()

@ Motlalepula_Mmesi
I hope @ margusl and I have been able to help.

I think you inherited some decent code but not something that is easy to read if you are just getting started with R.

Hello margusl

I wanted to personally thank you very Very VERY much for all your help in solving my problem with my RMarkdown file. I just finished working on it. You were correct that there was something wrong with how I was using the file path and your solution to trigger data import through the file panel worked. I encountered a few extra errors once the file error was fixed but I managed to solve those. I now can knit my document without any hiccups. And finally thank you for the quick demo for working with posit cloud. I am so grateful for all your efforts.

Hi John,
I wanted to personally thank you for all your efforts in fixing the problem with my RMarkdown file. You were correct that the problem was in downloading that file. @margusl 's recommendation that I trigger file import through the file panel is what worked in the end. Thank you once again and I am grateful for all your help.

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

If you have a query related to it or one of the replies, start a new topic and refer back with a link.