Re: [R] Ifelse statements and combining columns

2017-07-25 Thread PIKAL Petr
ilto:r-help-boun...@r-project.org] On Behalf Of Kirsten > Morehouse > Sent: Monday, July 24, 2017 2:24 PM > To: R-help > Subject: [R] Ifelse statements and combining columns > > Hi everyone, > > I'm having some trouble with my ifelse statements. > > I'm try

Re: [R] Ifelse statements and combining columns

2017-07-24 Thread Koustav Pal
That ifelse statement is a mess, it is missing brackets, comma separators between arguments and & or | between conditions. The bracket error points towards the invalid bracket you had in the second ifelse since it expects and yes and a no argument alongside conditions. ifelse(test = (dat$cond == "

Re: [R] Ifelse statements and combining columns

2017-07-24 Thread Duncan Murdoch
On 24/07/2017 8:57 AM, Jeff Newmiller wrote: Not a reproducible example, so a bit of guessing here, but a) don't try to assign results to variables inside the ifelse. That is, remove all the single-equals signs and "test" variables. If you really need to conditionally assign variables then us

Re: [R] Ifelse statements and combining columns

2017-07-24 Thread Jeff Newmiller
Not a reproducible example, so a bit of guessing here, but a) don't try to assign results to variables inside the ifelse. That is, remove all the single-equals signs and "test" variables. If you really need to conditionally assign variables then use "if"... but chances are good you don't need

Re: [R] Ifelse statements and combining columns

2017-07-24 Thread Rui Barradas
Hello, Your ifelse statement is a mess. I cannot make sense of it. Let me try to explain where I've lost it. dat$cond <- ifelse(test = dat$cond == "cond1" This is already very bad, do you mean dat$cond == "cond1" ? Maybe you mean that condition OR the others below, but then there's one '|' mi

[R] Ifelse statements and combining columns

2017-07-24 Thread Kirsten Morehouse
Hi everyone, I'm having some trouble with my ifelse statements. I'm trying to put 12 conditions within 3 groups. Here is the code I have so far: dat$cond <- ifelse(test = dat$cond == "cond1" | dat$cond == "cond2" | dat$cond == "cond3" dat$cond == "cond4" yes = "Uniform"