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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
Anonymous
Not applicable

Plotting Graph in R for First Time

Hi Experts

 

I am trying to plot the following in R.....but not sure where i am going wrong, I have check that the R libraries are availble on the Microsoft Cloud...This plots fine in R Studio.

 

my data points are 33,35,34,35,22,24,26,30,20,26,33,18...

 

#Begin first set of commands 
library(ggplot2)
library(trend)
library(zoo)
library(dplyr)
library(Kendall)
#End of first set of commands


#Begin second set of commands
data1 <- ts(c(33,35,34,35,22,24,26,30,20,26,33,18), start=c(2018, 1), end=c(2018, 12), frequency=12)
  mk.test(data1)
  data1X <- c(1:length(data1))
  data1Fit <- lm(data1~data1X)
  data1df <- data.frame(date=as.Date(time(data1)), Y=as.matrix(data1))
  ggplot(data=data1df, mapping=aes(x=date, y=Y, ymin = 0))+geom_point() +
    geom_line(color='blue') +
    stat_smooth(method = "lm", col = "red") +
    xlab("Months") + 
    ylab("Complaints") +
    scale_x_date(date_breaks = "1 month", date_labels = '%b %y') +
    labs(title = paste("Adj R2 = ",signif(summary(data1Fit)$adj.r.squared, 5),
                       " Slope =",signif(data1Fit$coef[[2]], 5)))
  #End of second set of commands
1 ACCEPTED SOLUTION
v-lili6-msft
Community Support
Community Support

hi, @Anonymous 

It should be that "trend" package is not supported in Power bi but it is supported in R Studio.

here is the document for you refer to:

https://docs.microsoft.com/en-us/power-bi/service-r-packages-support

 

Best Regards,

Lin

Community Support Team _ Lin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
v-lili6-msft
Community Support
Community Support

hi, @Anonymous 

It should be that "trend" package is not supported in Power bi but it is supported in R Studio.

here is the document for you refer to:

https://docs.microsoft.com/en-us/power-bi/service-r-packages-support

 

Best Regards,

Lin

Community Support Team _ Lin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

HI Lin

 

I have removed the Trend Package - and agree.  So are you saying now that the code should work just fine,

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Prices go up Feb. 11th.

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

Find out what's new and trending in the Fabric community.