On Tue, Dec 7, 2010 at 7:54 AM, Gabor Grothendieck
<ggrothendi...@gmail.com> wrote:
> 'On Tue, Dec 7, 2010 at 5:19 AM, mxkuhn <mxk...@gmail.com> wrote:
>> Greg and Frank,
>>
>> Thanks for the replies. I didn't express myself very well; I'm not interest 
>> in the model fitting aspect. I'd just like to get the full set of dummy 
>> variables (optimally from model.matrix)
>>
>
> Try this:
>
> levels(when$time) <- c("morning", "afternoon", "night")
> levels(when$day) <- c("Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun")
>
> contr.dummy <- function(n, ...) diag(n)
> mm <- suppressWarnings(model.matrix(~ day + time, when))
> mm[is.na(mm)] <- 1
> mm
>
> You might also want to set the levels of your factors first so that it
> includes levels that are not in the data and so that the levels are
> sorted in an order other than alphabetical:
>

The levels(when$day) lines should be:

levels(when$day) <- c("Monday", "Tuesday", "Wednesday", "Thursday",
"Friday", "Saturday", "Sunday")



-- 
Statistics & Software Consulting
GKX Group, GKX Associates Inc.
tel: 1-877-GKX-GROUP
email: ggrothendieck at gmail.com

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to