From: Timothy H. Keitt (Timothy.Keitt@StonyBrook.Edu)
Date: Thu 10 May 2001 - 07:48:37 EST
Message-ID: <3AF9BB35.1070201@StonyBrook.Edu>
Try:
for(i in 1:nrow(dframe)) my.row <- dframe[i, ]
T.
Till Baumgaertel wrote:
> hello all,
>
> for my diploma-thesis i want to statitically analyze near-infrared-spectra.
> a spectrum is given by the y-values of 1038 equi-distant x-points.
> in nature, a spectrum is a continuous curve. for analysis, every x-point
> is seen as a statistical variable.
>
> now my problem:
> first, i read a csv-table in a data.frame called sTable via read.table.
>
> besides some meta-data there are 1038 variables holding absorbance-values
> for each wave-number, so a spectrum can be seen as a "case".
>
> when i calculate e.g. means for every variable, R works very *fast*. also
> if i want to scale a variable for every spectrum (=case) it's fast: sTable$WN4000
> <- sTable$WN4000 / 1.34 .
> but for some reasons i have to iterate through the spectra, especially when
> i want to differentiate a curve, because then i first have to build a interpolation
> polynom from the given x-points and y-values of a specific case.
>
> i wrote a function getCase <- function( dataFrame, caseNo) with return-value
> of type data.frame and holding the case "caseNo" of the dataFrame.
>
> now, this results in absolutely bad performance.
>
> my question:
> what is the most convenient and fastest way to access a single row of a
> data.frame? if possible, i'd like something i could use like this:
> sTable <- getSpectraTable()
> case11 <- getRow( sTable, 11)
> wn4000 <- case11$WN4000
> is there a built-in function/method in R i didn't find yet?
> also i'd like to avoid casting the data.frame to a matrix (or whatever)
> for reducing the risks by holding data redundantly.
>
> thank you for your help!
> till
>
>
>
>
>
> ________________________________________
> Der clevere Infobote - Shopping-Tipps bequem abonniert. Jetzt neu bei http://www.epost.de
>
>
> -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
> 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@stat.math.ethz.ch
> _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
>
-- Timothy H. Keitt Department of Ecology and Evolution State University of New York at Stony Brook Phone: 631-632-1101, FAX: 631-632-7626 http://life.bio.sunysb.edu/ee/keitt/-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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@stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
This archive was generated by hypermail 2b30 : Fri 22 Jun 2001 - 18:58:41 EST