No. You need to test more carefully.
a - factor(c(1,3,5))
b - factor(c(5,7))
c(a,b)
[1] 1 2 3 1 2
lev - sort(unique(f - c(a,b)))
f - factor(f,levels=lev)
f
[1] 1 2 3 1 2
Levels: 1 2 3
## but
unlist(list(a,b),use.names=FALSE)
[1] 1 3 5 5 7
Levels: 1 3 5 7
However, Is level 5 in 'a' the
Thank you for clarifying, Dr. Gunter. My bad.
Regards,
Jorge.-
On Thu, Oct 18, 2012 at 5:21 PM, Bert Gunter gunter.ber...@gene.com wrote:
No. You need to test more carefully.
a - factor(c(1,3,5))
b - factor(c(5,7))
c(a,b)
[1] 1 2 3 1 2
lev - sort(unique(f - c(a,b)))
f -
jorgeivanve...@gmail.com
Cc: r-help@r-project.org; s...@gnu.org
Sent: Thursday, October 18, 2012 2:21 AM
Subject: Re: [R] how to concatenate factor vectors?
No. You need to test more carefully.
a - factor(c(1,3,5))
b - factor(c(5,7))
c(a,b)
[1] 1 2 3 1 2
lev - sort(unique(f - c(a,b)))
f
* Bert Gunter thagre.ore...@trar.pbz [2012-10-17 23:21:44 -0700]:
However, Is level 5 in 'a' the same as level 5 in 'b' ?
yes, of course.
would anyone want to _different_ factors with identical string representations?!
--
Sam Steingold (http://sds.podval.org/) on Ubuntu 12.04 (precise) X
mood - factor(c(blue, sunny))
skycolor - factor(c(azure,blue,teal)
If factors are not defined with levels specifications, automatic merging should
never be allowed. The fact that read.table automatically generates factors
using default levels is why I nearly always import using as.is=TRUE,
On Thursday, October 18, 2012, Sam Steingold wrote:
* Bert Gunter thagre.ore...@trar.pbz [2012-10-17 23:21:44 -0700]:
However, Is level 5 in 'a' the same as level 5 in 'b' ?
yes, of course.
would anyone want to _different_ factors with identical string
representations?!
Off the cuff,
hi Jorge,
* Jorge I Velez wbetrvinair...@tznvy.pbz [2012-10-18 16:43:58 +1100]:
a - factor(5:1,levels=1:9)
b - factor(9:1,levels=1:9)
lev - sort(unique(f - c(a, b)))
f - factor(f, levels = lev)
str(f)
Factor w/ 9 levels 1,2,3,4,..: 5 4 3 2 1 9 8 7 6 5 ...
is sort(unique()) really
* R. Michael Weylandt zvpunry.jrlyn...@tznvy.pbz [2012-10-18 16:01:37
+0100]:
On Thursday, October 18, 2012, Sam Steingold wrote:
* Bert Gunter thagre.ore...@trar.pbz [2012-10-17 23:21:44 -0700]:
However, Is level 5 in 'a' the same as level 5 in 'b' ?
yes, of course.
would anyone
* Jeff Newmiller wqarj...@qpa.qnivf.pn.hf [2012-10-18 07:53:24 -0700]:
If you HAVE defined your factors using explicit levels definitions, you
should have no trouble combining them.
http://article.gmane.org/gmane.comp.lang.r.general:277719
--
Sam Steingold (http://sds.podval.org/) on Ubuntu
-project.org] On
Behalf
Of Sam Steingold
Sent: Thursday, October 18, 2012 8:02 AM
To: r-help@r-project.org; Jorge I Velez
Subject: Re: [R] how to concatenate factor vectors?
hi Jorge,
* Jorge I Velez wbetrvinair...@tznvy.pbz [2012-10-18 16:43:58 +1100]:
a - factor(5:1,levels=1:9)
b
* William Dunlap jqha...@gvopb.pbz [2012-10-18 15:33:38 +]:
c() has an unfortunate history.
:-)
ISTR reading in the R manual ~15(?) years ago that the language was in a
flux and one could not expect code written for the current release to
work in the next release. I was considering R as
On Thu, Oct 18, 2012 at 4:20 PM, Sam Steingold s...@gnu.org wrote:
* R. Michael Weylandt zvpunry.jrlyn...@tznvy.pbz [2012-10-18 16:01:37
+0100]:
On Thursday, October 18, 2012, Sam Steingold wrote:
* Bert Gunter thagre.ore...@trar.pbz [2012-10-17 23:21:44 -0700]:
However, Is level 5 in
How do I concatenate two vectors of factors?
--8---cut here---start-8---
a - factor(5:1,levels=1:9)
b - factor(9:1,levels=1:9)
str(c(a,b))
int [1:14] 5 4 3 2 1 9 8 7 6 5 ...
str(unlist(list(a,b),use.names=FALSE))
Factor w/ 9 levels 1,2,3,4,..: 5 4 3 2 1 9
Hi Sam,
Perhaps the following?
a - factor(5:1,levels=1:9)
b - factor(9:1,levels=1:9)
lev - sort(unique(f - c(a, b)))
f - factor(f, levels = lev)
str(f)
Factor w/ 9 levels 1,2,3,4,..: 5 4 3 2 1 9 8 7 6 5 ...
HTH,
Jorge.-
On Thu, Oct 18, 2012 at 3:44 PM, Sam Steingold wrote:
How do I
14 matches
Mail list logo