如果第一列V1
不是以“KEGG_”子字符串开始,则将该行的所有内容移动到以“KEGG_”开始的前一行。
move.these.rows <- kegg[!(kegg$V1 %like% "KEGG_"),]
rows.with.kegg <- kegg[kegg$V1 %like% "KEGG_",]
字符串
输入:
> df <- dput(kegg[26:31,1:5])
structure(list(V1 = c("KEGG_SNARE_INTERACTIONS_IN_VESICULAR_TRANSPORT",
"KEGG_LYSOSOME", "CD164", "LIPA", "KEGG_CARDIAC_MUSCLE_CONTRACTION",
"ATP1A3"), V3 = c("STX12", "PLA2G15", "HGSNAT", "AP1M1", "CACNA2D1",
"ATP1A2"), V4 = c("STX2", "AP3B2", "ABCA2", "LAPTM4B", "CACNB1",
"UQCRB"), V5 = c("VAMP5", "GGA1", "DNASE2B", "NAPSA", "COX8A",
"COX6A2"), V6 = c("GOSR2", "SLC11A1", "AGA", "HEXB", "CACNB2",
"SLC9A6")), row.names = 26:31, class = "data.frame")
型
所需输出:
| | V3| V4| V5| V6| V7| V8| V9| V10| V11| V12| V13| V12 | V13 |
| --|--|--|--|--|--|--|--|--|--|--|--|--| ------------ |
| STX12| STX2| VAMP5| GOSR2|||||||||||
| PLA2G15| AP3B2| GGA1| SLC11A1| CD164| HGSNAT| ABCA2| DNASE2B|阿加|AP1M1| LAPTM4B| NAPSA| HEXB| HEXB |
| CACNA2D1| CACNB1| COX8A| CACNB2| ATP1A3| ATP1A2| UQCRB| COX6A2| SLC9A6||||||
2条答案
按热度按时间l2osamch1#
在碱R中:
字符串
在tidyverse中:
型
mm5n2pyu2#
tidyverse
工作流:字符串