[R] Plotting graph for Missing values

jim holtman jholtman at gmail.com
Mon Jan 26 03:29:42 CET 2009


Here is an example of how you might approach it:

> dos <- seq(as.Date('2006-05-01'), as.Date('2007-03-31'), by='1 day')
> pat1 <- rbinom(length(dos), 1, .5)  # generate some data
> # partition by month and then list out the number of zero values (missing)
> tapply(pat1, format(dos, "%Y%m"), function(x) sum(x==0))
200605 200606 200607 200608 200609 200610 200611 200612 200701 200702 200703
    21     22     16     18     16     15     16     17     14     16     13
>


On Sun, Jan 25, 2009 at 8:51 PM, Shreyasee <shreyasee.pradhan at gmail.com> wrote:
> Hi Jim,
>
> The dataset has 4 variables (dos, patientinformation1, patientinformation2,
> patientinformation3).
> In dos variable ther are months (May 2006 to March 2007) when the surgeries
> were formed.
> I need to calculate the percentage of missing values for each variable
> (patientinformation1, patientinformation2, patientinformation3) for each
> month.
> I need a common script to calculate that for each variable.
>
> Thanks,
> Shreyasee
>
>
> On Mon, Jan 26, 2009 at 9:46 AM, jim holtman <jholtman at gmail.com> wrote:
>>
>> What does you data look like?  You could use 'split' and then examine
>> the data in each range to count the number missing.  Would have to
>> have some actual data to suggest a solution.
>>
>> On Sun, Jan 25, 2009 at 8:30 PM, Shreyasee <shreyasee.pradhan at gmail.com>
>> wrote:
>> > Hi,
>> >
>> > I have imported one dataset in R.
>> > I want to calculate the percentage of missing values for each month (May
>> > 2006 to March 2007) for each variable.
>> > Just to begin with I tried the following code :
>> >
>> > *for(i in 1:length(dos))
>> > for(j in 1:length(patientinformation1)
>> > if(dos[i]=="May-06" && patientinformation1[j]=="")
>> > a <- j+1
>> > a*
>> >
>> > The above code was written to calculate the number of missing values for
>> > May
>> > 2006, but I am not getting the correct results.
>> > Can anybody help me?
>> >
>> > Thanks,
>> > Shreyasee
>> >
>> >        [[alternative HTML version deleted]]
>> >
>> > ______________________________________________
>> > R-help at r-project.org mailing list
>> > https://stat.ethz.ch/mailman/listinfo/r-help
>> > PLEASE do read the posting guide
>> > http://www.R-project.org/posting-guide.html
>> > and provide commented, minimal, self-contained, reproducible code.
>> >
>>
>>
>>
>> --
>> Jim Holtman
>> Cincinnati, OH
>> +1 513 646 9390
>>
>> What is the problem that you are trying to solve?
>
>



-- 
Jim Holtman
Cincinnati, OH
+1 513 646 9390

What is the problem that you are trying to solve?




More information about the R-help mailing list