[R] A Question about read.table and Data Frames in R

Robert Sherry rsherry8 at comcast.net
Mon Jun 30 00:22:17 CEST 2014

I created the following file:


I then read the file in R using the command:
	stockList=read.table("/NotesOnR/stockList", header = T, sep=",")

I would then expect the following expression to evaluate to the simple
string APA:
However when I type that in on the command line, I get:
[1] APA

I would also expect to be able to print out the table by using the command:
	for( i in 1:3 ) {
		print( stockList$symbol[i] )
		print ( stockList$shares[i] )

However, as part of the output I get:
	Levels: APA CVX XOM
I do not understand what is going on. Also, when I try passing the
expression stockList$symbol to a standard function in R, it does not work.

I think that I am missing something here but I am not sure what I am
missing. Should I be writing code like:
	for  ( i in stockList$smybol )
However,  given the symbol, I am not sure how to get the share count that is
in the same row.

I thank the group in advance for their responses.


More information about the R-help mailing list