Have the counter function in R ?
if we use the software SAS
/*** SAS Code **/
data tmp(drop= i);
retain seed x 0;
do i = 1 to 5;
call ranuni(seed,x);
output;
end;
run;
data new;
counter=_n_; * this keyword _n_ ;
set tmp;
run;
/*
_n_ (Automatic
* San José * Singapore *
www.ambaresearch.com
-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On
Behalf Of Nash
Sent: Wednesday, February 25, 2009 5:55 PM
To: r-help
Subject: [R] Have a function like the _n_ in R ? (Automatic count function
I think you can use seq function:
seq(5)
On Wed, Feb 25, 2009 at 9:25 AM, Nash morri...@ibms.sinica.edu.tw wrote:
Have the counter function in R ?
if we use the software SAS
/*** SAS Code **/
data tmp(drop= i);
retain seed x 0;
do i = 1 to 5;
call
The _n_ construct in SAS is most analogous to that of row names in R,
accessible (and modifiable) via the row.names() function:
DF - structure(list(Month = structure(c(2L, 2L, 2L, 2L, 1L, 1L, 1L,
1L, 3L, 3L, 3L, 3L, 3L), .Label = c(Aug, July, Sept), class =
factor),
Week = 27:39,
And for completeness here's a function that returns the next integer
on each call.
n - (function(){
i - 0
function() {
i - i + 1
i
}
})()
n()
[1] 1
n()
[1] 2
n()
[1] 3
n()
[1] 4
n()
[1] 5
n()
[1] 6
;)
Hadley
On Wed, Feb 25, 2009 at 8:27 AM, David Winsemius
On Wed, Feb 25, 2009 at 8:41 AM, Wacek Kusnierczyk
waclaw.marcin.kusnierc...@idi.ntnu.no wrote:
hadley wickham wrote:
And for completeness here's a function that returns the next integer
on each call.
n - (function(){
i - 0
function() {
i - i + 1
i
}
})()
actually, you
On Wed, Feb 25, 2009 at 3:30 PM, hadley wickham h.wick...@gmail.com wrote:
And for completeness here's a function that returns the next integer
on each call.
n - (function(){
i - 0
function() {
i - i + 1
i
}
})()
n()
[1] 1
n()
[1] 2
n()
[1] 3
n()
[1] 4
n()
[1] 5
n()
On Wed, 25 Feb 2009, Gustaf Rydevik wrote:
On Wed, Feb 25, 2009 at 3:30 PM, hadley wickham h.wick...@gmail.com wrote:
And for completeness here's a function that returns the next integer
on each call.
n - (function(){
i - 0
function() {
i - i + 1
i
}
})()
n()
[1] 1
n()
[1] 2
hadley wickham wrote:
On Wed, Feb 25, 2009 at 8:41 AM, Wacek Kusnierczyk
waclaw.marcin.kusnierc...@idi.ntnu.no wrote:
hadley wickham wrote:
And for completeness here's a function that returns the next integer
on each call.
n - (function(){
i - 0
function() {
i - i + 1
On Wed, Feb 25, 2009 at 4:43 PM, Charles C. Berry cbe...@tajo.ucsd.edu wrote:
On Wed, 25 Feb 2009, Gustaf Rydevik wrote:
On Wed, Feb 25, 2009 at 3:30 PM, hadley wickham h.wick...@gmail.com
wrote:
And for completeness here's a function that returns the next integer
on each call.
n -
10 matches
Mail list logo