Skip to content
Back to formatted view

Raw Message

Message-ID: <loom.20111117T010304-531@post.gmane.org>
Date: 2011-11-17T00:11:46Z
From: JulioSergio
Subject: Named rows in a table (data frame) read from a file

I read a table as follows:

> F1 <- read.table("Rtext3.txt")
> F1
  Price Floor Area Rooms Age Cent.heat
a 52.00   111  830     5 6.2        no
b 54.75   128  710     5 7.5        no
c 57.50   101 1000     5 4.2        no
d 57.50   131  690     6 8.8        no
e 59.75    93  900     5 1.9       yes

As it is seen, the rows have a name. However I don't know how to access a 
particular element from that name, for instance,

> attach(F1)
> Price
[1] 52.00 54.75 57.50 57.50 59.75
> Price[["a"]]
Error en Price[["a"]] : sub?ndice fuera de  los l?mites
> Price$a
Error en Price$a : $ operator is invalid for atomic vectors
> Price['a']
[1] NA
> Price["a"]
[1] NA

If I cannot access particular elements of the frame components by the row names, 
is there any use of having the rows named?

Thanks,

Sergio.