Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Ankitapahuja
Regular Visitor

R code not working

Hi,

 

I am unable to run any R code in the data set. Below is the error received. Please help. Thanks

 

R script issue.PNG

6 REPLIES 6
Anonymous
Not applicable

Hi Ankitpahuja
Could you please provide the R Code, so we may check it?

Hi,

 

Below is the R code,

 

R code.PNG

Anonymous
Not applicable

Hi

Although I can't see the whole code, my best guess is that something is missing before the r code..

would you mind the post the query code?

 

The R code is as below:

 

write.table(dataset, file = "C:/Users/v-akrag/Documents/MSFT Office Apps/Test/PowerBI_SD_new2.csv",  row.names = FALSE)

 

and Power BI query code is

 

 

#"Inserted Week of Year" = Table.AddColumn(#"Inserted Year", "WeekOfYear", each Date.WeekOfYear([Start Date]), type number),

    #"Inserted Merged Column" = Table.AddColumn(#"Inserted Week of Year", "Merged", each Text.Combine({Text.From([Year], "en-US"), Text.From([WeekOfYear], "en-US")}, ":"), type text),

#"Grouped Rows" = Table.Group(#"Changed Type2", {"Category", "App Name", "Merged"}, {{"Downloads", each List.Sum([Downloads]), type text}}),

#"Merged Queries" = Table.NestedJoin(#"Inserted Merged Column1",{"Merged.1"},PowerBI_SD1,{"NewMerged"},"NewColumn",JoinKind.Inner),

    #"Expanded NewColumn" = Table.ExpandTableColumn(#"Merged Queries", "NewColumn", {"D.Date", "Index", "D.Date.lag", "D.Downloads.lag", "WoW Growth"}, {"NewColumn.D.Date", "NewColumn.Index", "NewColumn.D.Date.lag", "NewColumn.D.Downloads.lag", "NewColumn.WoW Growth"}),

    #"Run R Script" = R.Execute("# 'dataset' holds the input data for this script#(lf)write.table(dataset, file = ""C:/Users/v-akrag/Documents/MSFT Office Apps/Test/PowerBI_SD_new2.csv"",  row.names = FALSE)",[dataset=#"Expanded NewColumn"])

in

    #"Run R Script"

 

 

 

 

Anonymous
Not applicable

I tested your R Script, it works fine.

So I think the issue happens in one of the steps before, even though the message tells something different.

This is the entire Power Bi query code. Could you please help us identifying where the error might lie:

 

 

 

let

    Source = Folder.Files("C:\Users\v-akrag\Documents\MSFT Office Apps\Test\Downloads_csv"),

    #"Invoked Custom Function" = Table.AddColumn(Source, "Transform Binary from Downloads_csv", each #"Transform Binary from Downloads_csv"([Content])),

    #"Renamed Columns1" = Table.RenameColumns(#"Invoked Custom Function",{{"Name", "Source.Name"}}),

#"Expanded Table Column1" = Table.ExpandTableColumn(#"Removed Other Columns1", "Transform Binary from Test (4)", Table.ColumnNames(#"Removed Other Columns1"[#"Transform Binary from Test (4)"]{0})),

 

#"Inserted Week of Year" = Table.AddColumn(#"Inserted Year", "WeekOfYear", each Date.WeekOfYear([Start Date]), type number),

    #"Inserted Merged Column" = Table.AddColumn(#"Inserted Week of Year", "Merged", each Text.Combine({Text.From([Year], "en-US"), Text.From([WeekOfYear], "en-US")}, ":"), type text),

#"Grouped Rows" = Table.Group(#"Changed Type2", {"Category", "App Name", "Merged"}, {{"Downloads", each List.Sum([Downloads]), type text}}),

#"Merged Queries" = Table.NestedJoin(#"Inserted Merged Column1",{"Merged.1"},PowerBI_SD1,{"NewMerged"},"NewColumn",JoinKind.Inner),

    #"Expanded NewColumn" = Table.ExpandTableColumn(#"Merged Queries", "NewColumn", {"D.Date", "Index", "D.Date.lag", "D.Downloads.lag", "WoW Growth"}, {"NewColumn.D.Date", "NewColumn.Index", "NewColumn.D.Date.lag", "NewColumn.D.Downloads.lag", "NewColumn.WoW Growth"}),

    #"Run R Script" = R.Execute("# 'dataset' holds the input data for this script#(lf)write.table(dataset, file = ""C:/Users/v-akrag/Documents/MSFT Office Apps/Test/PowerBI_SD_new2.csv"",  row.names = FALSE)",[dataset=#"Expanded NewColumn"])

in

    #"Run R Script"

 

 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.