[R] Vector and String
Prof Brian Ripley
ripley at stats.ox.ac.uk
Fri Oct 22 10:55:14 CEST 2004
On Fri, 22 Oct 2004 pbrouilly at gphy.campus.univ-poitiers.fr wrote:
> Hi everybody,
> I'm using a vector to strore some strings.
> I create a vector named seq2 :
> > seq2<-vector(length=0)
so you created a *logical vector*. See ?vector.
> I have a string named b
> > b
>  CATGGTAGGAATAC
I think you have a factor, not a `string'. What does str(b) say?
> I put b in the vector
> > seq2<-c(seq2,b)
> Finally I edit seq2
> > seq2
>  "14760"
> My question is why I obtained a number (14760) when I add a string (CATGGTAGGAATAC)
> I have an idea : when I edit b, I see (  CATGGTAGGAATAC )
> and not ( "CATGGTAGGAATAC")
> How can I convert b to a true string with ""
seq2 <- character()
seq2 <- c(seq2, as.character(b))
Brian D. Ripley, ripley at stats.ox.ac.uk
Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel: +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UK Fax: +44 1865 272595
More information about the R-help