I can't understand why it's stating there is no such file when it is sitting in the environment:
#~~~~~~~~~~~
# Libraries
#~~~~~~~~~~
library(dplyr)
#>
#> Attaching package: 'dplyr'
#> The following objects are masked from 'package:stats':
#>
#> filter, lag
#> The following objects are masked from 'package:base':
#>
#> intersect, setdiff, setequal, union
library(ggplot2)
library(tidyr)
#~~~~~~~~~~~~
# Thresholds
#~~~~~~~~~~~
Thresh.Brix.min <- 15
Thresh.Brix.max <- 30
Thresh.Pol.min <- 50
Thresh.Pol.max <- 105
Thresh.Fibre.min <- 4
Thresh.Fibre.max <- 25
Thresh.Ash.min <- 0
Thresh.Ash.max <- 8
# Import the NIRS data (NIRPred.csv), a CSV file with variable names in the first row, comma (“,”) as field separator character, and dot (“.”) as decimal point character
NIRData<- read.table("NIRPred.csv", header=TRUE, sep = ",", dec= ".")
#> Warning in file(file, "rt"): cannot open file 'NIRPred.csv': No such file
#> or directory
#> Error in file(file, "rt"): cannot open the connection
# Display summary
summary(data.frame(NIRData))
#> Error in data.frame(NIRData): object 'NIRData' not found
# Assign the DateTime variable to the POSIXct data type
NIRData$DateTime <- as.POSIXct(NIRData$DateTime, format = "%Y-%m-%d %H:%M:%S")
#> Error in as.POSIXct(NIRData$DateTime, format = "%Y-%m-%d %H:%M:%S"): object 'NIRData' not found
# Use transform() with the floor() function applied to ScanID to create a new variable called LabID in the NIRData table.
NIRData<-NIRData%>%mutate(LabID=transform(NIRData$ScanID)+floor(NIRData$ScanID))
#> Error in eval(lhs, parent, parent): object 'NIRData' not found
Here's a screenshot: