[R] Access an entry after reading a table

jim holtman jholtman at gmail.com
Mon Aug 6 05:46:34 CEST 2007


read.table will convert you character columns to factors.  You are
seeing a single value returned ("A"), but it is also reporting the
levels for the factors. One way is to read the data in without
conversion to factors:

 Model=read.table("ModelMat.txt", header=TRUE, as.is=TRUE)

or you can convert the factor to character for output:

as.character(Model[1,1])


On 8/2/07, Gang Chen <gangchen at mail.nih.gov> wrote:
> Sorry about this basic question. After reading a table,
>
> Model=read.table("ModelMat.txt", header=T)
>
> I want to get access to each entry in the table Model. However, if I do
>
>  > Model[1,1]
>
> I get the following,
>
> [1] A
> Levels: A B C
>
> My question is, how can I just get the entry "A" without the 2nd line
> ("Levels: A B C")?
>
> Thanks,
> Gang
>
> ______________________________________________
> 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.
>


-- 
Jim Holtman
Cincinnati, OH
+1 513 646 9390

What is the problem you are trying to solve?



More information about the R-help mailing list