r - Eliminate in an increasing order rows in a data frame -


eliminate in increasing order rows in data frame

x<-c(4,5,6,23,5,6,7,8,0,3) y<-c(2,4,5,6,23,5,6,7,8,0) z<-c(1,2,4,5,6,23,5,6,7,8)  df<-data.frame(x,y,z)    df     x  y  z 1   4  2  1 2   5  4  2 3   6  5  4 4  23  6  5 5   5 23  6 6   6  5 23 7   7  6  5 8   8  7  6 9   0  8  7 10  3  0  8 

i eliminate number 23 in df columns instructing sequentially increasingly remove row per column (not matching value 23, initial x location).

df     x  y  z 1   4  2  1 2   5  4  2 3   6  5  4 4   5  6  5 5   6  5  6 6   7  6  5 7   8  7  6 8   0  8  7 9   3  0  8 

thank

you try:

  n <- 4   df1 <- df[-n,]   df1[] <- unlist(df,use.names=false)[-seq(n, prod(dim(df)), by=nrow(df)+1)]    df1    #   x y z    #1  4 2 1    #2  5 4 2    #3  6 5 4    #5  5 6 5    #6  6 5 6    #7  7 6 5    #8  8 7 6    #9  0 8 7    #10 3 0 8 

Comments

Popular posts from this blog

java - How to specify maven bin in eclipse maven plugin? -

single sign on - Logging into Plone site with credentials passed through HTTP -

php - Why does AJAX not process login form? -