Render code to pdf that can be cut and pasted

Here's a chunk I'm trying to render accurately to pdf, and by "accurately" I mean that it's possible to cut and paste the code from the knitted document and have it execute correctly in the console.

In the example below, the code returns 1 in the knitted output but returns 2 when you cut and paste from the knitted pdf output to the console :

grep('^ab', c('ab', 'd^ab'))

The issue is that the circumflex in the code is ASCII 94, but is rendered to a typographical circumflex when knitted to pdf. It thus loses the interpretation as beginning of string. (It is correctly knitted to html).

Is there some way to control the rendering process so that the output circumflex is also ascii 94?

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.