我正在尝试使用awk
提取部分模式和完全匹配。部分模式为gene analysis,
,完全匹配为common variant
。提取第1行是因为它具有这两个标准。第4行不是因为它不包含完全匹配。谢谢你:)。
AWK
awk -F'\t' -v OFS="\t" '$2 ~ /^gene analysis,("common variant")$/' file
档案 tab-delimeted
123 this is for gene analysis, common variant
456 xxxx
789 yyyy
111 gene analysis, deletion
所需的输出 tab-delimited
123 this is for gene analysis, common variant
答案 0 :(得分:1)
我的理解是你正在寻找与基因分析,常见变体和#34;的完全匹配。字符串,不需要拆分字符串以匹配部分
library(dplyr)
library(zoo)
time.a = as.Date(c(10:30))
time.b = as.Date(c(20:40))
time.c = as.Date(c(30:50))
value.a = as.numeric(seq(10,30,1))
value.b = as.numeric(seq(20,60,2))
value.c = as.numeric(seq(20,30,.5))
length(time.a)
length(time.b)
length(time.c)
length(value.a)
length(value.b)
length(value.c)
print(time.a)
print(time.b)
print(time.c)
print(value.a)
print(value.b)
print(value.c)
data.a = data.frame(time.a, value.a)
data.b = data.frame(time.b, value.b)
data.c = data.frame(time.c, value.c)
names(data.a) = c("Date", "Value.a")
names(data.b) = c("Date", "Value.b")
names(data.c) = c("Date", "Value.c")
all.data = full_join(data.a, data.b)
all.data = full_join(all.data, data.c)
plot(all.data$Date, all.data$Value.a,
type = "l",
main = "plot",
xlab = "Date",
ylab = "Values")
lines(all.data$Date, all.data$Value.b,
col = "blue")
lines(all.data$Date, all.data$Value.c,
col = "red")