r script
3 TopicsRegresion lineal multiple R studio Power Bi
Hola, ejecuté un script de r para calcular una regresión lineal multiple. Pude obtener el intercepto y slope y traspasarlos a una tabla utilizando library broom tidy(model). library(broom) model <- lm(Energía_electrica~ Grados + Transacciones,dataset) model <- tidy(model) esta es la base de datos Mes Energía_electrica Grados Transacciones Tienda ene-22 93.471 337 58.567 CD feb-22 82.053 319 51.095 CD mar-22 79.777 295 55.652 CD abr-22 67.907 204 49.633 CD may-22 71.634 185 49.520 CD jun-22 68.864 164 49.280 CD jul-22 69.559 159 50.992 CD ago-22 67.204 161 49.913 CD sept-22 63.007 172 43.913 CD oct-22 65.902 204 48.704 CD nov-22 66.469 256 46.081 CD dic-22 73.164 326 50.385 CD ene-22 132.321 354 66.405 hc feb-22 108.787 313 61.665 hc mar-22 114.572 304 65.195 hc abr-22 94.501 207 56.435 hc may-22 98.740 170 55.612 hc jun-22 87.222 151 52.630 hc jul-22 81.592 123 54.133 hc ago-22 74.998 142 50.118 hc sept-22 67.039 188 43.383 hc oct-22 77.155 212 49.618 hc nov-22 108.387 260 48.931 hc yo necesito calcular la regresión para cada tienda y que la tabla con slope e intercepto me haga una distinción de cual es para cada tienda o que con los filtros los números se actualicen (debo tener slope e intercepto en una tabla porque luego necesito ocupar esos numeros para formulas). Se puede hacer algo como un ciclo for o alguna distinción en esta nueva tabla para filtrar por tienda?1.3KViews0likes3CommentsDynamically place text in R Script visual
Because Power BI is designed as a tool to be used interactively, it has many limitations on static data labels. To get around this issue, I'm using ggplot in an R Script visual to create a bubble chart where I can label bubble values with multiple data dimensions. The R Script visual passes fields as an R dataframe named dataset. So far, so good. I want to place annotation text on the right side of the plot. To do this, I need to know the extent of the x and y axes and use that information to set the x and y values in the geom_text() or annotate() functions. To do that, I need to know the minimum and maximum values of the x and y data points. Assuming my fields are named x_data and y_data, I have included the following in my R script: xmin <- min(dataset$x_data) xmax <- max(dataset$x_data) ymin <- min(dataset$y_data) ymax <- max(dataset$y_data) I then use the variables in to position my text: g <- dataset %>% ggplot(aes(x = x_data, y = y_data)) + geom_point(aes(size = size_data)) + annotate(geom='label', label='Test text', size = 4, x=xmax, y=ymax, hjust="inward", vjust="inward") g The code runs without error, but the text label does not appear. If I hard code the values of xmax and ymax in the annotate() command, it does. This makes it appear that the variable values are not visible to the rest of the script, yet there is no error. Does anyone know if calculated R variables can work the way I'm intending? And if they can't, is there any other way to accomplish what I'm trying to do?Solved1.5KViews0likes3CommentsEstimating Weibull Parameters
Hello! I've been attempting to create a Weibull distribution in PBI in order to get the B50 and B10 life ratings for performance. In order to create it I've been attempting for a few days to create a dynamic index to do the calculations for it, but overall it seems PBI isn't optimized for computing something like this, and even if I solve the dynamic indexing problem I wouldn't be able to perform all the calculations, graph them, and get the estimated weibull parameters from that. Is there any better way to go about creating a weibull distribution to get life ratings? Would using an R script be the best possible solution? Or would the rest of the calculations be possible if the dynamic indexing problem can be solved? I can provide more context to the situation if that would help to clarify anything. Any advice or help is greatly appreciatedSolved3.7KViews0likes3Comments