arun
2014-Jan-16 21:34 UTC
[R] extracting rows from data frame that approximately equal another data frame
Hi, May be this helps: x <- data.frame(V1=-1.162877, V2=0.1848928) ?set.seed(245) df <- as.data.frame(matrix(rnorm(5051*2),ncol=2)) ?cut1 <- cut(df[,1],breaks=c(x[,1]-0.1,x[,1]+0.1)) ?cut2 <- cut(df[,2],breaks=c(x[,2]-0.1,x[,2]+0.1)) df1 <- df[!is.na(cut1) & !is.na(cut2),] A.K. I have a dataframe and would like to extract rows that approximately?equal to the values in another data frame. say I have a data frame called x dim(x) [1] 1 2 x ? ? ? ? ? V1 ? ? ? ?V2 x -1.162877 0.1848928 I would like to search through a larger data frame called df and extract all rows that approximately equal the two values in the data frame x by say +- 0.1. The larger dataframe has these dimensions dim(df) [1] 5051 ? ?2