grpstats with nan values

조회 수: 6 (최근 30일)
Leah
Leah 2012년 12월 12일
편집: Giuseppe 2015년 11월 27일
so I thought you use nanmean and nansum to ignore nans with grpstats, but it seems that it always ignores them. I want a nan to be returned if there is a nan value present in the grouping. I can only get it work if all the values are nan and you are using mean. I tried to write an anonymous function, but the values are filtered out in the groupstat function before the anonymous function is called. Does anyone have any experience with this? Is it a bug? I'm in version 2010b
d=dataset({[1; 1; 1; 2; 2; 2],'id'},{rand(6,1),'value'})
d.value(1)=nan()
grpstats(d,'id',{'mean' 'sum'})
d.value(1:3)=nan()
grpstats(d,'id',{'mean' 'sum'})
  댓글 수: 1
Giuseppe
Giuseppe 2015년 11월 27일
편집: Giuseppe 2015년 11월 27일
It is documented in the guide:
grpstats treats NaNs as missing values, and removes them from the input data before calculating summary statistics.
grpstats ignores empty group names.
Still, I think it is a very bad choice. This function must not be used for calculations, but just to obtain summary statistics to display.

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 NaNs에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by