Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
Hi All,
I am using R code to generate a scatter plot with moving average but when I run the code I am getting the below error.
library(ggplot2) library(zoo, warn.conflicts = FALSE) library(dplyr, warn.conflicts = FALSE) library(lubridate, warn.conflicts = FALSE) dataset$Date_of_Cleaning__c = as.factor(dataset$Date_of_Cleaning__c) dataset$Date_of_Cleaning__c = as.Date(dataset$Date_of_Cleaning__c,format="%d/%m/%Y") # find moving average zoo.avg <- zoo(dataset$Specific_Water_Usage__c) ma1 <- rollapplyr(zoo.avg, 2, mean, fill = NA, na.rm = T) #result$avgwu=coredata(ma1) #plot graph p <- ggplot(data=dataset, aes(x= Date_of_Cleaning__c, y= Specific_Water_Usage__c, color= Name))+ ylab("Water Usage") + geom_point()+ ggtitle(paste0("Water Management")) + scale_x_date(date_breaks = "1 month",date_labels = "%b/%y")+ theme(axis.title.y = element_text(size = 11, face = "bold",margin = margin(0,2,0,0)))+ theme(axis.title.x = element_text(size = 11, face = "bold"))+ theme(axis.text.x = element_text(size=11))+ theme(axis.text.y = element_text(size=11))+ theme(plot.title = element_text(face = "bold",size= 11,lineheight = 0.7,hjust = 0.5), plot.subtitle = element_text(face = "bold",size= 12,lineheight = 0.9,hjust = 0.5))+ theme(plot.title=element_text(margin=margin(0,0,7,0)))+ #geom_smooth(data=result, aes(x=Date, y=avgwu),color="red", size=1.5,se=FALSE)
It seems that you may remove the last plus sign (+).
HI @v-chuncz-msft,
I had removed the (+), another issue is I was using ggplot to plot geom_point(), however, the date is overlapped each other.
So try to use scale_x_date(date_breaks = "1 month",date_labels = "%b/%y"), however is not working due to the date format.
#date format
dataset$Date_of_Cleaning__c = as.factor(dataset$Date_of_Cleaning__c)
dataset$Date_of_Cleaning__c = as.Date(dataset$Date_of_Cleaning__c,format="%d/%m/%Y")
I did change the date format using the code above, it shows error in seq.int(0, to0 - from, by)...
Anyone can help me to solve this issue?
is there any way to overcome the date overlapping each other?
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
110 | |
100 | |
80 | |
64 | |
58 |
User | Count |
---|---|
148 | |
111 | |
94 | |
84 | |
67 |