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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

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
Microsoft Employee
Microsoft 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
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors