| To: | s-news@wubios.wustl.edu |
|---|---|
| Subject: | Summary: how do arguments work? |
| From: | Carlisle Thacker <thacker@aoml.noaa.gov> |
| Date: | Thu, 19 Apr 2001 16:07:58 -0400 (EDT) |
| In-reply-to: | <OF00F2AC9E.D47D1A9A-ON85256A33.0064A468@spgdag.ca> |
Thanks to all who replied! My problem was not passing the argument to
by(), which was needed for function used within by():
| specified here
v
> test.fcn <- function(a, b, x){
+ by(a, b, function(data, x) x*data, x)}
^ ^
| | MUST ALSO BE HERE!
|
| needed here
> test.a <- data.frame(u = 1:4,v = c(1,1,2,2))
> test.a
u v
1 1 1
2 2 1
3 3 2
4 4 2
> test.fcn(test.a, test.a$v, 3)
b:1
u v
1 3 3
2 6 3
------------------------------------------------------------
b:2
u v
3 9 6
4 12 6
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| ||
| Previous by Date: | persp() function question, Cande V. Ananth |
|---|---|
| Next by Date: | kernel smoothers for gam( ), Mark Stevenson |
| Previous by Thread: | persp() function question, Cande V. Ananth |
| Next by Thread: | kernel smoothers for gam( ), Mark Stevenson |
| Indexes: | [Date] [Thread] [Top] [All Lists] |