SWATdoctR error

59 views
Skip to first unread message

Kirsten Vernin

unread,
Feb 18, 2025, 9:18:47 PMFeb 18
to SWAT+ Editor
I would like to use the SWATtdoctR package to complete model verification for my model using SWAT+. However, I am unable to run the model simulation in R without getting the following error: 
Error in `map2_chr()`: ! Can't recycle `.x` (size 25) to match `.y` (size 24).

when I run the following code: sim_nostress <- run_swat_verification(project_path = "C:/SWAT/SWATPlus/Datasets/doublebayou/Scenarios/Default/TxtInOut",
                                      outputs=c("wb","mgt","plt"),nostress=1)

I'm using R version 4.4.1 (2024-06-14 ucrt) -- "Race for Your Life" and made sure all of the required packages were loaded (SWATdoctR, dplyr, purrr, readr, tidyr). My file path is set to be the TextInOut file and it looks like run verify folder is created and populated. However because the object sim_nostress is not created, I'm unable to run the remainder of the functions. 

Has anyone else run into this error when using SWAT+ and SWATdoctR? 

Emil Wagner

unread,
Oct 6, 2025, 11:16:02 AMOct 6
to SWAT+ Editor

Hi, I ran into the same issue. Have you found a solution?

My guess is that the problem might be due to changes in the structure of the codes.bsn file in a  SWAT+ update, which could be why SWATdoctR is having trouble reading the file.

HIROKAZU FUKUI

unread,
Dec 3, 2025, 5:03:05 PM (yesterday) Dec 3
to SWAT+ Editor
I'm facing the same problem. Were you able to solve it?
2025年10月7日火曜日 0:16:02 UTC+9 Emil Wagner:

Shoaib Ahmed

unread,
12:34 AM (23 hours ago) 12:34 AM
to HIROKAZU FUKUI, SWAT+ Editor
I ran into not exactly this but a similar error. There are two fixes, either edit the input file, R is trying to read a line where it is expecting to have a value but finds it empty, or vice versa. I traced back and found an extra tab being printed in the output file "codes.bsn". I used to delete the extra tab and run it.

Second fix: I patched the SWATDoctR code to read the input file ignoring the extra tab and this worked better.

Hope this helps. Let me know if you would like me to send you the patch.

Kind regards,
Shoaib








--
You received this message because you are subscribed to the Google Groups "SWAT+ Editor" group.
To unsubscribe from this group and stop receiving emails from it, send an email to swatplus-edit...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/swatplus-editor/181e3fe8-974f-40a2-be2f-cabbe637ffeen%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages