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.

______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to