0

I am conducting a time series analysis and generating a graph for different suburbs with different quarterly sales spanning three decades. All the csv files for these suburbs are saved separately with a 'period' column and 'quarterly sale price' column. The coding for all these suburbs is going to be the same. However, a new script for suburb 'b' is not able to locate the csv files saved in the same folder for the analysis done for the previous suburb 'a'.

#this file loads the quarterly median house sales for suburb 'a'

rm(list=ls())

library(fpp2)

data <-read.csv("c:/users/dell/desktop/analysis/suburb a - deflated.csv")

Y <-ts(data[,2],start=c(1990),end=c(2021),frequency=4)

autoplot(Y) + ggtitle("Time Plot: Median House Sales Per Quarter- Adelaide") + ylab("Median Sale Price")

error for suburb 'b':

Error in file(file, "rt") : cannot open the connection

In addition: Warning message:

In file(file, "rt") :

cannot open file 'c:/users/dell/desktop/analysis/suburb b - deflated.csv': No such file or directory

edit: I am very new to R, I am not from this field so this coding was generated from looking at similar videos on youtube

sorifiend
  • 5,927
  • 1
  • 28
  • 45
rhi
  • 1
  • You should share the code used to load your other file (presumably what you refer to as suburb 'b'). The error seems to suggest that there might be something else being passed to the read.csv function, but it's hard to tell without seeing it. The working example (suburb A) you shared is helpful for context, but would be good to see the not-working snippet as well. – alexizydorczyk Oct 19 '21 at 01:59
  • Hi Izyda, thank you responding! the coding for suburb b is the same; – rhi Oct 19 '21 at 02:47
  • rm(list=ls()) library(fpp2) data <-read.csv("c:/users/dell/desktop/analysis/suburb b - deflated.csv") Y <-ts(data[,2],start=c(1990),end=c(2021),frequency=4) autoplot(Y) + ggtitle("Time Plot: Median House Sales Per Quarter- Aberfolye") + ylab("Median Sale Price") – rhi Oct 19 '21 at 02:48
  • suburb a - deflated.csv and suburb b -deflated.csv are two different files. Yet when I use the same coding and procedure for both of them, it only works for suburb a and suburb b shows error. – rhi Oct 19 '21 at 02:51
  • 1
    Ok, check out this answer: https://stackoverflow.com/questions/5568847/how-to-open-csv-file-in-r-when-r-says-no-such-file-or-directory. It is a little hard to debug this with a "reproducible" example, but essentially, you want to ensure that the path is correct, the file actually exists at that address, and you are spelling/capitalizing the path in your file system correctly.. The linked answer provides some suggestions / common issues that apparently occur in Windows (`C:/`) file systems. – alexizydorczyk Oct 19 '21 at 06:04

0 Answers0