[R] Is this kind of removing of elements from data.frame (in)efficient?
mviljamaa
mviljamaa at kapsi.fi
Tue Sep 13 09:37:18 CEST 2016
So I'm a beginner in R and I was testing the removal of elements from a
data.frame.
The way I remove the element(s) with the minimum value in kid_score
variable is to do:
kidmomhs <- data[kidmomhs$kid_score != min(kidmomhs$kid_score),]
So now kidmomhs is the same data, but without the row(s) with the
minimum value of kid_score.
Judging by the syntax this looks as if R might be creating a copy of the
data array, just without the rows that were removed.
The question however is, is this the most efficient way to remove
elements from data structures in R? And is the above inefficient? Does
the above create copies of almost the entire data structure?
In other programming languages I've become accustomed to doing removal
of elements by changing them to NULL and then e.g. reordering the data
structure. Rather than having to take copies of almost the entire data
structure.
More information about the R-help
mailing list