I am quite new to Mathematica so I hope my question isn't too basic. I would like to apply a function to the rows of a dataset where selected columns are the input to the function. I can do this with a list but I am eventually going to deal with a large file with a lot of columns and would like to choose the columns based on the header. I never got that far because I cannot get Apply to work on more than one row of a dataset.
Example: CREATE A SIMPLE FUNCTION
In[1]:= simplefunc[a_, b_, c_] := (a + b)*c
In[2]:= simplefunc[1, 2, 3]
Out[2]= 9
IMPORT A LIST (MATRIX)
In[4]:= noheader = Import["D:/test/noheader.csv"]
({ {1, 2, 3},{2, 3, 4}, {3, 4, 5},{4, 5, 6}})
APPLY THE FUNCTION TO THE FIRST ROW - IT WORKS
In[13]:= simplefunc @@ noheader[[1]]
Out[13]= 9
APPLY THE FUNCTION TO ALL ROWS - IT WORKS
In[5]:= simplefunc @@@ noheader
Out[5]= {9,20,35,54}
USE SEMANTIC IMPORT TO CREATE A DATASET WITH HEADERS
In[6]:= yesheader = SemanticImport["D:/test/yesheader.csv"]
Out[6]=
a b c
1 2 3
2 3 4
3 4 5
4 5 6
2 levels | 4elements | 12elements total \[SpanFromLeft] \[SpanFromLeft]
APPLY THE FUNCTION TO THE FIRST ROW -- IT WORKS
In[9]:= simplefunc @@ yesheader[[1]]
Out[9]= 9
APPLY THE FUNCTION TO THE ENTIRE DATASET - IT FAILS
In[14]:= simplefunc @@@ yesheader
Out[14]= Failure[Dataset,<|MessageTemplate:>Dataset::invqf,MessageParameters-><|Symbol->Apply,Head->Apply,Arguments->{simplefunc,TypeSystem`Vector(TypeSystem`Struct({a,b,c},{TypeSystem`Atom(Integer),TypeSystem`Atom(Integer),TypeSystem`Atom(Integer)}),4),{1}}|>|>]
I have tried other approaches with no success. Does Apply simply not work with datasets? Is there a way to get to my final goal of applying a function to selected columns by header names?
Thank you!
Ed