Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/72.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
R-在我的数据框中创建一列,该列包含每个列表(在列表对象列表中)的名称(基于彼此之间的重叠)_R - Fatal编程技术网

R-在我的数据框中创建一列,该列包含每个列表(在列表对象列表中)的名称(基于彼此之间的重叠)

R-在我的数据框中创建一列,该列包含每个列表(在列表对象列表中)的名称(基于彼此之间的重叠),r,R,我有一个数据帧(df3)和一个列表列表(l3): 如果我们将列表堆叠到一个两列data.frame中,然后执行合并(在基本R) 或者使用tidyverse,enframe将列表添加到两列tibble,取消最新列表列并进行连接 library(tibble) library(dplyr) library(tidyr) enframe(l3, value = 'geneSet', name= 'cluster') %>% unnest(c(geneSet)) %>%

我有一个数据帧(df3)和一个列表列表(l3):


如果我们
列表
堆叠到一个两列data.frame中,然后执行
合并
(在
基本R


或者使用
tidyverse
enframe
列表
添加到两列
tibble
取消最新
列表
列并进行连接

library(tibble)
library(dplyr)
library(tidyr)
enframe(l3, value = 'geneSet', name= 'cluster') %>% 
     unnest(c(geneSet)) %>%
     right_join(df3)
df1 <- structure(list(geneSet = c("GO:0070848", "GO:0071363", "GO:0007169", 
                    "GO:0007167"), description = c("response to growth factor", "cellular response to growth factor stimulus", 
                     "transmembrane receptor protein tyrosine kinase signaling pathway", 
                     "enzyme linked receptor protein signaling pathway")), row.names = c(10L, 
                     16L, 177L, 219L), class = "data.frame")

df2 <- structure(list(geneSet = c("GO:0070647", "GO:0016567", "GO:0032446"
), description = c("protein modification by small protein conjugation or removal", 
                   "protein ubiquitination", "protein modification by small protein conjugation"
)), row.names = c(13L, 15L, 25L), class = "data.frame")
df3 <- rbind(df1,df2)
######################print my dataframe
> df3
       geneSet                                                      description
10  GO:0070848                                        response to growth factor
16  GO:0071363                      cellular response to growth factor stimulus
177 GO:0007169 transmembrane receptor protein tyrosine kinase signaling pathway
219 GO:0007167                 enzyme linked receptor protein signaling pathway
13  GO:0070647     protein modification by small protein conjugation or removal
15  GO:0016567                                           protein ubiquitination
25  GO:0032446                protein modification by small protein conjugation
> df3
       geneSet                                                      description cluster
10  GO:0070848                                        response to growth factor  GROUP1
16  GO:0071363                      cellular response to growth factor stimulus  GROUP1
177 GO:0007169 transmembrane receptor protein tyrosine kinase signaling pathway  GROUP1
219 GO:0007167                 enzyme linked receptor protein signaling pathway  GROUP1
13  GO:0070647     protein modification by small protein conjugation or removal  GROUP2
15  GO:0016567                                           protein ubiquitination  GROUP2
25  GO:0032446                protein modification by small protein conjugation  GROUP2
merge(df3, stack(l3), by.x = 'geneSet', by.y = 'values')
library(tibble)
library(dplyr)
library(tidyr)
enframe(l3, value = 'geneSet', name= 'cluster') %>% 
     unnest(c(geneSet)) %>%
     right_join(df3)