| To: | borek@igf.edu.pl |
|---|---|
| Subject: | Re: observation number |
| From: | Sundar Dorai-Raj <sundar.dorai-raj@pdf.com> |
| Date: | Tue, 17 Jun 2003 08:18:07 -0500 |
| Cc: | s-news@lists.biostat.wustl.edu |
| Organization: | PDF Solutions, Inc. |
| References: | <3EEF1345.5060900@igf.edu.pl> |
| User-agent: | Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.0.2) Gecko/20021120 Netscape/7.01 |
Janusz Borkowski wrote: Dear S+ users,I have a data frame in which the first column indicates the day number, the second column observation number and the third results of observations. It may look like:Dn On R1 1 1 3 1 2 4 1 3 5 2 4 6 2 5 7 2 6 8 To find minimum value of R1 for each day is easy: min.valR1<-Tapply(R1,Dn,min)but how can I get not only the vector of minimum values, but also a vector of observation numbers for which the minimum occurred I am using S+ 4.5 for Windows.I will appreciate any advice.
Is this what you need?
dat <- data.frame(Dn = c(1, 1, 1, 2, 2, 2),
R1 = c(1, 0, 3, 5, 6, 4))
by(dat$R1, dat$Dn, function(x) {
m <- min(x)
c(m, which(x == m))
})
Regards,
Sundar
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| ||
| Previous by Date: | Re: observation number, Spencer Graves |
|---|---|
| Next by Date: | Re: Simulation of survival data to produce sample size estimate., Terry Therneau |
| Previous by Thread: | Re: observation number, Spencer Graves |
| Next by Thread: | Re: observation number, jingshan zhang |
| Indexes: | [Date] [Thread] [Top] [All Lists] |