Open bkerwick opened 1 year ago
Thank you for the detailed description. Could you provide the full result of the sessionInfo()
? I need to see the list of attached packages. There is no such information in your screenshot.
Sorry about that here you go
I have run your code several times and didn't see any errors. Also tried with loaded dplyr
with the same result. As far as I can see in the "attached packages" you load other packages except the expss. Could you give me all the code with library's
which you execute before running the code above?
I use macos but today i tried a fresh install of R on windows, installed expss and it's dependencies. Ran the code without doing anything else and below occurred. I hope this helps
Was this what you were looking for? Were you not able to recreate the error?
@bkerwick I have reproduced this issue. It seems this bug is Windows specific. Currently I don't know why this happens. Will investigate further.
I also encountered this issue today. I couldn't figure out what might be causing it, but it seems to be somehow related to unexpected behavior of the "/" character in value labels. Removing them has prevented this error, but I haven't tested it further yet, maybe it is just a coincidence, as this error was pretty random for me.
I also recently ran into the error when trying to create a crosstab with 208 variables in tab_cells and 16 in tab_cols. Removing "/" character did not solve the problem for me. I have observed that the error becomes more likely the more variables you include.
I wrote a code with trycatch as a temporary solution, so that I don't always have to re-run the code myself until it works. For the above scenario it took 7 tries until I got the record/table. Maybe it helps someone:
c = 0 # set counter to zero
repeat{
error <- FALSE
print(c)
tryCatch(my_table <- datasetSAV %>%
tab_cells(X1,
X2
) %>%
tab_cols(total(),
X3,
X4
) %>%
tab_stat_cases(label = "N", total_row_position = "above") %>%
tab_stat_cpct(label="%", total_statistic = "w_cpct", total_label = "#Total cases") %>%
tab_pivot(stat_position = "inside_columns") %>%
drop_empty_rows() %>%
drop_empty_columns(),
error = function(e){ error <<- TRUE})
if(error == FALSE){ break }
if(c == 10){ break}
c = c + 1
print("Error")
}
@gdemin Many thanks for your efforts and the great package!
Thank you so much, @JB0207, for your valuable comment. Your suggestion to use the "TryCatch function with Repeat" worked perfectly for me. I appreciate your time and effort in helping me with this issue.
I also encountered this issue today. I couldn't figure out what might be causing it, but it seems to be somehow related to unexpected behavior of the "/" character in value labels. Removing them has prevented this error, but I haven't tested it further yet, maybe it is just a coincidence, as this error was pretty random for me.
I tried this approch and had no success. There problem seems to be somewhere else
I forked your package and changed these 2 lines: https://github.com/gdemin/expss/compare/master...Waschoi:expss:master Maybe this could be done as an option, but I am not clever enough to figure this out.
This works well for me.
@Waschoi Thank you for your investigation but I can't use this workaround in the CRAN version.
You removed the check for label code duplication. And duplicated codes in value labels can produce unpredictable bugs in further processing, such as table creation.
This was not intended to be a permanent solution, but rather a good workaround for me. As soon as there is a real fix, I would use your version again. The bug really drove us crazy because it is not reproducible.
Since R 4.4.1 the problem is gone 😁
Thats great news thank you for your work around also
We have started using expss to create a lot of tabs and workbooks and found we are getting a random error in the workflow. To replicate a random error is hard but below is my attempt with screenshots where in the loop the error occurred.
Would like to know if there is a way to avoid this and if i am missing something obvious. Thank you for your time