Bar chart

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Bar chart

D.R. Wahlgren
Folks,
I'd like to create a bar chart but I'm not familiar enough with SPSS'
chart builder to pull this off.  It seems simple enough, but it
involve plotting frequency counts across cases, rather than plotting
values as they were entered in the data set.  Hopefully one of you
can easily point me in the right direction.

The cases in my data were entered manually by two people. I'd like to
graph the total number of cases that were entered by each person, by
week.  I have a variable that codes the date each case was entered
(DE_fulldate) and a variable coding who entered it (DE_staff values 1
and 2).

So for example, the x-axis would be Week and y-axis would be # of
cases entered.  There would be two bars per week, corresponding to
person 1 and person 2.

Can this be done directly in the chart builder or do I need to
compute new variables first?

Incidentally, so far I've just been eyeballing frequencies using the
following syntax, repeated for consecutive 1-week intervals:

temp.
select if (DE_fulldate ge date.mdy(8,1,2010)) and (DE_fulldate le
date.mdy(8,7,2010)).
freq DE_staff.

Thanks,
Dennis

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD
Reply | Threaded
Open this post in threaded view
|

Re: Bar chart

ViAnn Beadle
Show us your data structure. What defines a case?

-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of
D.R. Wahlgren
Sent: Thursday, September 23, 2010 4:45 PM
To: [hidden email]
Subject: Bar chart

Folks,
I'd like to create a bar chart but I'm not familiar enough with SPSS'
chart builder to pull this off.  It seems simple enough, but it involve
plotting frequency counts across cases, rather than plotting values as they
were entered in the data set.  Hopefully one of you can easily point me in
the right direction.

The cases in my data were entered manually by two people. I'd like to graph
the total number of cases that were entered by each person, by week.  I have
a variable that codes the date each case was entered
(DE_fulldate) and a variable coding who entered it (DE_staff values 1 and
2).

So for example, the x-axis would be Week and y-axis would be # of cases
entered.  There would be two bars per week, corresponding to person 1 and
person 2.

Can this be done directly in the chart builder or do I need to compute new
variables first?

Incidentally, so far I've just been eyeballing frequencies using the
following syntax, repeated for consecutive 1-week intervals:

temp.
select if (DE_fulldate ge date.mdy(8,1,2010)) and (DE_fulldate le
date.mdy(8,7,2010)).
freq DE_staff.

Thanks,
Dennis

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command SIGNOFF SPSSX-L For a list of
commands to manage subscriptions, send the command INFO REFCARD

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD
Reply | Threaded
Open this post in threaded view
|

Re: Bar chart

Albert-Jan Roskam
In reply to this post by D.R. Wahlgren
Hi,

The R code below generates this graph: http://img338.imageshack.us/img338/5808/graphu.gif

You can put it in a begin/end program R block.

# sample data
dts <- Sys.Date() - round(runif(100, 0, 200))
weekno <- format(as.Date(dts), "%U")
ncases <- round(runif(100, 0, 100))
person <- round(runif(100, 0, 1))
df <- data.frame(weekno, ncases, person)

# actual code
library(ggplot2)
m <- ggplot(df, aes(x = weekno, fill=factor(person)))
m + geom_bar()

Cheers!!
Albert-Jan

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
All right, but apart from the sanitation, the medicine, education, wine, public order, irrigation, roads, a fresh water system, and public health, what have the Romans ever done for us?
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

--- On Fri, 9/24/10, D.R. Wahlgren <[hidden email]> wrote:

From: D.R. Wahlgren <[hidden email]>
Subject: [SPSSX-L] Bar chart
To: [hidden email]
Date: Friday, September 24, 2010, 12:44 AM

Folks,
I'd like to create a bar chart but I'm not familiar enough with SPSS'
chart builder to pull this off.  It seems simple enough, but it
involve plotting frequency counts across cases, rather than plotting
values as they were entered in the data set.  Hopefully one of you
can easily point me in the right direction.

The cases in my data were entered manually by two people. I'd like to
graph the total number of cases that were entered by each person, by
week.  I have a variable that codes the date each case was entered
(DE_fulldate) and a variable coding who entered it (DE_staff values 1
and 2).

So for example, the x-axis would be Week and y-axis would be # of
cases entered.  There would be two bars per week, corresponding to
person 1 and person 2.

Can this be done directly in the chart builder or do I need to
compute new variables first?

Incidentally, so far I've just been eyeballing frequencies using the
following syntax, repeated for consecutive 1-week intervals:

temp.
select if (DE_fulldate ge date.mdy(8,1,2010)) and (DE_fulldate le
date.mdy(8,7,2010)).
freq DE_staff.

Thanks,
Dennis

=====================
To manage your subscription to SPSSX-L, send a message to
LISTSERV@... (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD

Reply | Threaded
Open this post in threaded view
|

Re: Bar chart

Spousta Jan
In reply to this post by D.R. Wahlgren
Hi Dennis,

Try this (the solution is in the last rows of the syntax):

* prepare a datafile with a similar structure.
INPUT PROGRAM.
+  LOOP #I = 1 TO 1000.
+     COMPUTE DE_staff = 1.
+     IF uniform(1) > 0.6 DE_staff = 2.
+     COMPUTE DE_fulldate = DATE.YRDAY(2010,rnd(uniform(100))+1).
+     FORMATS DE_fulldate (date11) / DE_staff (F1.0).
+     END CASE.
+   END LOOP.
+   END FILE.
END INPUT PROGRAM.
EXECUTE.

* create the week variable .
COMPUTE week = XDATE.WEEK(DE_fulldate).
FORMATS week (F2.0).

* and create a graph.
GRAPH
  /BAR(GROUPED)=COUNT BY week BY DE_staff.


Hope this helps,

Jan


-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of D.R. Wahlgren
Sent: Friday, September 24, 2010 12:45 AM
To: [hidden email]
Subject: Bar chart

Folks,
I'd like to create a bar chart but I'm not familiar enough with SPSS'
chart builder to pull this off.  It seems simple enough, but it involve plotting frequency counts across cases, rather than plotting values as they were entered in the data set.  Hopefully one of you can easily point me in the right direction.

The cases in my data were entered manually by two people. I'd like to graph the total number of cases that were entered by each person, by week.  I have a variable that codes the date each case was entered
(DE_fulldate) and a variable coding who entered it (DE_staff values 1 and 2).

So for example, the x-axis would be Week and y-axis would be # of cases entered.  There would be two bars per week, corresponding to person 1 and person 2.

Can this be done directly in the chart builder or do I need to compute new variables first?

Incidentally, so far I've just been eyeballing frequencies using the following syntax, repeated for consecutive 1-week intervals:

temp.
select if (DE_fulldate ge date.mdy(8,1,2010)) and (DE_fulldate le date.mdy(8,7,2010)).
freq DE_staff.

Thanks,
Dennis

=====================
To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD



_____________
Tato zpráva a všechny připojené soubory jsou důvěrné a určené výlučně adresátovi(-ům). Jestliže nejste oprávněným adresátem, je zakázáno jakékoliv zveřejňování, zprostředkování nebo jiné použití těchto informací. Jestliže jste tento mail dostali neoprávněně, prosím, uvědomte odesilatele a smažte zprávu i přiložené soubory. Odesilatel nezodpovídá za jakékoliv chyby nebo opomenutí způsobené tímto přenosem.

Jste si jisti, že opravdu potřebujete vytisknout tuto zprávu a/nebo její přílohy? Myslete na přírodu.


This message and any attached files are confidential and intended solely for the addressee(s). Any publication, transmission or other use of the information by a person or entity other than the intended addressee is prohibited. If you receive this in error please contact the sender and delete the message as well as all attached documents. The sender does not accept liability for any errors or omissions as a result of the transmission.

Are you sure that you really need a print version of this message and/or its attachments? Think about nature.

-.- --

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD
Reply | Threaded
Open this post in threaded view
|

Re: Bar chart

Luca Meyer-3
In reply to this post by D.R. Wahlgren
I am having some difficulties to connect to Internet and I am quite sure that by now you have got your answer, but here you have the syntax of a simple offline exercise I have done myself:

/* first I create some sample data (please notice that date is in European format but I guess it can be done in American format using ADATE10) */
NEW FILE.
DATA LIST /DATE (DATE10) ID (F1).
BEGIN DATA
13/09/20102
13/09/20101
14/09/20102
27/09/20101
28/09/20101
28/09/20102
END DATA.
EXE.
/* then I compute the week variable (needs to be string to have the ggraph wizard working corretly) */
STRING WEEK (A2).
COMPUTE WEEK=STRING(XDATE.WEEK(DATE),F2.0).
EXE.
/* finally I use the ggraph wizard to get the graph */
GGRAPH
 /GRAPHDATASET NAME="graphdataset" VARIABLES=WEEK COUNT()[name="COUNT"] ID MISSING=LISTWISE
   REPORTMISSING=NO
 /GRAPHSPEC SOURCE=INLINE.
BEGIN GPL
 SOURCE: s=userSource(id("graphdataset"))
 DATA: WEEK=col(source(s), name("WEEK"), unit.category())
 DATA: COUNT=col(source(s), name("COUNT"))
 DATA: ID=col(source(s), name("ID"), unit.category())
 COORD: rect(dim(1,2), cluster(3,0))
 GUIDE: axis(dim(3), label("WEEK"))
 GUIDE: axis(dim(2), label("Count"))
 GUIDE: legend(aesthetic(aesthetic.color.interior), label("ID"))
 SCALE: linear(dim(2), include(0))
 ELEMENT: interval(position(ID*COUNT*WEEK), color.interior(ID), shape.interior(shape.square))
END GPL.

HTH,
Luca

Luca Meyer
www.lucameyer.com
PASW Statistics v. 18.0.2 (2-apr-2010)
R version 2.9.2 (2009-08-24)
Mac OS X 10.6.4 (10F569) - kernel Darwin 10.4.0

Il giorno 24/set/2010, alle ore 00.44, D.R. Wahlgren ha scritto:

> Folks,
> I'd like to create a bar chart but I'm not familiar enough with SPSS'
> chart builder to pull this off.  It seems simple enough, but it
> involve plotting frequency counts across cases, rather than plotting
> values as they were entered in the data set.  Hopefully one of you
> can easily point me in the right direction.
>
> The cases in my data were entered manually by two people. I'd like to
> graph the total number of cases that were entered by each person, by
> week.  I have a variable that codes the date each case was entered
> (DE_fulldate) and a variable coding who entered it (DE_staff values 1
> and 2).
>
> So for example, the x-axis would be Week and y-axis would be # of
> cases entered.  There would be two bars per week, corresponding to
> person 1 and person 2.
>
> Can this be done directly in the chart builder or do I need to
> compute new variables first?
>
> Incidentally, so far I've just been eyeballing frequencies using the
> following syntax, repeated for consecutive 1-week intervals:
>
> temp.
> select if (DE_fulldate ge date.mdy(8,1,2010)) and (DE_fulldate le
> date.mdy(8,7,2010)).
> freq DE_staff.
>
> Thanks,
> Dennis
>
> =====================
> To manage your subscription to SPSSX-L, send a message to
> [hidden email] (not to SPSSX-L), with no body text except the
> command. To leave the list, send the command
> SIGNOFF SPSSX-L
> For a list of commands to manage subscriptions, send the command
> INFO REFCARD

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD
Reply | Threaded
Open this post in threaded view
|

Re: Bar chart

D.R. Wahlgren
In reply to this post by Spousta Jan
Thank you to those who responded (Jan, Luca, ViAnn and someone whose
name I've forgotten but who suggested a solution using R).  I have
since been swamped with other urgent tasks, but I intend to try these
suggestions as soon as I can.

Dennis

At 4:14 PM +0200 9/27/10, Spousta Jan wrote:

>Hi Dennis,
>
>Try this (the solution is in the last rows of the syntax):
>
>* prepare a datafile with a similar structure.
>INPUT PROGRAM.
>+  LOOP #I = 1 TO 1000.
>+     COMPUTE DE_staff = 1.
>+     IF uniform(1) > 0.6 DE_staff = 2.
>+     COMPUTE DE_fulldate = DATE.YRDAY(2010,rnd(uniform(100))+1).
>+     FORMATS DE_fulldate (date11) / DE_staff (F1.0).
>+     END CASE.
>+   END LOOP.
>+   END FILE.
>END INPUT PROGRAM.
>EXECUTE.
>
>* create the week variable .
>COMPUTE week = XDATE.WEEK(DE_fulldate).
>FORMATS week (F2.0).
>
>* and create a graph.
>GRAPH
>   /BAR(GROUPED)=COUNT BY week BY DE_staff.
>
>
>Hope this helps,
>
>Jan

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD