Quantcast
Channel: Desktop topics
Viewing all articles
Browse latest Browse all 213916

Bug using an if statement in R script

$
0
0

Hi everyone,

 

I am experiencing some trouble with an R script in Power BI.

 

I aim at converting some data of a column depending on its value.

When I run this script, to replaces all "2" by "100", all 2 gets indeed replaced but by "null", not by 100.

 

Here's the script :

 

ctr <- 0
for (day in dataset[,1]) {
ctr <- ctr+1
if (dataset[,1][ctr] == 2) {
dataset[,1][ctr] <- 100
}
}

 

output <- dataset

 

Here is a screenshot :

 


snap.PNG

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Someone may have a clue.

 

Thanks

 

Didier


Viewing all articles
Browse latest Browse all 213916

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>