[R] using nested ifelse when i want to process values from more than 3 columns of data frame
Anusha.Indhira at controlsdata.com
Mon Oct 24 14:06:23 CEST 2016
Got past the syntax error,now I got new error below
Error in match.fun(FUN) : c("'ifelse((kmeans.data$HBV51OpenDmd & kmeans.data$HBV52OpenDmd & ' is not a function, character or symbol", "' kmeans.data$HBV53OpenDmd & kmeans.data$HBV8OpenDmd) == 1, ' is not a function, character or symbol", "' \"all-true\", (ifelse((kmeans.data$HBV51OpenDmd == 0 & kmeans.data$HBV52OpenDmd == ' is not a function, character or symbol", "' 0 & kmeans.data$HBV53OpenDmd == 0 & kmeans.data$HBV8OpenDmd == ' is not a function, character or symbol", "' 0), \"all-false\", \"other\")))' is not a function, character or symbol" )
From: Indhira, Anusha
Sent: 24 October 2016 12:56
To: 'r-help at r-project.org'
Subject: using nested ifelse when i want to process values from more than 3 columns of data frame
I would like to process each row of data frame having 8 columns of which I am interested in 4 columns for my analysis.I tried using apply function but I get syntax error,although I checked for missing syntaxes ,couldn't figure out the mistake.Can you also suggest me more efficient way to perform same action.
# creating target column from result
kdata$target <- apply(kdata,1,ifelse((kdata$H1 & kdata$H2 & kdata$H3 &
kdata$H8) == 1,"all-true",(ifelse(kdata$H1== 0 &
kdata$H2 == 0 &
kdata$H3 == 0 &
kdata$H8 == 0) ,
This e-mail (including attachments) contains contents owned by Rolls-Royce plc and its subsidiaries, affiliated companies or customers and covered by the laws of England and Wales, Brazil, US, or Canada (federal, state or provincial). The information is intended to be confidential and may be legally privileged. If you are not the intended recipient, you are hereby notified that any retention, dissemination, distribution, interception or copying of this communication is strictly prohibited and may subject you to further legal action. Reply to the sender if you received this email by accident, and then delete the email and any attachments.
[[alternative HTML version deleted]]
More information about the R-help