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

java - WARN : org.springframework.web.servlet.PageNotFound - No mapping found for HTTP request with URI [/board/] in DispatcherServlet with name 'appServlet' -

android - How to create dynamically Fragment pager adapter -

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