

Hey there,
I tried to count the number of rows, where my data isn't NaN in a
certain column.
this was my guess:
(given is a data frame with 2069 rows and 17 cols)
NROW(data[jan,16] != NaN)
("jan" is defined this way: jan < which(data[,2]==1, arr.ind= TRUE))
but I only get the number of columns where my data is "1" in the second
col. R isn't removing the NaN.
na.rm isn't working here.
I would appreciate your help.
______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/rhelpPLEASE do read the posting guide http://www.Rproject.org/postingguide.htmland provide commented, minimal, selfcontained, reproducible code.


?is.nan
Peter Ehlers
On 20110222 07:11, Sandra Stankowski wrote:
> Hey there,
>
> I tried to count the number of rows, where my data isn't NaN in a
> certain column.
>
> this was my guess:
>
> (given is a data frame with 2069 rows and 17 cols)
>
> NROW(data[jan,16] != NaN)
>
> ("jan" is defined this way: jan< which(data[,2]==1, arr.ind= TRUE))
>
>
> but I only get the number of columns where my data is "1" in the second
> col. R isn't removing the NaN.
> na.rm isn't working here.
>
> I would appreciate your help.
>
> ______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/rhelp> PLEASE do read the posting guide http://www.Rproject.org/postingguide.html> and provide commented, minimal, selfcontained, reproducible code.
______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/rhelpPLEASE do read the posting guide http://www.Rproject.org/postingguide.htmland provide commented, minimal, selfcontained, reproducible code.


Sandra,
Please provide a small, reproducible example of this issue.
You probably want to use ?is.nan and not the inequality
operator.
Similar example, contrast:
x < NA
is.na(x)
x == NA
Sandra Stankowski wrote:
> Hey there,
>
> I tried to count the number of rows, where my data isn't NaN in a
> certain column.
>
> this was my guess:
>
> (given is a data frame with 2069 rows and 17 cols)
>
> NROW(data[jan,16] != NaN)
>
> ("jan" is defined this way: jan < which(data[,2]==1, arr.ind= TRUE))
>
>
> but I only get the number of columns where my data is "1" in the second
> col. R isn't removing the NaN.
> na.rm isn't working here.
>
> I would appreciate your help.
>
> ______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/rhelp> PLEASE do read the posting guide
> http://www.Rproject.org/postingguide.html> and provide commented, minimal, selfcontained, reproducible code.
______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/rhelpPLEASE do read the posting guide http://www.Rproject.org/postingguide.htmland provide commented, minimal, selfcontained, reproducible code.


Hi Sandra,
What about ?is.na function ?
Hope this help
Regards,
ML
Le 22/02/11 16:11, Sandra Stankowski a écrit :
> NROW(data[jan,16] != NaN)

####################################
Mohamed Lajnef,IE INSERM U955 eq 15#
Pôle de Psychiatrie #
Hôpital CHENEVIER #
40, rue Mesly #
94010 CRETEIL Cedex FRANCE #
[hidden email] #
tel : 01 49 81 31 31 (poste 18467) #
Sec : 01 49 81 32 90 #
fax : 01 49 81 30 99 #
####################################
[[alternative HTML version deleted]]
______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/rhelpPLEASE do read the posting guide http://www.Rproject.org/postingguide.htmland provide commented, minimal, selfcontained, reproducible code.


is.na function does'nt seem to work, but maybe I'm just dealing with it
in a wrong way.
here's an example
> m < c(2, 3, 5, 6, 3, 7, 99, 99, 6)
> n < c(1,1,1,1,1,2,2,2,2)
so my matrix contains certain missing values
> m[m==99] < NA
> o < data.frame(m, n)
> o
m n
1 2 1
2 3 1
3 5 1
4 6 1
5 3 1
6 7 2
7 NA 2
8 NA 2
9 6 2
"2" stands for february
> february < which(o[,2]==2, arr.ind = TRUE)
> prec_feb < sum(o[february,1], na.rm = TRUE)
> prec_feb
[1] 13
And now I need to know the exact number of rows, where "m" contains a
value. to know how many days a month give any information. (to create
monthly means and stuff)
hope this explains, what I need to know.
Thanks,
S.
Am 22.02.2011 16:50, schrieb Erik Iverson:
> Sandra,
>
> Please provide a small, reproducible example of this issue.
> You probably want to use ?is.nan and not the inequality
> operator.
>
> Similar example, contrast:
>
> x < NA
> is.na(x)
> x == NA
>
> Sandra Stankowski wrote:
>> Hey there,
>>
>> I tried to count the number of rows, where my data isn't NaN in a
>> certain column.
>>
>> this was my guess:
>>
>> (given is a data frame with 2069 rows and 17 cols)
>>
>> NROW(data[jan,16] != NaN)
>>
>> ("jan" is defined this way: jan < which(data[,2]==1, arr.ind= TRUE))
>>
>>
>> but I only get the number of columns where my data is "1" in the
>> second col. R isn't removing the NaN.
>> na.rm isn't working here.
>>
>> I would appreciate your help.
>>
>> ______________________________________________
>> [hidden email] mailing list
>> https://stat.ethz.ch/mailman/listinfo/rhelp>> PLEASE do read the posting guide
>> http://www.Rproject.org/postingguide.html>> and provide commented, minimal, selfcontained, reproducible code.
>
______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/rhelpPLEASE do read the posting guide http://www.Rproject.org/postingguide.htmland provide commented, minimal, selfcontained, reproducible code.


Sandra Stankowski wrote:
> is.na function does'nt seem to work, but maybe I'm just dealing with it
> in a wrong way.
>
> here's an example
>
> > m < c(2, 3, 5, 6, 3, 7, 99, 99, 6)
> > n < c(1,1,1,1,1,2,2,2,2)
>
> so my matrix contains certain missing values
Thank you for the example.
You're constructing a data.frame, not a matrix.
Those are two separate classes in R.
> > m[m==99] < NA
> > o < data.frame(m, n)
> > o
> m n
> 1 2 1
> 2 3 1
> 3 5 1
> 4 6 1
> 5 3 1
> 6 7 2
> 7 NA 2
> 8 NA 2
> 9 6 2
>
> "2" stands for february
>
> > february < which(o[,2]==2, arr.ind = TRUE)
> > prec_feb < sum(o[february,1], na.rm = TRUE)
> > prec_feb
> [1] 13
>
> And now I need to know the exact number of rows, where "m" contains a
> value. to know how many days a month give any information. (to create
> monthly means and stuff)
You might find ?complete.cases useful.
Also try:
sum(!is.na(o$m))
?tapply may also be useful in general: e.g.,
tapply(o$m, o$n, mean, na.rm = TRUE)
None of this is tested...
>
> hope this explains, what I need to know.
>
> Thanks,
> S.
>
>
>
>
>
> Am 22.02.2011 16:50, schrieb Erik Iverson:
>> Sandra,
>>
>> Please provide a small, reproducible example of this issue.
>> You probably want to use ?is.nan and not the inequality
>> operator.
>>
>> Similar example, contrast:
>>
>> x < NA
>> is.na(x)
>> x == NA
>>
>> Sandra Stankowski wrote:
>>> Hey there,
>>>
>>> I tried to count the number of rows, where my data isn't NaN in a
>>> certain column.
>>>
>>> this was my guess:
>>>
>>> (given is a data frame with 2069 rows and 17 cols)
>>>
>>> NROW(data[jan,16] != NaN)
>>>
>>> ("jan" is defined this way: jan < which(data[,2]==1, arr.ind= TRUE))
>>>
>>>
>>> but I only get the number of columns where my data is "1" in the
>>> second col. R isn't removing the NaN.
>>> na.rm isn't working here.
>>>
>>> I would appreciate your help.
>>>
>>> ______________________________________________
>>> [hidden email] mailing list
>>> https://stat.ethz.ch/mailman/listinfo/rhelp>>> PLEASE do read the posting guide
>>> http://www.Rproject.org/postingguide.html>>> and provide commented, minimal, selfcontained, reproducible code.
>>
>
______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/rhelpPLEASE do read the posting guide http://www.Rproject.org/postingguide.htmland provide commented, minimal, selfcontained, reproducible code.


Thanks.
I made it!
Best wishes,
S.
Am 22.02.2011 17:41, schrieb Erik Iverson:
>
>
> Sandra Stankowski wrote:
>> is.na function does'nt seem to work, but maybe I'm just dealing with
>> it in a wrong way.
>>
>> here's an example
>>
>> > m < c(2, 3, 5, 6, 3, 7, 99, 99, 6)
>> > n < c(1,1,1,1,1,2,2,2,2)
>>
>> so my matrix contains certain missing values
>
> Thank you for the example.
> You're constructing a data.frame, not a matrix.
> Those are two separate classes in R.
>
>> > m[m==99] < NA
>> > o < data.frame(m, n)
>> > o
>> m n
>> 1 2 1
>> 2 3 1
>> 3 5 1
>> 4 6 1
>> 5 3 1
>> 6 7 2
>> 7 NA 2
>> 8 NA 2
>> 9 6 2
>>
>> "2" stands for february
>>
>> > february < which(o[,2]==2, arr.ind = TRUE)
>> > prec_feb < sum(o[february,1], na.rm = TRUE)
>> > prec_feb
>> [1] 13
>>
>> And now I need to know the exact number of rows, where "m" contains
>> a value. to know how many days a month give any information. (to
>> create monthly means and stuff)
>
> You might find ?complete.cases useful.
>
> Also try:
>
> sum(!is.na(o$m))
>
> ?tapply may also be useful in general: e.g.,
>
> tapply(o$m, o$n, mean, na.rm = TRUE)
>
> None of this is tested...
>
>>
>> hope this explains, what I need to know.
>>
>> Thanks,
>> S.
>>
>>
>>
>>
>>
>> Am 22.02.2011 16:50, schrieb Erik Iverson:
>>> Sandra,
>>>
>>> Please provide a small, reproducible example of this issue.
>>> You probably want to use ?is.nan and not the inequality
>>> operator.
>>>
>>> Similar example, contrast:
>>>
>>> x < NA
>>> is.na(x)
>>> x == NA
>>>
>>> Sandra Stankowski wrote:
>>>> Hey there,
>>>>
>>>> I tried to count the number of rows, where my data isn't NaN in a
>>>> certain column.
>>>>
>>>> this was my guess:
>>>>
>>>> (given is a data frame with 2069 rows and 17 cols)
>>>>
>>>> NROW(data[jan,16] != NaN)
>>>>
>>>> ("jan" is defined this way: jan < which(data[,2]==1, arr.ind= TRUE))
>>>>
>>>>
>>>> but I only get the number of columns where my data is "1" in the
>>>> second col. R isn't removing the NaN.
>>>> na.rm isn't working here.
>>>>
>>>> I would appreciate your help.
>>>>
>>>> ______________________________________________
>>>> [hidden email] mailing list
>>>> https://stat.ethz.ch/mailman/listinfo/rhelp>>>> PLEASE do read the posting guide
>>>> http://www.Rproject.org/postingguide.html>>>> and provide commented, minimal, selfcontained, reproducible code.
>>>
>>
>
______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/rhelpPLEASE do read the posting guide http://www.Rproject.org/postingguide.htmland provide commented, minimal, selfcontained, reproducible code.

