Skip to content

Commit

Permalink
Update treatment.R
Browse files Browse the repository at this point in the history
  • Loading branch information
cwendorf committed Oct 7, 2023
1 parent 38cea65 commit ad24f4c
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions R/treatment.R
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ treatment.first <- function (n, base=1, intercept=FALSE, contrasts=TRUE, sparse=

treatment.last <- function (n, intercept=FALSE, contrasts=TRUE, sparse=FALSE) {
base <- if (is.numeric(n) && length(n) == 1L) n else length(n)
levels <- as.character(seq_len(n))
cont <- contr.treatment(n, base=base, contrasts=contrasts, sparse=sparse)
colnames(cont) <- paste(levels[-n], levels[n], sep="-")
levels <- as.character(seq_len(base))
colnames(cont) <- paste(n[-base], n[base], sep="-")
if(intercept) (cont <- cbind(Int=1,cont))
cont
}

0 comments on commit ad24f4c

Please sign in to comment.