Re: [問題] 撈資料

看板R_Language作者時間10年前 (2014/08/21 21:00), 10年前編輯推噓0(001)
留言1則, 1人參與, 最新討論串7/7 (看更多)
Make anything what you need clean. reference: #1JlmgrEG (R_Language) #1JrRu6ay (R_Language) x = data.frame( "gene_a" = c("A", "B", "C"), "Chromosome" = c("1", "X", "2"), "gene_start" = as.integer(c(25000, 1000, 0)), "gene_end" = as.integer(c(50000, 2000, 800)), stringsAsFactors = FALSE ) y = data.frame( "Probe_b" = c("a1", "a2", "a3", "a4", "a5"), "Chromosome2" = c("2", "4", "1", "X", "1"), "Chr_s" = as.integer(c(175, 600, 23575, 1010, 30000)), "Chr_e" = as.integer(c(200, 625, 23600, 1035, 30025)), stringsAsFactors = FALSE ) x_merge_y = merge( x, y, by.x = "Chromosome", by.y = "Chromosome2" ) condition = ( x_merge_y$gene_start <= x_merge_y$Chr_s ) & ( x_merge_y$Chr_e <= x_merge_y$gene_end ) output = x_merge_y[condition, c("gene_a", "Probe_b")] order_index = order(output$gene_a) output[order_index, ] -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 119.14.64.43 ※ 文章網址: http://www.ptt.cc/bbs/R_Language/M.1408626055.A.30B.html ※ 編輯: HeroNoah (119.14.64.43), 08/21/2014 21:07:37

08/21 21:35, , 1F
高招,這幾篇中,效率最高的方法!
08/21 21:35, 1F
文章代碼(AID): #1JzUs7CB (R_Language)
討論串 (同標題文章)
文章代碼(AID): #1JzUs7CB (R_Language)