The code below should create a new column in a DataFrame,
new_MaxAllwFAR = [15.0, 15.0, 15.0, 15.0].
Instead it creates,
new_MaxAllwFAR = [15.0, 15.0, missing, missing].
Can you help me understand why? And how should I debug in this instance? Is there a more efficient way to code this in DataFrames.jl?
using DataFrames
dataF = DataFrame(MaxAllwFAR = [15., 15., missing, missing],
ComArea = [1000., 1000., 1000., 1000.],
ResArea = [0., 0., 0., 0.],
ResidFAR = [missing, missing, 10., 10.],
CommFAR = [missing, missing, 15., 15.])
function xform_maxfar(max_far, com_area, res_area, resid_far, com_far)
if ismissing(max_far)
if com_area > res_area
return com_far
else
return resid_far
end
else
return max_far
end
end
transform!(dataF,
[:MaxAllwFAR, :ComArea, :ResArea, :ResidFAR, :CommFAR] =>
xform_maxfar => :new_MaxAllwFAR)
println(dataF)