Reputation: 99
type<-c('2室1厅','2室2厅','3室2厅','1室1厅','4室2厅',
'3室1厅','1室','2室','1室2厅','5室2厅','4室3厅')
Why does ifelse
return only numbers?
Upvotes: 1
Views: 1531
Reputation: 120
Try this:
ifelse(house$room == type, '不要张贴图片', as.character(house$room))
Upvotes: 0
Reputation: 887048
It could be that house$room
is factor
and it gets coerced to integer
storage values within the ifelse
loop. One option is to convert to character
class
ifelse(house$room %in% type, as.character(house$room), '不要张贴图片')
Upvotes: 5