getting error when scaning the data

Hi All ,

I am beginner in coding and in R programming.
I want to implement the Baxter-King filter from the Package ‘mFilter’ on Eur/Usd data .
Here is my code:


  library('mFilter')
  a = scan("C://EURUSD60_CLOSE");
  
  plot(a, type='l')
  a.bw <- bkfilter(a, pl=2, pu=4, nfix=1,type="fixed")
  a.trend <-a.bw$trend
  lines(a.trend,col="blue")

I am getting the following error messages;

>   plot(a, type='l')
Error in plot(a, type = "l") : object 'a' not found

what should I replace the object ''a'' with ?What is exactly ''a'' for?
The second error message is

>   a = scan("C://EURUSD60_CLOSE.txt");
Error in file(file, "r") : cannot open the connection
In addition: Warning message:
In file(file, "r") :
cannot open file 'C://EURUSD60_CLOSE.txt': No such file or directory

I extracted the EURUSD60_CLOSE.txt file into the c//
when I check the file from the c// the file is there.But when I check the file from Session/Set working directory/Choose directory the file from the c// the file is not there.

Thank you.

It seems you data file is named C://EURUSD60_CLOSE.txt, so the scan function should be run as

a = scan("C://EURUSD60_CLOSE.txt")

That will get rid of the No such file or directory error. Your data will then be stored in the object named a and the next line of code, plot(a, type='l') should run, plotting your data as a line.

Thanks for your respond.Unfortunately I still get the error message in below .

>   a = scan("C://EURUSD60_CLOSE.txt")
Error in file(file, "r") : cannot open the connection
In addition: Warning message:
In file(file, "r") :
  cannot open file 'C://EURUSD60_CLOSE.txt': No such file or directory
>

Is this something to do Windows security settings?The file in the c//
is visible but EURUSD60_CLOSE.txt file is not visible in the Session/Set working directory/Choose directory.

I see that I had a typo in my previous answer. The file path should have only one / in it:

a = scan("C:/EURUSD60_CLOSE.txt")

If that does not work, try putting the file on your desktop. The top level c:\ folder is not usually used for storing data.

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