Skip to content
Prev 377985 / 398502 Next

Accessing Data Frame

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 == aCard$suit)
deck[-cardNo,]

But I'm still puzzled by the complexity of finding back the index of  
the card with the long statement.

Another approach that "works" is the following, but I still find it  
strange to depend on data frame row names to find the index:
cardNo <- as.numeric(row.names(aCard))

Apologies if the above question are strange. I'm coming C++ world with  
some bias with objects. Again, since "aCard" is extracted from the  
data frame, I assume (bias?) there would be a simple way to find back  
the item in the data frame it came frame. Some kind of indexOf() or  
similar on the container and item.

Benoit

Ista Zahn <istazahn at gmail.com> a ?crit?: