如果col A有子串,则绘制图

时间:2011-09-30 20:38:54

标签: gnuplot

我需要在gnuplot中执行此操作:

plot 1:4 where col 2=="P1", col 3=="3", col 1 has substring "blur1"

下载数据集:

col_1          col_2        col_3    col_4
gcc.blur1.O0   P1           3        10.5
icc.blur1.O2   P2           5        9.8
gcc.blur2.O3   P2           3        8.9

提前致谢。

3 个答案:

答案 0 :(得分:5)

AFAIK您需要使用外部脚本来检查子字符串。像awk和使用

之类的东西
plot "< awk '{...awk commands...}' input.dat"

如果您只想测试P1的col_2,可以通过

在gnuplot中进行测试
f(x,y)= (x eq "P1"? y : 1/0)

plot "input.dat" u 3:(f(strcol(2),$4))

strcol(n)将第n列作为字符串。 “eq”可用于比较字符串。

答案 1 :(得分:0)

如果您事先知道子字符串的确切位置,则可以尝试检查该部分的相等性,如下所示:

strcol(1)[5:9] eq 'blur1'

ps .:这是一些在gnuplot中处理字符串的方便示例:
http://gnuplot.sourceforge.net/demo/stringvar.html

答案 2 :(得分:0)

可以使用gnuplot的<f:fields> <Label visible="{= ${Data>/name} === 'firstScreen' &amp;&amp; !!${Data>/online/value} }" text="{i18n>label}"/> <Text visible="{= ${Data>/name} === 'firstScreen' &amp;&amp; !!${Data>/online/value} }" text="{=${Data>/online/value}}"/> </f:fields> 函数进行简单的检查。它返回找到的第一个字符的索引;如果未找到子字符串,则返回0:

require(openxlsx)
available_dfs<- ls()[sapply(ls(), function(x) is.data.frame(get(x)))]

list_of_datasets <- list("Name of DataSheet1" = dataframe1, "Name of Datasheet2" = dataframe2)
write.xlsx(list_of_datasets, file = "writeXLSX2.xlsx")

因此,您的plot命令看起来像

 var uniqueId = new mongoose.mongo.ObjectId();
    uniqueId = uniqueId.toString(); //Convert to string type
    var key = 'pictures.' + uniqueId; // if key is constant we can directly add that.

 User.findOneAndUpdate({'_id': userId}, {$set:{[key]: {'pictureName': pictureName, 'pictureNumber': pictureNumber}}}, {new: true}, (err, user) => {
       // Try using $set instead of $push as $push works on arrays
        });