The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

carminat (49) [Avatar] Offline
#1
I have a file with the following structure

#column 1      #column 2      #column 3 
  string          number         date


Imagine that the string in the column1 is the name of a user,
the number in column2 is a code associated to the user,
and the date in column3 records an action of the user
(a toy version of my file is here https://dl.dropboxusercontent.com/u/10917026/fake.csv )

The following script provides a statistic of the actions of all users
set format x "%d%b%y"
set datafile separator ";"
set xdata time
set xtics rotate by 90 offset 0,-3
set bmargin 10
set grid
set key left
set timefmt "%d/%m/%Y"

file="fake.csv"

plot    file  u 3:(1) smooth  cumulative w l  t ""


The above script works fine. Now I want gnuplot produce a similar statistic
filtering the events of a specific user: I tried both with the plot command
plot    file  u 3:((stringcolumn(1)=="jack")?1:0) smooth  cumulative w l  t ""

and
plot    file  u 3:(($1==3) ? 1 : 0 ) smooth  cumulative w l  t ""

but neither of these commands seems to work.

Did I make a mistake in the syntax?
philipp.janert (286) [Avatar] Offline
#2
1) For string comparison, you must use the "eq" operator instead of "==".
2) In the second example, you use the wrong column (it should be $2==3).

Does this fix things?