philchalmers / mirt

Multidimensional item response theory
199 stars 75 forks source link

Should `cat("\n")` be used when the `print()` method of `SingleGroupClass` ends? #214

Closed sfcheung closed 2 years ago

sfcheung commented 2 years ago

I don't know how to show this problem (to me it is a problem) because the problem occurred in an interactive session, and the form of the problem depends on the IDE being used. I tried R default console, RStudio, and Visual Studio Code, and the problems are different.

This code and reproduce the problem:

library(mirt)
mod1 <- mirt(expand.table(LSAT7), 1)
mod1

Simply put, because "\n" is not printed when the method ends, something unexpected can occur. For example, in R default console, the is the last line:

RMSEA = 0.023, CFI = NaN, TLI = NaN> 

The cursor is right after >.

In Visual Studio Code, this is the last line:

> SEA = 0.023, CFI = NaN, TLI = NaN

The cursor will overlap with S in SEA.

In RStudio, this is the last line:

RMSEA = 0.023, CFI = NaN, TLI = NaN> 
>

The problem is less severe because the only issue is the > at the end of the line.

When users use the print method, it is natural to expect that this method will "cat" a "\n" when it ends. This is how the print method usually behaves.

How about adding cat("\n") after line 91, before the print method ends?

https://github.com/philchalmers/mirt/blob/6ef8918af53996f3ab70ca614bba8a3bfc0b67e6/R/SingleGroup-methods.R#L86-L92

philchalmers commented 2 years ago

I have no problem with this stylistic chance. Should be patched now.