R 从数据帧中的特征向量中提取第二个观测值
从数据帧中的c向量中提取第二个观测值 我有一些数据看起来像:R 从数据帧中的特征向量中提取第二个观测值,r,R,从数据帧中的c向量中提取第二个观测值 我有一些数据看起来像: splitNames 1 , grupo, modelo, s.a.b., de, c.v. 2 , gymboree 3 , cerner 4 , stellus, capital, investment 5 , cambium, learning, gro
splitNames
1 , grupo, modelo, s.a.b., de, c.v.
2 , gymboree
3 , cerner
4 , stellus, capital, investment
5 , cambium, learning, group
6 , cornell, companies
7 , the, boeing
8 , wd-40, co
9 , glencore
10 , the, valspar
我想从数据中提取grupo、金宝贝、cerner、stellus、形成层、康奈尔、wd-40、Glencore和。目前我可以这样做,但它只从数据中提取grupo。y%>%mutatesplitNames[[1][[2]]
数据:
根据您的数据结构,您可以使用:
sapply(data$splitNames, function(x) x[2])
[1] "grupo" "gymboree" "cerner" "stellus" "cambium" "cornell"
[7] "the" "wd-40" "glencore" "the"
根据您的数据结构,您可以使用:
sapply(data$splitNames, function(x) x[2])
[1] "grupo" "gymboree" "cerner" "stellus" "cambium" "cornell"
[7] "the" "wd-40" "glencore" "the"
既然您正在使用Tidyverse,您也可以这样做: 图书馆咕噜声 map_chrdata$splitNames,2 >[1]grupo金宝贝cerner stellus形成层康奈尔 >[7]wd-40嘉能可
由v0.3.0于2020年7月14日创建,由于您正在使用Tidyverse,因此您也可以通过以下方式完成: 图书馆咕噜声 map_chrdata$splitNames,2 >[1]grupo金宝贝cerner stellus形成层康奈尔 >[7]wd-40嘉能可 由v0.3.0于2020年7月14日创建,我们可以使用[无匿名功能]
sapply(data$splitNames, `[`, 2)
#[1] "grupo" "gymboree" "cerner" "stellus" "cambium" "cornell" "the" "wd-40" "glencore" "the"
我们可以使用[没有匿名函数]
sapply(data$splitNames, `[`, 2)
#[1] "grupo" "gymboree" "cerner" "stellus" "cambium" "cornell" "the" "wd-40" "glencore" "the"