[R] Reg. strings and numeric data in matrix.

Greg Snow Greg.Snow at intermountainmail.org
Fri Mar 9 21:39:38 CET 2007


A matrix can only have 1 type of data, so if you try to include both
strings and numbers in a matrix, the numbers will be converted to
strings.

Another type of data object is a data frame, a data frame works much
like a matrix in many ways, but allows some columns to be numbers and
others to be strings (though usually strings are converted to factors).

You should read (or reread) the help page "An Introduction to R",
section 5 talks about matricies, then section 6 talks about data frames
(and lists).  Section 7 shows how to read data from files into data
frames.  Those 3 sections should answer your questions below.

Hope this helps,

-- 
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
greg.snow at intermountainmail.org
(801) 408-8111
 
 

> -----Original Message-----
> From: r-help-bounces at stat.math.ethz.ch 
> [mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of 
> Mallika Veeramalai
> Sent: Friday, March 09, 2007 1:03 PM
> To: r-help at stat.math.ethz.ch
> Subject: [R] Reg. strings and numeric data in matrix.
> 
> 
> Hi All,
> 
> Sorry for this basic question as I am new to this R. I would 
> like to know, is it possible to consider a matrix with some 
> columns having numeric data and some other's with characters 
> (strings) data?  How do I get this type of data from a flat file.
> 
> Thanks very much,
> mallika 
> 
> ______________________________________________________________
> ______________
>     Mallika Veeramalai, Ph.D.,
>     Postdoctoral Associate,
>     Bioinformatics & Systems Biology,
>     Burnham Institute for Medical Research,
>     La Jolla,  CA 92037, USA.
>     phone : +1 858 646 3100 ext: 3627
>     Fax   : +1 858 795 5249
>     Web   : http://bioinformatics.burnham.org/~mallika/
>     Email : mallikav at burnham.org (or) kaaviyam at gmail.com
> 
> ______________________________________________
> R-help at stat.math.ethz.ch 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.
>



More information about the R-help mailing list