r - In SparkR, how can we add a new column based on logical operations on an existing column? -
i can this
employees$salarynew = employees$salary * 2 employees$sale_chance <- (employee$salary > 2000)  but if want this
employees$sale_chance_1 <-  if (employees$salary > 2000) 'high'  else 'low' it gives error
error in if (employees$salary > 2000) "high" else "low" :    argument not interpretable logical this gives same error
emp1 <- withcolumn(employees, "sale_prob", {if (employees$salary > 2000) 'high' else 'low'}) 
shouldn't ifelse(employees$salary > 2000, 'high', 'low')
Comments
Post a Comment