Displaying 2 results from an estimated 2 matches for "2a2".
Did you mean:
22
2007 Apr 11
0
Reshape and column order
...ore than one
column it seems to mix up the column headings (or the columns, depending on
how you look at it). For example:
> d <-
data.frame(row=1:2,b.1=c("1b1","2b1"),b.2=c("1b2","2b2"),a.1=c("1a1","2a1"),a.2=c("1a2","2a2"))
> d
row b.1 b.2 a.1 a.2
1 1 1b1 1b2 1a1 1a2
2 2 2b1 2b2 2a1 2a2
If I try reshape on this, the column headings are over the wrong columns:
> reshape(d,direction="long",idvar="row",varying=2:5)
row time b a
1.1 1 1 1a1 1b1
2.1 2 1 2a1 2b1
1.2...
2012 May 06
1
Understanding custom contrasts
I have a question regarding customising contrasts for linear models I
read the section in Fox/Weisberg's CAR (2nd ed.) and was
thinking--apparently erroneously--that the following two snippets
would do the same:
# approach 1: default treatment contrasts
# generate data
set.seed(1111)
y <- c(rnorm(1000, -1), rnorm(1000, 0), rnorm(1000, 1))
x <- factor(rep(letters[1:3], each=1000))
#