Here is another approach that uses only the default packages:
> onecar <- mtcars[10,]
> w <- which(duplicated(rbind(mtcars,onecar), fromLast = TRUE))
> w
[1] 10
> mtcars.subset <- mtcars[-w,]
>
>
> threecars <- mtcars[c(1,10,15),]
> w <- which(duplicated(rbind(mtcars,threecars), fromLast=TRUE))
>
I do not know how you define "quick way," but as there is an "==" method
for data frames (see ?"==" and links therein for details), that allows the
straightforward use of basic R functionality:
## using your 'deck' and 'topCard' examples:
> deck [ apply(deck == topCard[rep(1,nrow(deck)), ],1, all
AFAIK the intent of the designers of the data frame class was that rownames be
unique and be useful for tracking the origins of records in data subsets.
However, after a few merging operations the traceability becomes murky anyway
and relational set theory avoids them. Neither data.table nor dpl
Many thanks everyone for the rich feedback. Very impressive. I will
digest all the information received and continue on my learning around
R.
Benoit
Duncan Murdoch a écrit :
On 03/01/2019 12:39 p.m., Benoit Galarneau wrote:
Thanks for the feedback.
Point taken about the data.table package
On 03/01/2019 12:39 p.m., Benoit Galarneau wrote:
Thanks for the feedback.
Point taken about the data.table package, I will take a look for sure.
As I am new to the R programming, I'm exploring with the default
libraries as a start.
I have various options that works like this one:
topCard <- de
On 03/01/2019 12:39 p.m., Benoit Galarneau wrote:
Thanks for the feedback.
Point taken about the data.table package, I will take a look for sure.
As I am new to the R programming, I'm exploring with the default
libraries as a start.
I have various options that works like this one:
topCard <- de
See below.
> On Jan 3, 2019, at 6:50 AM, Benoit Galarneau
> wrote:
>
> Hi everyone,
> I'm new to the R world.
> Probably a newbie question but I am stuck with some concept with data frame.
> I am following some examples in the "Hands-On Programming with R".
>
> In short, how can I access/filte
Thanks for the feedback.
Point taken about the data.table package, I will take a look for sure.
As I am new to the R programming, I'm exploring with the default
libraries as a start.
I have various options that works like this one:
topCard <- deck[1,]
#Remove card from deck using row name
d
You would be better served to reference SQL semantics (relational identity)
than Network database semantics (object identifiers) for understanding data
frames. The row in `aCard` is not the same as the row in `deck`, and you should
not construct your algorithms based on individual rows but rathe
>In my programmer's head, something similar to this should "work": ...
> deck[aCard]
There are some people who agree with you... see the data.table package, which
can be made to behave like this.
Keep in mind that the aCard data frame in general may have a different set of
column names or more
You are correct, the anti_join is working fine.
However, I still find it strange there is no "quick" way to find the
index of an item extracted from the data frame.
This works as it returns the deck without the card no 10.
aCard = deck[10,]
cardNo = which(deck$value == aCard$value & deck$suit
Hi Benoit,
You can select rows from deck matched in aCard using
merge(deck, aCard)
Selecting rows that don't match is bit more difficult. You could do
something like
isin <- apply(mapply(function(x, y) x %in% y, deck, topCard),
1,
all)
deck[!isin, ]
perhaps.
Alte
Hello,
Inline.
Às 14:50 de 03/01/2019, Benoit Galarneau escreveu:
Hi everyone,
I'm new to the R world.
Probably a newbie question but I am stuck with some concept with data
frame.
I am following some examples in the "Hands-On Programming with R".
In short, how can I access/filter items in a
Hi everyone,
I'm new to the R world.
Probably a newbie question but I am stuck with some concept with data frame.
I am following some examples in the "Hands-On Programming with R".
In short, how can I access/filter items in a data frame using a variable.
One example consists of manipulating elem
14 matches
Mail list logo