ISAAKiel / oxcAAR

R Package - Interaction with Oxcal
GNU General Public License v2.0
21 stars 4 forks source link

Changing resolution causes error #31

Closed MartinHinz closed 3 years ago

MartinHinz commented 3 years ago

From a user:

I am trying to use oxcAAR, which seems to be a nice tool for R user when calibrating 14C dates. I have a problem when changing the Resolution option to 1 year instead of the default (5 years). The simple following script works perfectly:

res=executeOxcalScript("R_Date(\"test\", 1120, 30);") OxCal v4.4.2 (c) Bronk Ramsey (2020) res2 <- readOxcalOutput(res) res3 <- parseOxcalOutput(res2)

and produce an adequate output (.js) file.

But, changing the resolution gives an error:

res=executeOxcalScript("Options(){Resolution=1;}; R_Date(\"test\", 1120, 30);") OxCal v4.4.2 (c) Bronk Ramsey (2020) res2 <- readOxcalOutput(res) res3 <- parseOxcalOutput(res2) Error in seq.default(from = calcurve_start, by = calcurve_resolution, : 'from' must be of length 1

The output .js file is built (I attach it to this mail), but "parseOxcalOutput" fails to read its content.

Do you have any idea where does this error come from?

MartinHinz commented 3 years ago

Reason: When Resolution is changed, Oxcal just add another entry for the calibration ("calib[0]") with the settings from the Option command. Monkey patch solution: in extractCalCurveFromOxcalResult() only the last entry of name, start and resolution is considered now, using

calcurve_resolution <- calcurve_resolution[length(calcurve_resolution)]

More sustainable solution:

29