Skip to content

Bar Graph

4 messages · Keniajin Wambui, John, Jim Lemon

#
I am using R 3.0.2 on a 64 bit machine

I have a data set from 1989-2002. The data has four variables
serialno, date, admission ward, temperature and bcg scar.

serialno admin_ward date_admn bcg_scar temp_axilla yr
70162    Ward2         11-Oct-89       y           38.9 1989
70163     Ward1        11-Oct-91       y             37.2 1991
70164     Ward2       11-Oct-92        n               37.3 1992
70165     Ward1        11-Oct-93        y                38.9 1993
70166     Ward1       11-Oct-94          y              37.7 1994
70167      Ward1       11-Oct-95          y              40 1995


I want to do a bar graph of total data (serialno) vs *(data of one of
the variables) to show the available data vs total data over the years

i am using

gplot(dta, aes(temp_axilla, fill=admin_ward)) + geom_bar() +
  facet_grid(. ~ yr, scales = "free",margins=F) + geom_histogram(binwidth=300)

But can include the serialno which shows the data. how can I achieve this
#
On Mon, 11 Nov 2013 18:02:19 +0300
Keniajin Wambui <kiangati at gmail.com> wrote:

            
You really need to pay better attention somewhere.  There are six
variables in your example table for instance, not four.  You state you
want to do something with the serialno variable, but it is not used 
in your bit of code.  Also, given that serialno appears to be
unique in your example, a bar graph would be singularly uninformative.

You need to provide a better example of the data, and an actual example
of the code you are trying to use, including the libraries you've
loaded.  

jwdougherty
#
The serialno represents each individual in the data set.The total
count of the serialno will represent the whole sample

 I want to do a graph to compare the total data (serialno) vs each of
the remaining five variables yearly. i.e to show the total data
(serialno) vs available data for one of the variables in the above
case temp axilla.

The above code plot count of temp_axilla yearly,how can I include
serialno to be part of the plot?

I have used
library(ggplot2)
library(foreign)
utils package
On Tue, Nov 12, 2013 at 11:53 AM, jwd <jwd at surewest.net> wrote:

  
    
#
On 11/13/2013 07:20 PM, Keniajin Wambui wrote:
Hi Keniajim,
It is not easy to work out what you want. If each serial number is an 
individual and you want the total number of individuals (dataset is 
"mydata"):

length(unique(mydata$serialno))

If you want the total number of individuals per year:

nind<-function(x) return(length(unique(x)))
year<-as.numeric(format(as.Date(mydata$date_admn,"%d-%b-%y"),"%Y"))
by(mydata$serialno,mydata$year,nind)

Perhaps this will give you a start.

Jim