Question

I have the following data frame which is created below:

temp <- as.data.frame(with(uadm, table(prlo_state_code)))

I am looking to create 11 dummy variables. One for each of the top 10 and an 'other'. The top 10 can easily be found with:

#top10
temp <- temp[order(temp$Freq, decreasing=T),]
head(temp, n=10)

I know R is great, so I am assuming there is an easy to auto-create (and name) the dummy variables from the top 10 and collapse the rest into a final dummy called 'other.'

Thanks in advance for any help or insight.

No correct solution

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top