error:time zone not found When I use read_table()

I just learn how to use R and R studio. And I met some trouble when I use read_table.I have already install readr package successfully. I don't know how to fix it. Please give me some help. Thanks.

da <- read_table("q-ko-earns8309.txt")
##Error: Timezone database not found at "C:/Users/寰愭槑瀹?Documents/R/win-library/4.1/tzdb/tzdata"

Also I don't know why such odd characters come out in path.

This is unfortunately a hard to fix bug caused by https://github.com/r-lib/tzdb/issues/10.

It looks like you are on Windows. The problem comes with having Unicode characters in your file path, i.e. 寰愭槑瀹?.

In general R is not the best at handling Unicode in file paths, so there may be other places where you are going to get bitten by this outside of just readr. That said, this is a bug in tzdb and I would like to fix it eventually.

In the meantime, to fix this you have to do one of two things.

You could create a new user that doesn't have Unicode in the name and login as them. That is going to be the best long term solution to avoid any other Unicode issues with R and file paths (pretty much all your file paths are going to have your user name in the file path).

Or you could tell R to look for your package library in a different place. To do this you should open your .Renviron file with usethis::edit_r_environ(). You'll need to update the R_LIBS_USER environment variable to a folder that doesn't have Unicode in the name. Possibly like:

R_LIBS_USER="C:/R/packages/%v"

This assumes that you can create a folder on your machine directly on your C drive, and that it doesn't have to be inside your User specific folder at C:/Users/寰愭槑瀹?. If you can't create the folder shown above, this isn't going to work for you unfortunately.

The %v is going to become the R version you are working on in the form of <major>.<minor>. i.e. if you are on R 4.0.2 then that would become 4.0.

For that to take effect, the folder actually has to exist on your computer, so you need to manually go create the folder C:/R/packages/4.0 (where you would substitute 4.0 for whatever your R version is. You can figure that out by typing R.version.string in the R console).

Then if you restart R, .libPaths() should return "C:/R/packages/4.0" as the first path.

At that point you'll need to install tzdb again with install.packages("tzdb") so that it puts it in that new folder.

If you get that far, restart R one more time and hopefully you can read the file with readr now.

I'm sorry that you are new to R and are experiencing this, I know this probably isn't very fun.

Thank u for detailed explanation. I tried to set a new path for package which was without special characters.But it also failed.
So I re-downloaded R and R studio and set library file path again. The read_table function works well !!! But I got new trouble. R studio always said

In normalizePath(path.expand(path), winslash, mustWork) :path[1]="C:/Users/???/Documents"

Now I even cannot use R markdown to finish my course task. When I load Rmarkdown,

Error writing code to file C:/Users/�.....

I think the reason is my user account is not named in English. Maybe I really need to create a new user,although I am unwilling to do that.

Thanks ,Davis.

I'm not sure how to advise on the rest of that.

If you can, I really do think the best solution for you is to create a new user. I think you'll constantly be fighting issues like this otherwise.

You could try to rename your user profile folder, but it is complex and might have unintended side effects, so if you try that then you should make a backup of your computer first https://www.tenforums.com/tutorials/89060-change-name-user-profile-folder-windows-10-a.html

Finally I fix it by creating a new user in English. And everything works very well now. Not only readr package, but also R markdown.
Thank you so much,Davis.

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.