Here's the basic scaffolding of what a potential for
loop solution could look like:
x <- data.frame(MonthsEmployed = 1:3,
MonthlyRent = 1:3,
CO_Age = 1:3,
LN_ialenofres = 1:3,
NewVehInd = logical(3))
results <- numeric(length = nrow(x))
for (i in seq_len(nrow(x))) {
results[i] <- run(calculate_fnscore, list("MonthsEmployed" = x$MonthsEmployed[i],
"MonthlyRent" = x$MonthlyRent[i],
"CO_Age" = x$CO_Age[i],
"LN_ialenofres" = x$LN_ialenofres[i],
"NewVehInd" = x$NewVehInd[i]))
}
A few questions:
- Where are the functions
run
,calculate_fnscore
, andboolean_to_bit
coming from? Did you write these or are they from a package? I assume that the list contains arguments to the functioncalculate_fnscore
, and I'm unsure of the advantage of passing these viarun
. - Does your CSV file use
NULL
for missing values? If yes, you could convert these toNA
by setting the argumentna.strings = "NULL"
for the functionread.csv
. - Would it be possible to convert your question to a reproducible example?