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

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -