plot - Rename factors in a spineplot with R -
is possible rename factor's in spineplot? names of factors long, overlap.
thanks advices!
reading spineplot, clear can pass parameters yaxlabels , xaxlabels control vectors annotation of axes.
one useful function abbreviate shorten character strings.
combining information spineplot example gives:
treatment <- factor(rep(c(1, 2), c(43, 41)), levels = c(1, 2), labels = c("placebo", "treated")) improved <- factor(rep(c(1, 2, 3, 1, 2, 3), c(29, 7, 7, 13, 7, 21)), levels = c(1, 2, 3), labels = c("none", "some", "marked")) spineplot(improved ~ treatment, yaxlabels=abbreviate(levels(improved), 2)) 
not of plot functions in r have type of parameter. more general solution, might necessary rename factors before passing plot function. can access , modify factor names using levels function:
levels(treatment) <- abbreviate(levels(treatment), 5) plot(improved ~ treatment) 
Comments
Post a Comment