[R] Have a function like the "_n_" in R ? (Automatic count function )

Nash morrison at ibms.sinica.edu.tw
Wed Feb 25 13:25:18 CET 2009


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 variables)
are created automatically by the DATA step or by DATA step statements.
*/

/*** Output ********************************
counter	     seed             x
1	584043288	         0.27197
2	935902963	         0.43581
3	301879523	         0.14057
4	753212598	         0.35074
5	1607264573	0.74844

********************************************/

Have a function like the "_n_" in R ?


--
Nash - morrison at ibms.sinica.edu.tw




More information about the R-help mailing list