[R] How to select the column header with \Sexpr{}

David Winsemius dwinsemius at comcast.net
Tue Jul 13 00:14:49 CEST 2010


On Jul 12, 2010, at 5:45 PM, Felipe Carrillo wrote:

> Thanks for the quick reply Duncan.
> I don't think I have explained myself well, I have a dataset named  
> "report" and
> my column headers are run1,run2,run3,run4 and so on.
>
> I know how to access the data below those columns with  
> \Sexpr{report[1,1]} &
> &\Sexpr{report[1,2]} and so on, but I can't access my column headers
> with \Sexpr{} because I can't find the way to reference  
> run1,run2,run3 and run4.
> Sorry if I am not explain myself really well.

Wouldn't this just be:

\Sexpr{names(report)}  # ?  or perhaps you want specific items in that  
vector?

Sexpr{names(report)[1]}, Sexpr{names(report)[2]}, etc

-- 
David.
>
>
>
>
> ----- Original Message ----
>> From: Duncan Murdoch <murdoch.duncan at gmail.com>
>> To: Felipe Carrillo <mazatlanmexico at yahoo.com>
>> Cc: r-help at stat.math.ethz.ch
>> Sent: Mon, July 12, 2010 2:18:15 PM
>> Subject: Re: [R] How to select the column header with \Sexpr{}
>>
>> On 12/07/2010 5:10 PM, Felipe Carrillo wrote:
>>> Hi:
>>> Since I work with a few different fish runs my column headers change
>> everytime
>>> I start a new Year. I have been using \Sexpr{} for my row and  
>>> columns and now
>> I am trying to use with my report column headers. \Sexpr{1,1} is  
>> row 1 column 1,
>>> what can I use for headers? I tried \Sexpr{0,1} but sweave didn't  
>>> like
>> it..Thanks in advance
>>> for any hints
>>>
>>
>> \Sexpr takes an R expression, and inserts the first element of the  
>> result into
>> your text.  Using just "0,1" (not including the quotes) is not a  
>> valid R
>> expression.
>>
>> You need to use paste() or some other function to construct the  
>> label you want
>> to put in place, e.g. \Sexpr{paste(0,1,sep=",")} will give you "0,1".
>>
>> Duncan Murdoch
>>
>
>
>
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

David Winsemius, MD
West Hartford, CT



More information about the R-help mailing list