Line 91: as.numeric(FX[,i]) should be as.numeric(FX[[i]]) so that this works if FX is a tbl. (Otherwise get an error that a list object cannot be coerced into a double.)
Line 207 should be deleted. It is overwriting the work done in lines 199-205 and produces an error if density1 and density2 are not identical.
Line 91: as.numeric(FX[,i]) should be as.numeric(FX[[i]]) so that this works if FX is a tbl. (Otherwise get an error that a list object cannot be coerced into a double.)
Line 207 should be deleted. It is overwriting the work done in lines 199-205 and produces an error if density1 and density2 are not identical.