Skip to content
Prev 317851 / 398506 Next

creating a new variable.

On 02/19/2013 11:01 AM, Nicole Ford wrote:
Hi Nicole,
The usual way something like this is done is to create a factor of a 
given size with the appropriate levels:

party<-factor(sample(c("dem","rep","oth"),100,TRUE))
  party
   [1] dem dem dem rep oth dem dem oth rep dem rep rep oth dem oth oth 
dem dem
  [19] oth rep oth rep dem oth rep dem oth oth oth oth rep dem oth dem 
oth rep
  [37] dem oth dem oth rep oth rep oth rep dem dem rep rep rep dem oth 
dem dem
  [55] oth dem rep dem rep oth rep oth dem dem dem rep dem rep dem oth 
rep rep
  [73] rep dem rep rep rep dem oth oth oth rep oth rep oth oth dem oth 
rep dem
  [91] rep rep oth dem rep dem dem oth dem dem
Levels: dem oth rep

Jim