Posts Tagged ‘ as.factor ’

Example 9.24: Changing the parameterization for categorical predictors

March 22, 2012
By
Example 9.24: Changing the parameterization for categorical predictors

In our book, we discuss the important question of how to assign different parameterizations to categorical variables when fitting models (section 3.1.3). We show code in R for use in the lm() function, as follows:lm(y ~ x, contrasts=list(x,"contr.trea...

Read more »

Conversion of Several Variables to Factors

December 15, 2011
By
Conversion of Several Variables to Factors

..often needed when preparing data for analysis (and usually forgotten until I need it for the next time).With the below code I convert a set of variables to factors - it could be that there are slicker ways to do it (if you know one let me know!) > da...

Read more »

Example 7.9: Get data from SAS into R

August 8, 2009
By
Example 7.9: Get data from SAS into R

Some people use both SAS and R in their daily work. They might be more familiar with SAS as a tool for manipulating data and R preferable for plotting purposes. While our goal in the book is to enable people to avoid having to switch back and forth, ...

Read more »