[R] Accessing single element of data.frame

Jannis bt_jannis at yahoo.de
Mon Jul 26 23:55:34 CEST 2010


The solution to (most R problems) is as follows:

1.if asking for help include reproducible examples including parts of 
your data otherwise we can just guess what kind of data you have.

2. In general, refer to the help pages of the functions you use ( 
help(read.csv),help(data.frame) ) (

i have to confess that a similar problem puzzled me for quite a while, 
so here comes suggestion 3:

3. As a start, have a look what kind of data you have:

class(t1)
class(t2)
class(t2[2,])

I would guess that t2 is a factor and not a vector and that the problem 
lies in read.csv converting whatever data you have to factors.

See

?read.csv


and the

stringsAsFactors


argument of that call. Adjusting its values might fix your problem. If 
not, go back to advice 1 ;-)


HTH
Jannis


vacas schrieb:
> Hi I am new to R. 
> I am having this problem
> t1 <- read.csv("myfile.csv")
> t2 <- data.frame(t1)
> which have 10 row and 10 columns
> t2[1,1] does not give the first element but it gives the levels, how can I
> fix it. 
>
> I will be thankful to community. 
>



More information about the R-help mailing list