r script
5 TopicsCreating a Custom Gauge Visual
I'm trying to create a custom visual that shows the distribution of data through a visualisation similar to a boxplot. I then want to have a point on that plot that moves along the boxplot depending on the value of a slicer. But the problem is my slicer moves the boxplot and the scale aswell. I created my visual with R and I've included the code below: Dar <- ggplot(data = dataset, aes(x = 0, y = Data)) + scale_color_viridis_d( option = "mako", name = "Level:", direction = -1, begin = .15, end = .9, labels = function(x) paste0(as.numeric(x)*100, "%") ) + ggdist::stat_interval() + coord_flip() + stat_summary(geom = "point", fun = "median", color = "red", size = 6, pch = 17, aes(x = -0.05, y = Data) ) Dar And this is what my visualisation looks like: Any help would be greatly appreciated!608Views0likes0CommentsR-Script Visual Runtime Error in Power BI Server
Hi Everyone, I wrote a R-Script that works/runs perfectly in Power BI Desktop but doesn't work when published to the Power BI Service. I'm not able to pinpoint the error, is it the pipe operator (%<%)? Any help would be highly apperciated, I've been struggling with this issue for some time now. Script Runtime Error: Evaulation Error: Level sets of factors are different R-Script: # The following code to create a dataframe and remove duplicated rows is always executed and acts as a preamble for your script: # dataset <- data.frame(ProjectName, Commodity, WBS_code, Months, Running_Total_V2, Total_Scope_V2, RTPercentCompleteV2, Project_Description) # dataset <- unique(dataset) # Paste or type your script code here: library(dplyr) library(ggplot2) library(RColorBrewer) proposal_project <- unique(dataset[["Project_Description"]]) # there are duplicates due to WBS df <- dataset %>% select(ProjectName, Commodity, Months, RTPercentCompleteV2) %>% distinct() # for projects with multiple entries for the same percent complete, keep the highest value df <- df %>% group_by(ProjectName, Commodity, RTPercentCompleteV2) %>% slice(which.max(Months)) %>% arrange(Months) # group by and interpolate pctcomplete <- seq(0.1, 1, by=0.05) df <- df %>% group_by(ProjectName, Commodity) %>% group_modify(~ {approx(.x$RTPercentCompleteV2, .x$Months, xout=pctcomplete) %>% data.frame()}) %>% ungroup() prop_df <- df %>% filter(ProjectName == proposal_project) # split out proposal data after transformations df2df <- df %>% filter(ProjectName != proposal_project) data_wo_proposal <- df2df %>% group_by(Commodity,x) %>% summarise_at(vars(y),list(mean_duration = mean)) # plot mindiff <- min(c(0)) maxdiff <- max(c(max(data_wo_proposal$mean_duration, na.rm=TRUE), max(prop_df$y, na.rm=TRUE))) ticks <- round(seq(mindiff, maxdiff, by=2)) tick_y <- seq(0,100, by=5) g <- ggplot(data=data_wo_proposal, aes(x=mean_duration, y=x, colour=Commodity)) + geom_line(linetype=2) + geom_point() final_plot <- g + geom_line(data = prop_df, aes(x=y,y=x,colour=Commodity)) + geom_point(data=prop_df,aes(x=y,y=x,colour=Commodity)) final_plot_label <- final_plot + labs(title='Average Duration of Reference Projects vs Proposal Project', subtitle=paste('Proposal Project:',prop_df$ProjectName[1], '(solid line in figure below)'), x= 'Duration (Months)',y='Percent Complete') + theme_bw() + theme(legend.position='bottom', legend.title=element_blank()) + scale_colour_brewer(palette='Set1') + scale_x_continuous(breaks=ticks)+scale_y_continuous(labels = scales::percent_format(accuracy = 1),breaks=seq(0,1, by=.05)) final_plot_label Thank you, ValSolvedR Custom Power BI Visualization Variable Input Handling
I am trying to create a custom viz (scatter plot) with the ability to provide different options for colour and shape of the points using ggplot2. My visualisation works fine when I specify both the Shape and Colour parameter, however, I want to be able to only supply one or the other down the road, not always both. This is what my parameter options look like: While my R script.r file for ingesting data is: This is the error I get when I don't include Colour or Shape or both. I feel that the ability to handle not supplying an argument should be handled within the script which I have tried to do. However, I am now stuck.Custom Visual isn't showing in report. Using R
Dear All, I have created a custom visual using R script in Power bi (online). Actually I was looking to create interactive visualization using R language. I have followed all the steps one by one given in these two articles. 1. https://www.blue-granite.com/tutorials/power-bi-interactive-r-visual 2. https://docs.microsoft.com/en-us/power-bi/developer/visuals/custom-visual-develop-tutorial#troubleshooting Right now there is no error but the blank screen. Some time it shows an error e.g (Script timeout error) Kindly help how to get rid of this problem. Thanks Regards, Nabeel MukhtarR table - dynamic column name
Hello, I need a table visual in R for wich the name of a specific colum must get a value from a measure. I'm new to R but until now I could manage to rename a colum and obtain a new name using this code: library(gridExtra) colnames(dataset)[colnames(dataset)=="TotalBase"] <- "NewName" So the original name "TotalBase" was transformed into the "NewName". But how could I pass a measure value? Is it possible to achieve something like this?: colnames(dataset)[colnames(dataset)=="TotalBase"] <- Table[Measure] Kind Regards, LucianSolved