Problem when knitting in R

When I try to output a world file of R Markdown, I got an error message:
Quitting from lines 63-119 (Untitled.Rmd)
Error in nchar(x) > n :
comparison (6) is possible only for atomic and list types
Calls: ... sew.list -> lapply -> FUN -> sew.character ->
Execution halted

And I also get an error message like "Error while opening file", "No such file or directory", but the file path is definitely right.

The chunk( lines 63-119) works well, when I run it independently. I have no idea what's wrong in my code and how to fix it.

Here's my code.

```{r  import data}
#r  import data
behaviour = read.csv("/Users/lu/Documents/Quatium Project/Task 1/Task 1 Data/QVI_purchase_behaviour.csv")
transaction = read_excel("/Users/lu/Documents/Quatium Project/Task 1/Task 1 Data/QVI_transaction_data.xlsx")

1.1 Examine transaction data

```{r Task 1.1 Examine transaction data}
# show the summary of transaction data metrix

#--------# Change the type of DATE into date format #--------
transaction$DATE <- as.Date(transaction$DATE, origin = "1899-12-30")

They need not only to be here according to the OS, the RStudio working environment, as shown by getwd(), must also be set to

and keeping the two notions in synch is a bother. The bother can be minimal with

  1. Create a separate RStudio project for each set of scripts that will use various datasets.
  2. Create a directory data
  3. Copy the .csv and `xlsx’ files there; avoid embedded blanks in names
  4. Treat the folder as read-only or include it in git or another VCS.
  5. Create a sibling folder obj for any transformations to be saved as an rds object, and preserve the script that performs the transformations
  6. install.packages("here")
  7. Then, whatever working directory is set to, the target can be accessed simply: read.csv(here::here("data/QVI_purchase_behaviour.csv")

This topic was automatically closed 45 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.