[6362] in s-news-athena

home help back first fref pref prev next nref lref last post

Summary: Matrix subset of dataframe

daemon@ATHENA.MIT.EDU (garrett@gsc.emr.ca)
Thu Feb 2 11:59:50 1995

Date: Thu, 2 Feb 95 11:27:26 EST
From: garrett@gsc.emr.ca
To: s-news@utstat.toronto.edu

Firstly -		Thank you for all the helpful responses, I
		have reproduced what seem to be the
		best suggestions below, and
Secondly -	I apologize for forgetting what I was once
		taught about cbind.  I should spend more
		time just browsing the manuals as has been
		suggested recently.

There were two simple solutions to my problem of creating a sub
matrix from a data frame.  In both examples I will assume the data frame has 
been attached:
.
> attach(dataframe)
.
then
.
> sub.mat <- cbind(var4, var2, var6, var9)
.
> is.matrix(sub.mat)

[1] T
.

or to obtain a sub data frame rather than a sub matrix

.
> sub.dataframe <- dataframe[, c("var4", "var2", "var6", "var9")]
.
> is.data.frame(sub.dataframe)

[1] T


Robert G. (Bob) Garrett
Applied Geochemistry Subdivision
Geological Survey of Canada
601 Booth St., Ottawa, Ontario K1A 0E8
Internet: garrett@gsc.emr.ca
Tel.: 613+995-4517   FAX: 613+996-3726

home help back first fref pref prev next nref lref last post