Have a look at anti_join() from the dplyr package. It does exactly
what you want. Here is an example based on the code of Robin
Table_A <- as.data.frame(Table_A, stringsAsFactors = FALSE)That is
Table_B <- as.data.frame(Table_B, stringsAsFactors = FALSE)
library(dplyr)
anti_join(Table_A, Table_B,
Hi,
I'll coded your example into R code:
Table_A <- c('a...@gmail.com', 'John Chan', '0909')
Table_A <- rbind(Table_A, c('b...@yahoo.com', 'Tim Ma', '89089'))
colnames(Table_A) <- c('Email', 'Name', 'Phone')
Table_A
Table_B <- c('a...@gmail.com', 'John Chan', 'M', '0909')
Table_B <- rbind(Table_
Thanks - Peter, Eivind, Rui
Sorry, I perhaps could not explain it properly in the first go.
Trying to simplify it here with an example - Say I have two dataframes as
below that are NOT equally-sized data frames (i.e., number of columns are
different in each table):
Table_A:
Email
...@r-project.org<mailto:r-help@r-project.org>t 9:05
PM
Subject: Re: [R] Merging dataframes
To: Rui Barradas mailto:ruipbarra...@sapo.pt>>
Cc: Chintanu mailto:chint...@gmail.com>>, R help
mailto:r-help@r-project.org>>
I'd expect more like
setdiff(A$key, B$key)
and
On Tue, 1 May 2018, Chintanu wrote:
Hi,
May I please ask how I do the following in R. Sorry - this may be trivial,
but I am struggling here for this.
For two dataframes (A and B), I wish to identify (based on a primary
key-column present in both A & B) -
1. Which records (rows) of A did no
I'd expect more like
setdiff(A$key, B$key)
and vice versa. Or, if you want the actual rows
A[!(A$key %in% B$key),]
or for the row numbers
which(!(A$key %in% B$key))
-pd
> On 1 May 2018, at 12:48 , Rui Barradas wrote:
>
> Hello,
>
> Is it something like this that you want?
>
> x <- d
Hello,
Is it something like this that you want?
x <- data.frame(a = c(1:3, 5, 5:10), b = c(1:7, 7, 9:10))
y <- data.frame(a = 1:10, b = 1:10)
which(x != y, arr.ind = TRUE)
Hope this helps,
Rui Barradas
On 5/1/2018 11:35 AM, Chintanu wrote:
Hi,
May I please ask how I do the following in R
Hi,
May I please ask how I do the following in R. Sorry - this may be trivial,
but I am struggling here for this.
For two dataframes (A and B), I wish to identify (based on a primary
key-column present in both A & B) -
1. Which records (rows) of A did not match with B, and
2. Which records
I would probably do it this way,
tmp <- list(data.frame(name="sample1", red=20),
data.frame(name="sample1", green=15),
data.frame(name="sample2", red=10),
data.frame(name="sample2", green=30))
fun1 <- function(df) data.frame(name=df$name, color=names(df)[2],
va
Here is how you can to it with tidyr:
> x <- list(data.frame(name="sample1", red=20)
+ , data.frame(name="sample1", green=15)
+ , data.frame(name="sample2", red=10)
+ , data.frame(name="sample2", green=30)
+ )
> library(dplyr)
> library(tidyr)
>
> # convert to 'name, type, value';
Thanks, ldply got me a data frame straight away. But it filled empty
spaces with NA and merge no longer works.
> ldply(mylist)
name red green
1 sample1 20NA
2 sample1 NA15
3 sample2 10NA
4 sample2 NA30
> mydf <- ldply(mylist)
> merge(mydf[1,],mydf[2,])
[1] name red gre
Hello,
Sorry, forget my first answer, I misunderstood what you wanted.
Let's try again.
First of all you have a typo in your second sample2, you wrote 'sample
2' with a space.
Now try this.
fun2 <- function(n){
merge(lst[[n]], lst[[n + 1]])
}
N <- which(seq_along(lst) %% 2 == 1)
lst2 <- l
You can use ldply in the plyr package to bind all the data.frames together
(a regular loop will also work). Afterwards you can summarise using ddply
Hope this helps
Ulrik
Ed Siefker schrieb am Fr., 3. Juni 2016 21:10:
> aggregate isn't really what I want. Maybe tapply? I still can't get
> it
Hello,
Maybe something like the following.
lst <-
list(data.frame(name="sample1", red=20), data.frame(name="sample1",
green=15), data.frame(name="sample2", red=10), data.frame(name="sample
2", green=30))
fun <- function(DF){
data.frame(name = DF[, 1], color = colnames(DF)[2], colnum = DF
aggregate isn't really what I want. Maybe tapply? I still can't get
it to work.
> length(mylist)
[1] 4
> length(names)
[1] 4
> tapply(mylist, names, merge)
Error in tapply(mylist, names, merge) : arguments must have same length
I guess because a list isn't an atomic data type. What function wi
I manually constructed the list of sample names and tried the
aggregate call I mentioned.
Merge works when called manually, but not when using aggregate.
> mylist <- list(data.frame(name="sample1", red=20), data.frame(name="sample1",
> green=15), data.frame(name="sample2", red=10), data.frame(na
I have a list of data as follows.
> list(data.frame(name="sample1", red=20), data.frame(name="sample1",
> green=15), data.frame(name="sample2", red=10), data.frame(name="sample 2",
> green=30))
[[1]]
name red
1 sample1 20
[[2]]
name green
1 sample115
[[3]]
name red
1 sample
See ?rbind.fill in the plyr package.
On Wed, Oct 7, 2009 at 9:32 AM, christiaan pauw wrote:
> Hallo Everyone
> I have the kind of problem that one should never have because one must
> always plan well and communicate with your team. But now I haven't so here
> is my problem.
>
> I have data comin
Hallo Everyone
I have the kind of problem that one should never have because one must
always plan well and communicate with your team. But now I haven't so here
is my problem.
I have data coming in on a daily basis from surveys in 10 towns. The
questionnaire has 62 variables but some of the region
19 matches
Mail list logo