Hi, I have two dataframes (Dataframe_A, Dataframe_B) with the same no. of columns. The first column of both the dataframes contains unique names. I wish to have Dataframe_A with the rows that are NOT common to Dataframe_B. With merge (), it is possible to get the common rows or to merge rows, but I am not quite sure how to do it in a simpler way. Any help would be much appreciated. Thank you. Cheers, Chintanu [[alternative HTML version deleted]]
Le lundi 24 septembre 2012 ? 13:22 +1000, Chintanu a ?crit :> Hi, > > I have two dataframes (Dataframe_A, Dataframe_B) with the same no. of > columns. The first column of both the dataframes contains unique names. > I wish to have Dataframe_A with the rows that are NOT common to > Dataframe_B.So you just want to drop some rows from A? In that case, do: Dataframe_A <- Dataframe_A[!Dataframe_A[[1]] %in% Dataframe_B[[2]],]> With merge (), it is possible to get the common rows or to merge rows, but > I am not quite sure how to do it in a simpler way. Any help would be much > appreciated.No need for merge, as all rows you need are already in A. My two cents
Hello, See also ?setdiff Hope this helps, Rui Barradas Em 24-09-2012 08:30, Milan Bouchet-Valat escreveu:> Le lundi 24 septembre 2012 ? 13:22 +1000, Chintanu a ?crit : >> Hi, >> >> I have two dataframes (Dataframe_A, Dataframe_B) with the same no. of >> columns. The first column of both the dataframes contains unique names. >> I wish to have Dataframe_A with the rows that are NOT common to >> Dataframe_B. > So you just want to drop some rows from A? In that case, do: > Dataframe_A <- Dataframe_A[!Dataframe_A[[1]] %in% Dataframe_B[[2]],] > >> With merge (), it is possible to get the common rows or to merge rows, but >> I am not quite sure how to do it in a simpler way. Any help would be much >> appreciated. > No need for merge, as all rows you need are already in A. > > > My two cents > > ______________________________________________ > R-help at r-project.org mailing list > 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.