I am utilizing the same dataset within R and Power BI. When only graphing the datapoints in a scatterplot format, they give the same results. below is a screenshot from Power BI’s R script editor:
enter image description here
However, when I try to connect these points using type = “b”, the results differ. R connects the points based on x axis which is correct (date from oldest to newest). Below:
enter image description here
Power BI seemingly connects the points from y axis least to greatest which is incorrect. below:
enter image description here
I believe that Power BI is doing some sort of data cleaning on their backend that is reading the data in a specific way. I’m very familiar with Power BI but newer to R and cannot seem to find a solution or explanation of this issue online. Below is the code which is identical between programs (after importing the file using read.csv in R):
dataset$Date = as.Date(with(dataset, paste(Year, Month, c(“1″),sep=”-“)), “%Y-%m-%d”)
plot(dataset$Date, dataset$US.Maintenance.Spend, type = “b”, ylim = c(50000000, 300000000), xlim = as.Date(c(‘2020-01-01’, ‘2023-12-31’)))
the data only has three columns: Year, Month, and US.Maintenance.Spend
DPaulson is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.