I have a csv that I have imported that has multiple data fields for a times series. So the first field is the datetime, and the rest of the fields are variuous datapoints.
How would I plot the pointwise max value of multiple fields, where the fields would be matched on some sort of wildcard?
So for example:
time,foo1,foo2,foo3
1:00,1,2,3
2:00,3,1,1
3:00,2,5,3
What would be the easiest way to plot foo.* such that I get the max from each field: I.e. the resultant plot from that example would be: (1:00,3),(2:00,3),(3:00,5)?
To Clarify the example, the max points I mean are in **
time,foo1,foo2,foo3
1:00,1,2,*3*
2:00,*3*,1,1
3:00,2,*5*,3
Assuming your data are in a data.frame
x, you can usepmaxlike so:do.callcalls thepmaxfunction with each column inxas a...argument (except the first column, which is removed by negative subscripting).cbindcombines the first column ofxwith the resulting vector fromdo.call.Note that the 2nd argument to
do.callneeds to be a list and a data.frame is a list with some extra attributes. Ifxisn’t a data.frame, you’ll need to coerce it to one (or a regular list).