Thank you all very much for your helpful comments and showing where I went
wrong. After so many trials, the code below seems to work:
incorp <- with(data7.13.11,
ifelse(groupinc %in% c(5), 'cons',
ifelse(groupinc %in% c(-3,-2) & indinc < 9,
'ethnat',
Hello,
Sorry, there's a mistake repeated in 3 code lines. Corrected:
incorp <- rep(NA, 4408)
incorp[groupinc == 5] <- 'cons'
incorp[(groupinc %in% -3:-2) & (indinc < 9)] <- 'ethnat'
incorp[(groupinc %in% 1:4) & (indinc > 8)] <- 'libmul'
incorp[(groupinc %in% -2:-1) & (indinc > 8)] <- 'civic'
H
On Nov 7, 2012, at 3:07 PM, haps wrote:
> I have a big dataset. I want to create a new factor variable with certain
> conditions based on two existing numeric variables.
> Existing variables: indinc (range: 0 to 16), groupinc (range -3 to 5)
> Conditional values that 'incorp' will take:
> If gro
Hello,
Try the following.
incorp <- rep(NA, 4408)
incorp[groupinc == 5] <- 'cons'
incorp[(groupinc == -3:-2) & (indinc < 9)] <- 'ethnat'
incorp[(groupinc == 1:4) & (indinc > 8)] <- 'libmul'
incorp[(groupinc == -2:-1) & (indinc > 8)] <- 'civic'
Hope this helps,
Rui Barradas
Em 07-11-2012 23:0
On 08-11-2012, at 00:07, haps wrote:
> I have a big dataset. I want to create a new factor variable with certain
> conditions based on two existing numeric variables.
> Existing variables: indinc (range: 0 to 16), groupinc (range -3 to 5)
> Conditional values that 'incorp' will take:
> If groupi
5 matches
Mail list logo