Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
surajt
Frequent Visitor

Error in publishing R visuals

I developed a custom R visual in Power BI desktop using the following code (this is working in the desktop version)

 

dataset<-data.frame(Start_Time,End_Time,Machine,Duration)

Sys.setenv(TZ='CST6CDT')

library(ggplot2)
library(lubridate)
library(scales)

ds<-dataset
output <- as.data.frame(ds, stringsAsFactors = FALSE)

output$startTime2<-ymd_hms(output$Start_Time, tz="CST6CDT" )
output$endTime2<-ymd_hms(output$End_Time, tz="CST6CDT")

timelinechart <- ggplot(output, aes(color = Execution1)) + 
  geom_segment(aes(x=startTime2,xend=endTime2, y=Shift, yend=Shift),size=20)+theme(axis.text.x = element_text(angle = 45, hjust=1))+ scale_x_datetime(breaks=date_breaks("4 hour"))+coord_flip()

plot(timelinechart)

When I tried publishing this to web, it gives me the following error -

Error in as.POSIXlt.POSIXct(x, tz) : (converted from warning) unable to identify current timezone 'C': please set environment variable 'TZ'

 

I tried looking at a few posts which recommended adding Sys.setenv(TZ='CST6CDT') before library imports, but it didn’t work…

 

Any help with this will be greatly appreciated!

3 REPLIES 3
surajt
Frequent Visitor

Hi @pcshingles ,

 

Can you help me with this error? I believe the error that I have is same as what you had in your post. 

R script visual not displaying in web due to time zone error

 

Any help with this will be greatly appreciated!

 

Suraj

v-huizhn-msft
Microsoft Employee
Microsoft Employee

Hi @surajt,

Have you tried the solution shared in this thread? If you still have problem, could you please share your sample table for trouble shootting the error? You can create fake data if your data is confidential.

Best Regards,
Angelia

Hi @v-huizhn-msft,

 

I did take into consideration the thread you mentioned. The solution talks about setting a time zone before library imports.

That’s why I included the following in my code before library imports.

 

Sys.setenv(TZ='CST6CDT') 

 

Here is a sample file...

sample file 

 

Regards,

Suraj

 

 

 

 

 

 

 

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.