Forum Discussion
MPereira
7 years agoFrequent Visitor
Using R in Query Editor
Hello experts, I need to understand how to run an R script in Power BI and I found the link desktop-r-in-query-editor. At first the script did not work, until I found the post Error-in-r...
- 7 years ago
To me it looks like you aren't referencing the missing values column of completedData correctly.
When you load the data using dataset <-read.csv, by default it replaces the spaces within column names with periods. In particular, "SMI missing values" becomes "SMI.missing.values" so the last step in the R script doesn't do anything since it refers to a nonexistant column.
There are two easy fixes. Pick one or the other but not both.
- Change the last line.
output$completedValues <- completedData$"SMI missing values"
output$completedValues <- completedData$"SMI.missing.values" - Add an argument to read.csv to prevent this replacement.
dataset <- read.csv (file = "<path>", header = TRUE, sep = ",")
dataset <- read.csv (file = "<path>", header = TRUE, check.names=FALSE, sep = ",")
- Change the last line.
v-juanli-msft
7 years agoCommunity Support
Hi MPereira
The link Error-in-running-an-R-script-in-Power-Query is missing, i can't reproduce your problem, could you provide more details?
Best Regards
Maggie
- MPereira7 years agoFrequent Visitor
Hi v-juanli-msft and AlexisOlson,
Let's try!
The error link refers to a post where they suggest adding one more line of code with the path mapping of the CSV file used in the demonstration.
Here's the line of code:
dataset <- read.csv (file = "C: / Users / user / Google Drive / PowerPivot Power BI / EuStockMarkets_NA.csv", header = TRUE, sep = ",")Follow the link again:
I changed the path to my local settings and the R script started working.
However, from what I could understand, the script should return a column called CompletedValues, but this is not happening!I hope now I have been able to explain better!
Thank you for your help