Reputation: 5461
I have the below values in one of the column in a dataframe
231204.66666666666
376.0
346593.5
802.0
346594.5
801.0
346595.5
800.0
null
0.0
I just want the absolute value in this column. How can I do that in SparkR?
I found abs and round from SparkR which can do this job. But unfortunately it is not exported. Getting the below exception when I use Spark::abs(df$col)```
Error: 'abs' is not an exported object from 'namespace:SparkR'
I am getting the same error for SparkR::round as well.
I tried the below, but the column value not changed.
df$col <- abs(df$col)
How can I get the absolute value in the column?
Upvotes: 3
Views: 506
Reputation: 1718
The sample you gave does not change under abs().
abs has to be combined with round. Like,
round(abs(df$col))
Upvotes: 2