0

This is probably a very basic question but since I did not deal with dates and times in R, I didn't know how to solve it. The problem is when I open a new R session and run sys.time() it gives me wrong time. I found a solution to that Sys.setenv(TZ="TURKEY") and changed it. However, when I close R and open it again. It goes back to wrong result again. How do I make this permanent?

> Sys.time()
[1] "2022-04-01 11:16:37 GMT"
Warning messages:
1: In normalizePath(dirname(f)) : path[1]="NA": No such file or directory
2: In as.POSIXlt.POSIXct(x, tz) :
  unknown timezone 'zone/tz/2022a.1.0/zoneinfo/Europe/Istanbul'
> Sys.setenv(TZ="TURKEY")
> Sys.time()
[1] "2022-04-01 14:17:39 EEST"
fire_ecologist
  • 253
  • 3
  • 9

1 Answers1

1

You can set TZ="TURKEY" in your .Renvironment file. This will load each time you (re)start R, and thus you will always get the timezone you want.

.Renvironment files can be created for each R project, or globally for all your projects. You can see this answer for how to create a global .Renvironment file .

jpiversen
  • 3,062
  • 1
  • 8
  • 12