When a linear model includes both continuous and discrete independent variables, i.e. factors and regression variables, the analysis is called {\bf analysis of covariance}.
Examples
{\bf Example:} Consider simulated data with an x-variable and a factor as follows. The factor levels will be termed "A", "B" and "C", but the true effects associated with these levels will be 1, 4 and 2, respectively:
\begin{verbatim} > set.seed(1) > x<-rep(1:4,c(3,3,3,3)) > truvals<-c(1,4,2) > names(truvals)<-c("A","B","C") > w<-rep(truvals,4) > f<-factor(rep(names(truvals),4)) > n<-length(x) > y<-2+0.5*x+w+0.1*w*x+rnorm(n,0,0.1) > dat<-data.frame(y,x,f) \end{verbatim} Having generated the data, we can remove the original variables and just use the data frame.
These simulated data can now be used to test the various R commands and to understand the linear model, analysis of variance tables and so forth. \begin{verbatim} > rm(x,y,f,w) > drop1(lm(y~x+f,data=dat),test="F") > drop1(lm(y~f*x),test="F") > drop1(lm(y~x+f+f:x),test="F") > summary(aov(y~f)) > summary(lm(y~f)) \end{verbatim}