R-beta: vectors in dataframe?

Thomas Lumley thomas at biostat.washington.edu
Mon Apr 27 20:54:29 CEST 1998


On Mon, 27 Apr 1998, Bill Simpson wrote:

> I have a file:
> 
> x     y     z
> 0.025 0.025 1.65775
> 0.025 0.050 1.62602
> 0.025 0.075 1.63683
> 0.025 0.100 1.91847
> 0.025 0.125 2.00913
> 0.025 0.150 1.82222
> 0.025 0.175 1.70901
> 0.025 0.200 1.39759
> 0.025 0.225 1.39089
> 0.025 0.250 1.04762
> 
> If I read the file like this:
> data<-read.table("file.dat")
> 
> How do I access the vectors x,y,z that are inside the dataframe data?  I
> studied Venables and Ripley and could not figure it out.

	data$x 
	data$y 
	data$z  
or 
	data[,"x"]
	data[,"y"]
	data[,"z"]
or

	attach(data)
	x
	y
	z
	detach()

or in modelling functions
	lm(y~z+x,data=data)


Thomas Lumley
------------------------------------------------------+------
Biostatistics		: "Never attribute to malice what  :
Uni of Washington	:  can be adequately explained by  :
Box 357232		:  incompetence" - Hanlon's Razor  :
Seattle WA 98195-7232	:				   :
------------------------------------------------------------

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list