: Re: [R] Converting a categorical variable to multiple
dichotemousvariables
hi:
here is one solution:
cat-as.factor(c(1,1,3,2,4))
model.matrix(~cat-1,cat)
cbind(cat,model.matrix(~cat-1,cat))
Andrija
On Tue, Apr 12, 2011 at 2:17 PM, Shane Phillips
sphill...@lexington1.netwrote:
I have
-project.org
Sent: Tuesday, April 12, 2011 2:32 PM
Subject: Re: [R] Converting a categorical variable to multiple
dichotemousvariables
hi:
here is one solution:
cat-as.factor(c(1,1,3,2,4))
model.matrix(~cat-1,cat)
cbind(cat,model.matrix(~cat-1,cat))
Andrija
On Tue, Apr 12, 2011 at 2:17 PM, Shane
Shane,
Does this work?
# Your simulated data
subject=1:1000
treat=rbinom(1*1000,1,.13)
gender=rbinom(1*1000,1,.5)
eth=runif(1*1000, min=1, max=4)
cogat=rnorm(1*1000, 100, 16)
map=rnorm(1*1000, 200, 9)
growth=0
simtest=data.frame (subject=subject, treat=treat, gender=gender,
3 matches
Mail list logo