In C# I am used to the concept of a data set and a current record. It would be easy for me to write a complicated calc-price function with conditions on the current record.
For my own notes on Gregor's answer
IsPrettyIf <-function(row){
ret ="N"
if(row$Petal.Width > 0.3) { ret="Y"}
return(ret)
}
df <- iris
df$PrettyLoop ="" # add a column and initialize all the cells to be empty
for(i in 1:5) {
df$PrettyLoop[i] = IsPrettyIf(df[i,])
cat("Row",i, "is Pretty?",df$PrettyLoop[i],"\n")
}
The bit that trips me up is that row$PrettyLoop is like a cell and df$PrettyLoop is like a column, thinking with the spreadsheet analogy.