Skip to content
Back to formatted view

Raw Message

Message-ID: <9FB8D90B-4EDD-41DE-82DE-DB4F1CB4D496@gmail.com>
Date: 2011-01-19T06:27:54Z
From: Joshua Wiley
Subject: Printing "pretty' vectors in Sweave
In-Reply-To: <AANLkTi=TSEBrs21t-ikmwLDf8b_DTvvGKegA1YO1vv5k@mail.gmail.com>

Hi Robin,

Have you looked at the 'collapse' argument to paste?
something like:

myvec <- paste(1:4, collapse = ", ")

Might do what you want.  Also maybe ?bquote or the like to get rid of quotes possibly (I'm not in a position to try presently).

Side note, it is really probably best not to use 'c' as a variable name since it is such a fundamental function.

Cheers,

Josh


On Jan 18, 2011, at 21:46, Robin Jeffries <rjeffries at ucla.edu> wrote:

> I am trying to print a nice looking vector in Sweave.
> 
> c <- 1:4
> 
> I want to see (1, 2, 3, 4) in TeX. .
> 
> If I use
> paste(c, ",", sep="")
> I get
> "1," "2," "3," "4,"
> 
> If use cat(c, sep=",")
> I can't seem to assign it to an object,
> 1,2,3,4> myvec <- cat(c, sep=",")
> 1,2,3,4> myvec
> NULL
> 
> and if I bypass the object assignment and put
> "My vector is (\Sweave{cat(c, sep=",")}). "
> prints out
> "My vector is (). "
> 
> Suggestions?
> 
> 
> Robin Jeffries
> MS, DrPH Candidate
> Department of Biostatistics
> UCLA
> 530-624-0428
> 
>    [[alternative HTML version deleted]]
> 
> ______________________________________________
> 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.