Possible Duplicate:
Existing function for seeing if a row exists in a data frame?
Suppose I have the following data frame in R.
df = data.frame('a'=c(1:3), 'b'=c(4:6))
This data frame contains three rows: (1,4), (2,5) and (3,6)
. Suppose I did not know which rows df
contains and wanted to check whether a row (1,4) belongs to it, how can I check that?
My actual case involves comparison of 27 parameter values. Is there a solution in which I can do this without typing each and every parameter name? Thanks!
The reason I want to do this is that I have an R dataset called masterdata
which contains simulation data. I want to update this data set with new data that is obtained as I make additional simulation runs with different parameter combinations. It is possible, however, that I may forget that I have run the simulation for a certain parameter combination and may run it again, in which case, the masterdata
will be expanded with duplicate values. I can later go and remove these duplicate values, but I would not want the whole process of updating the data set to go through if the values are duplicate. For this I need to check if the data from a simulation run is already present in the masterdata
. I can do this if I know how to check whether a given row belongs to the masterdata
.
Thanks.