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
Anonymous
Not applicable

R script Understanding

Can anyone please help me in understanding the R Query in my powerBI report , so based on that I will change it in perl Script.

new_data <- dataset[dataset$ParName == 'Turbidity Field (NTU)',c('DepthValue','ResultValue','SampleDate', 'StationID')]

new_data$ResultValue = round(new_data$ResultValue, 2)

xrange <- range(new_data$ResultValue)

yrange <- range(new_data$DepthValue)

yrange <- range(c(0, yrange[2]))

 

plot(xlim=xrange, yrange, ylim = rev(yrange), type="n", xlab="Turbidity Field (NTU)",ylab="Depth", axes=FALSE )

 

all_lines <- unique(paste(new_data$SampleDate, new_data$StationID))

 

colors <- c()

c <- 0

for (i in all_lines) {

    c <- c + 1

    colors <- c(colors, c)

}

cc <- 0

limited_lines <- all_lines[0:5]

limited_colors <- colors[0:5]

for (i in limited_lines ) {

    cc <- cc + 1

    cur_data <- subset(new_data, paste(SampleDate, StationID)==i)

    sorted_data <- cur_data[order(cur_data$DepthValue),]

    lines(sorted_data$ResultValue, sorted_data$DepthValue, type="l", lwd=5, col=limited_colors[cc])

   

}

axis(3)

axis(2)

box()

 

 

Thanks,

Rosh

1 REPLY 1
v-yulgu-msft
Employee
Employee

Hi @Anonymous ,

 

You could start R learning from here: https://www.tutorialspoint.com/r/index.htm

 

Then, please refer to below documents to run R script in Power BI desktop.

Run R scripts in Power BI Desktop

Create Power BI visuals using R

 

Regards,

Yuliana Gu

Community Support Team _ Yuliana Gu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

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.