s-news
[Top] [All Lists]

Re : Mixing tapply and diff

To: S-News <s-news@lists.biostat.wustl.edu>
Subject: Re : Mixing tapply and diff
From: Tristan Lorino <tristan.lorino@lcpc.fr>
Date: Thu, 16 Feb 2006 09:51:59 +0100
In-reply-to: <000a01c632d4$d5c438e0$0540210a@www.domain>
Organization: LCPC
References: <1583438515.20060216093556@lcpc.fr> <000a01c632d4$d5c438e0$0540210a@www.domain>
Reply-to: Tristan Lorino <tristan.lorino@lcpc.fr>
Message de Dimitris Rizopoulos, reçu le jeudi 16 février 2006 à 09:41 :

DR> you already have it; you could use:

DR> vals <- tapply(as.vector(SDF1$V1), SDF1$V2, diff)
DR> out <- data.frame(id = rep(unique(SDF1$V2), sapply(vals, length)), 
DR> diff = vals)
DR> out

Thank you... but I have an error message:
Problem in data.frameAux.list(x, na.strings = na.strings, stringsAsFactors = 
str..: arguments imply differing number of rows: 2, 3, 1, 1
Use traceback() to see the call stack

12: eval(action, sys.parent())
11: doErrorAction("Problem in data.frameAux.list(x, na.strings = na.stri
ngs, stringsAsFactors = str..: arguments imply differing number of rows:
 2, 3, 1, 1",
10: stop(paste("arguments imply differing number of rows:", paste(nrows,
 collapse = ", ")))
9: data.frameAux.list(x, na.strings = na.strings, stringsAsFactors = str
ingsAsFactors)
8: data.frameAux.default(eval(as.name(paste("..", i, sep = ""))), na.str
ings = na.strings, stringsAsFactors = stringsAsFactors[i])
7: data.frameAux(eval(as.name(paste("..", i, sep = ""))), na.strings = n
a.strings, stringsAsFactors = stringsAsFactors[i])
6: data.frame(id = rep(unique(SDF1$V2), sapply(vals, length)), diff = va
ls)
5: eval(i, local)
4: source(auto.print = auto.print, exprs = substitute(exprs.literal))
3: script.run(exprs.literal = {
2: eval(expression(script.run(exprs.literal = {
1: 
Message: Problem in data.frameAux.list(x, na.strings = na.strings, strin
gsAsFactors = str..: arguments imply differing number of rows: 2, 3, 1, 
1 




-- 
Laboratoire Central des Ponts et Chaussées
[Division ESAR ? Section AGR]
Route de Bouaye BP 4129
44341 Bouguenais Cedex
France
Tél. 33 (0)2 40 84 56 18


<Prev in Thread] Current Thread [Next in Thread>