Suppose I have 2 columns in a table
Quantity int Price decimal
And I want to calculate the value of a 3rd column called Total.
In SQL Server's transact-sql I could simply write
select Price*Quantity as Total from mytable
or I could write a used defined function CalcTotal and then write
select calcTotal(quantity,price) as total from mytable
How do I write a function in R to add a similar column to a dataframe?
I tried to formulate my question here