Hi,
Try:
A <- as.data.frame(matrix(1:20,byrow=TRUE,ncol=4))
B <- as.data.frame(matrix(21:40,byrow=TRUE,ncol=4))
AB <- rbind(A,B)
#if the ?row.names of both datasets are from 1:nrow(dataset)
AB1 <- AB[order(as.numeric(c(row.names(A),row.names(B,]
#or
AB2 <- AB[c(matrix(seq(dim(AB)[1]),nrow=2,b
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1
On 12/05/13, 16:37 , arun wrote:
> Hi, Try ?join()
>
> library(plyr)
Well - what would we do without Hadley ...
He solved many problems we didn't know we would have soon...
Cheers,
Rainer
> y$ref <- y$id
>> join(x,y,by="ref")
> ref id val 1 N
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1
On 12/05/13, 16:11 , Sarah Goslee wrote:
> Adding the argument all.x=TRUE to merge() will retain the NA
> values, but the only reliable way I've found to preserve order with
> NA values in a merge is to add an index column to x, merge the
> data, sort
Hi,
Try ?join()
library(plyr)
y$ref <- y$id
> join(x,y,by="ref")
ref id val
1 NA NA NA
2 NA NA NA
3 NA NA NA
4 10 NA NA
5 9 9 106
6 8 8 107
7 7 7 105
8 6 6 104
9 5 NA NA
10 NA NA NA
11 1 NA NA
12 2 2 101
13 3 3 102
14 4 4 103
15 5 NA NA
A.K.
Adding the argument all.x=TRUE to merge() will retain the NA values,
but the only reliable way I've found to preserve order with NA values
in a merge is to add an index column to x, merge the data, sort on the
index column, then delete it.
Sarah
On Thu, Dec 5, 2013 at 9:56 AM, Rainer M Krug wrot
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1
Hi
My brain is giving up on this...
I have the following two data.frames:
x <- data.frame(ref=c(NA, NA, NA, 10:5, NA, 1:5))
y <- data.frame(id = c(2, 3, 4, 6, 7, 9, 8), val = 101:107)
Which look as follow:
> x
ref
1 NA
2 NA
3 NA
4
Peterso wrote
>
> Uwe:
>
> I was actually trying to stack one table on top of the other. All column
> names are the same except for the Part1 and Part 2. My final table should
> look like the table below. Maybe it is possible to change the names of
> Part1 and Part 2 to Part?
>
> A B C Part
>
I guess you just want one data.frame with the columns part1 and part2?
Then:
merge(part1, part2)
should do thr trick.
If you aim at something different, please explain you expected result.
Uwe Ligges
On 14.04.2012 01:33, Johnny Liseth wrote:
I am trying to merge two data frames, but one of t
I am trying to merge two data frames, but one of the column headings are
different in the two frames. How can I rjoin or rbind the tho frames?
Johnny
# Generate 2 blocks by confounding on abc
d1 <- conf.design(c(1,1,1), p=2, block.name="blk", treatment.names =
c("A","B","C"))
d2 <- conf.design(c(
Thomas,
You are very clever! The "meil2" data frame has twice the common variable
combinations:
> meil2
dist sexe style meil
138F clas 02:43:17
238F free 02:24:46
338H clas 02:37:36
438H free 01:59:35
545F clas 03:46:15
645F free 02:20
On Fri, 8 May 2009, Rock Ouimet wrote:
I am new to R (ex SAS user) , and I cannot merge two data frames without
getting duplicated rows in the results. How to avoid this happening without
using the unique() function?
1. First data frame is called "tmv" with 6 variables and 239 rows:
tmv[1:10,
I am new to R (ex SAS user) , and I cannot merge two data frames without
getting duplicated rows in the results. How to avoid this happening without
using the unique() function?
1. First data frame is called "tmv" with 6 variables and 239 rows:
> tmv[1:10,]
temps nomprenom sex
12 matches
Mail list logo