On Mon, 25 Sep 2006, Bruce LaZerte wrote:
> # R version 2.3.1 (2006-06-01) Debian Linux "testing"
>
> # Is the following behaviour a bug, feature or just a lack of
> # understanding on my part? I see that this was discussed here
> # last March with no apparent resolution.
Reference? It is the th
If you want it to act like a date store it as a Date:
dx <- as.Date(c("1970-04-04","1970-08-11","1970-10-18")) ###
x <- c(9,10,11)
ch <- data.frame(Date=dx,X=x)
dy <- as.Date(c("1970-06-04","1970-08-11","1970-08-18")) ###
y <- c(109,110,111)
sp <- data.frame(Date=dy,Y=y)
merge(ch, sp, all = TRUE
# R version 2.3.1 (2006-06-01) Debian Linux "testing"
# Is the following behaviour a bug, feature or just a lack of
# understanding on my part? I see that this was discussed here
# last March with no apparent resolution.
d <- as.factor(c("1970-04-04","1970-08-11","1970-10-18"))
x <- c(9,10,11)
ch
From: Sean Davis
>
> On 4/6/06 8:04 AM, "Sumanta Basak" <[EMAIL PROTECTED]> wrote:
>
> > Hi All,
> >
> >
> >
> > I have certain combinations for which I have some value, e.g.
> >
> >
> >
> > 0 1 20
> >
> > 0 2 15
> >
> > 1 1 40
> >
> > 1 2 52
> >
> >
> >
On 4/6/06 8:04 AM, "Sumanta Basak" <[EMAIL PROTECTED]> wrote:
> Hi All,
>
>
>
> I have certain combinations for which I have some value, e.g.
>
>
>
> 0 1 20
>
> 0 2 15
>
> 1 1 40
>
> 1 2 52
>
>
>
> Now I need to sort this list for which I'll get the c
Hi All,
I have certain combinations for which I have some value, e.g.
0 1 20
0 2 15
1 1 40
1 2 52
Now I need to sort this list for which I'll get the combination against the
lowest value. In this case, 15, and the combination will be 0 2.
--
SUMANTA B
One other idea; one could use match instead of merge:
> # tmp1a and tmp2a from below
> cbind(tmp1a, tmp2a[match(tmp1a$col1, tmp2a$col1), -1, drop = FALSE])
col1 col2
1A NA
2A NA
3C1
4C1
50 NA
60 NA
This avoids having to muck with reordering of rows and res
Sorry, I mixed up out and outa in the last post. Here it is correctly.
> levs <- c(LETTERS[1:6], "0")
> tmp1a <- data.frame(col1 = factor(c("A", "A", "C", "C", "0", "0"), levs))
> tmp2a <- data.frame(col1 = factor(c("C", "D", "E", "F"), levs), col2 = 1:4)
>
> out <- merge( cbind(tmp1a, seq = 1:nr
On 3/6/06, Gregor Gorjanc <[EMAIL PROTECTED]> wrote:
>
> But I want to get out
>
> A NA
> A NA
> C 1
> C 1
> 0 NA
> 0 NA
>
That's what I get except for the rownames. Be sure to
make the factor levels consistent. I have renamed the data frames
tmp1a and tmp2a to distinguish them from the ones in
Gabor and Jean thank you for your time and answers. Gabors approach does
not do what I want (with or without sort). Gabor note that when we merge
data.frame, this new data.frame gets new row.names and we can not be
consistent with sort.
> out <- merge(cbind(tmp1, seq = 1:nrow(tmp1)), tmp2, all.x =
Actually we don't need sort = FALSE if we are reordering it anyways:
out <- merge( cbind(tmp1, seq = 1:nrow(tmp1)), tmp2, all.x = TRUE)
out[out$seq, -2]
On 3/6/06, Gabor Grothendieck <[EMAIL PROTECTED]> wrote:
> I think you will need to reorder it:
>
> out <- merge( cbind(tmp1, seq = 1:nrow(tmp1)
I think you will need to reorder it:
out <- merge( cbind(tmp1, seq = 1:nrow(tmp1)), tmp2, all.x = TRUE, sort = FALSE)
out[out$seq, -2]
On 3/6/06, Gregor Gorjanc <[EMAIL PROTECTED]> wrote:
> Gabor Grothendieck wrote:
> > If you make the levels the same does that give what you want:
> >
> > levs
If believe that merge is trying to put first whatever cells that are
nonempty. For example if you instead did
> tmp2 <- data.frame(col1 = factor(c("C", "D", "E", "F","A"), levs),
col2 = 1:5)
> tmp2
col1 col2
1C1
2D2
3E3
4F4
5A5
> merge(tmp2, tmp1, al
Gabor Grothendieck wrote:
> If you make the levels the same does that give what you want:
>
> levs <- c(LETTERS[1:6], "0")
> tmp1 <- data.frame(col1 = factor(c("A", "A", "C", "C", "0", "0"), levs))
> tmp2 <- data.frame(col1 = factor(c("C", "D", "E", "F"), levs), col2 = 1:4)
> merge(tmp2, tmp1, all
If you make the levels the same does that give what you want:
levs <- c(LETTERS[1:6], "0")
tmp1 <- data.frame(col1 = factor(c("A", "A", "C", "C", "0", "0"), levs))
tmp2 <- data.frame(col1 = factor(c("C", "D", "E", "F"), levs), col2 = 1:4)
merge(tmp2, tmp1, all = TRUE, sort = FALSE)
merge(tmp1, tmp
Hello!
I am merging two datasets and I have encountered a problem with sort.
Can someone please point me to my error. Here is the example.
## I have dataframes, first one with factor and second one with factor
## and integer
> tmp1 <- data.frame(col1 = factor(c("A", "A", "C", "C", "0", "0")))
> t
16 matches
Mail list logo