numeric(0) ?????
Dear Massimiliano
How about
for (i in 1:20){
if(any(T$pluto==i)) T$pippo[T$pluto==i]
}
??
Depending on what you want to do with these subsets of the data.frame,
you might want to consider using
``tapply'' or ``by'' [se the help-files for these functions] instead of
the for loop.
For example :
tapply(T$pluto,T$pippo, sum)
Cheers
Ole
Massimiliano Cannata wrote:
hello,
I have a little problem with my script:
I select a subset from a data frame
for (i in 1:20){
T$pippo[T$pluto==i]
}
but sometime it is void because T$pluto==5 does not exists, the R answer is:
T$pippo[T$pluto==5]
numeric(0)
how to exclude this null subset? and what is numeric(0), similar to NA? I try an if statement, but how to write if T$pippo[T$pluto==i] is numeric(0)??? Thanks a lot. Maxi ------------- Ing. Massimiliano Cannata Istituto di Scienze della Terra - SUPSI C.P. 72 - CH-6952 Canobbio (Ticino, Switzerland) Tel +41 91 /935 12 25 - Fax +41 91 /935 12 09 eMail: massimiliano.cannata at supsi.ch Internet: http://www.ist.supsi.ch [[alternative HTML version deleted]]
_______________________________________________ R-sig-Geo mailing list R-sig-Geo at stat.math.ethz.ch https://www.stat.math.ethz.ch/mailman/listinfo/r-sig-geo
Ole F. Christensen Center for Bioinformatik Datalogisk Institut Aarhus Universitet Ny Munkegade, Bygning 540 8000 Aarhus C Denmark