Hi Dylan, > The patch does fix that issue -- but it introduces a different bug > for code blocks with ~:session~: the R block now only produces > output from the last statement evaluated. Of course, you're right. Good catch. Here's another attempt. It fixes the issue by modifying the R comint regular expression, requiring it to match at the beginning of the line. I think this should fix most cases, including the examples you sent. Still, it's not totally robust -- for example, it will still mangle multiline strings, if one of the lines starts with a substring that looks like a prompt. I'd be interested to hear if the attached patch works for the common cases you encounter, such as with tibbles. As an aside, I personally use an alternative implementation of ob-R sessions that doesn't suffer from this issue, and also provides some other benefits like async evaluation [1]. I'm planning to submit these changes to org-mode someday, but am not ready yet. But you may want to check it out, it was able to solve the issue in the other thread I linked as well. [1] https://github.com/jackkamm/ob-session-async