Re: [R] Assigning a larger number of levels to a factor that has fewer levels

2011-04-07 Thread Dimitri Liakhovitski
Thanks a lot, Ista! On Thu, Apr 7, 2011 at 11:52 AM, Ista Zahn wrote: > Hi Dimitri, > The factor() function allows you to specify the levels. So > > small.frame$myfactor <- factor(small.frame$myfactor, levels = > levels(large.frame$myfactor)) > > should do it. > > Best, > Ista > > On Thu, Apr 7,

Re: [R] Assigning a larger number of levels to a factor that has fewer levels

2011-04-07 Thread Ista Zahn
Hi Dimitri, The factor() function allows you to specify the levels. So small.frame$myfactor <- factor(small.frame$myfactor, levels = levels(large.frame$myfactor)) should do it. Best, Ista On Thu, Apr 7, 2011 at 11:47 AM, Dimitri Liakhovitski wrote: > Hello! > > I have larger and a smaller data

[R] Assigning a larger number of levels to a factor that has fewer levels

2011-04-07 Thread Dimitri Liakhovitski
Hello! I have larger and a smaller data frame with 1 factor in each - it's the same factor: large.frame<-data.frame(myfactor=LETTERS[1:10]) small.frame<-data.frame(myfactor=LETTERS[c(9,7,5,3,1)]) levels(large.frame$myfactor) levels(small.frame$myfactor) table(large.frame$myfactor) table(small.fra