Beginner: Choosing where to write xls files to

Please forgive if the code looks bad or if this is a dumb question, I'm brand new to R. Can someone help me on how to choose where I am saving the excel file to locally. That's what I'm attempting to do with the "c:\Users\Desktop\decstats.xlsx" but that is for some reason being included in the entire name of the document and where it gets saved is a nightmare. Can only go find it about 50% of the time

writexl::write_xlsx(decstats, "c:\\Users\\Desktop\\decstats.xlsx")

different systems have different conventions around path delimiters, its generally advisable to have R construct a path for you by using file.path()

                    file.path("C:","Users","Tommy Mulflur","Desktop","decstats.xlsx"))

also if theres any doubt about the directory , you can check if R undserstands it exists with something like

dir.exists(file.path("c:","Users","Tommy Mulflur"))

maybe adding it up iteratively will show you if you have a typo or somesuch along the way

Ok got it thank you so much! I tried parsing it up step by step and it returns false on either of the two below. I am now looking into creating/setting a directory. Always another challenge to go tackle!


dir.exists(file.path("c:", "Users"))

Any suggestions on this one?

Does seem strange. If you ask r to give you a temporary directory, what path does it return?


Also, what is your working directory?



I figured it out! Thank you so much. I can send the correct code if your curious.

I'm sure I'll have more silly questions soon. So much fun, but so much to learn!

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