The coef(model) part extracts the coefficient values from the estimated model. This simply says to run a regression analysis on the Manager variable in the dataframe dataset, and use all remaining columns ~. The key to obtain the required flexibilty with regards to the number of explanatory variables lies in the Manager ~.
The function lm() handles the regression analysis. This way you'll reduce the risk of dependency issues. I hope this is what you were looking for!Īs long as it's possible, I would avoid using numerous different R libraries. Insert a Table or Matrix and activate Coefficients and Variables to get this: Insert the following script: model Close & Apply to get back to Power BI Report section and verfiy that you have a new table under Visualizations > Fields: The dataset variable is a variable of the form ame in R and is a good (the only.) starting point for further analysis. Thankfully, your question is only about ONE input table, so things aren't going to get too complicated (for multiple input tables check out this post).
Notice the line # 'dataset' holds the input data for this script. Now, go to Transform > Run R Script to open this window:
Notice that this will add a new step under Query Settings > Applied Steps>:Īnd this is where you are going to be able to edit the few lines of R code we're going to use. Simply right-click the Date column and select Remove: This will not have an impact on your regression results. In order to maintain flexibility with regards to the number of columns to include in your analysis, I find it is best to remove the Date Column. Insert the following R snippet to run a regression analysis using all available variables in a table: model Edit Queries and check that you have this: Use Home > Edit Queries and then Transform > Run R Script.