How do you make this code work: myts <- readxl::read_excel(file.choose(), skip=1)[,"A3349873A"] %>% ts(frequency=12, start=c(1982,4))

Student here,

I got this code from my professor just so we could make our code work and change the headers. But I'm not certain what should go into the "....(file.choose()..." section. I put the name of file and then I did the path method I'd normally use for cvs files, in quotations too. Here's the link to the excel.

Originally, before the assignment was updated I had it saved as a cvs and doing the usual remove the row and struggling to relabel the second row as headers. In other online forums there was something about tidyverse and dyplr. Or using the name.columns function and using quotations for the new name. But I didn't the far either with either route when my professor updated us with this code.

nstall.packages("readxl")
myts <- readxl::read_excel(file.choose(), skip=1)[,"A3349873A"] %>% ts(frequency=12, start=c(1982,4))

The file.choose() function does not need an argument. It will open a dialog from which you can choose the file. If that is not working for you, you can replace file.choose() with a string showing the path to the file.

Great--thanks. I think my program was experiencing a slight glitch because that didn't happy the first time. Much appreciated.

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