Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
484 views
in Technique[技术] by (71.8m points)

powerbi - R Script is not running in Power BI

I have seen similar problems to this one but I have not found a solution for this specific case.

Context: I have some excel files imported into Power BI and I need to do some analysis.

Goal: I want to run the following code: head(my_df,3)

To achieve that I do the following: Home -> Transform Data -> Power Query Editor opens -> Click on "my_df" -> "Run R script" -> "output <- head(my_df,3)

This results in the following error message:

DataSource.Error: ADO.NET: R script error. Error in head(raw_booking, 3) : object 'raw_booking' not found Execution halted

Details: DataSourceKind=R DataSourcePath=R Message=R script error. Error in head(raw_booking, 3) : object 'raw_booking' not found Execution halted

I tried head(iris,3) and it worked!!! What am I missing?

question from:https://stackoverflow.com/questions/65927609/r-script-is-not-running-in-power-bi

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

"Run R script" takes the input data from the last applied step in the query and stores it as dataset in the script window.

Therefore, try:

output <- head(dataset, 3)

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...