Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Suppose I have an object that was processed in an earlier knitr chunk, say

my_df <- read.dta('somefile.dta')
x <- mean(my_df$age)

Putting an inline knitr chunk does not work -- the knitr chunk is written out as text; it is not processed. And I don't think I can use \Sexpr{x} because I don't seem to be able to refer to x in \Sexpr{}.

I'm using LyX 2.0.3 and svn, and knitr version .3

share|improve this question

1 Answer 1

up vote 1 down vote accepted

Surely you can use x in \Sexpr{} after the chunk in which x was created. Did you really try it at all? One reminder, though, is that you have to use TeX code in LyX to input \Sexpr{x} (press Ctrl+L) to make sure \ is not translated to \backslash.

share|improve this answer
    
This did not work for me. After upgrading to .3.5 it works as expected. Thanks. –  scottkosty Mar 8 '12 at 19:35
    
Hmm... that sounds weird; I did not change anything about \Sexpr{} recently. –  Yihui Mar 9 '12 at 3:14

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.