How to make overlay histogram with SPSS?

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

How to make overlay histogram with SPSS?

P.van Groenestijn
Dear List,

Is it possible to make an overlay picture of two histograms in SPSS and
if so, how?
I looked on the internet, for example on Levesque's site and in de
SPSS-list archive, but did not succeed.
Please help!

Pieter van Groenestijn
University of Nijmegen


--
RadboudUniversiteit Nijmegen
Faculteit Sociale Wetenschappen
Research Technische OndersteuningsGroep
Thomas van Aquinostraat 4.00.51
tel: 024-3612035
fax: 024-3612351
email: [hidden email]
hp: http://www.ru.nl/fsw/rtog/

=====================
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: How to make overlay histogram with SPSS?

ViAnn Beadle
Can you be more specific. What things are overlaid?

-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of
P.van Groenestijn
Sent: Monday, March 15, 2010 6:29 AM
To: [hidden email]
Subject: How to make overlay histogram with SPSS?

Dear List,

Is it possible to make an overlay picture of two histograms in SPSS and if
so, how?
I looked on the internet, for example on Levesque's site and in de SPSS-list
archive, but did not succeed.
Please help!

Pieter van Groenestijn
University of Nijmegen


--
RadboudUniversiteit Nijmegen
Faculteit Sociale Wetenschappen
Research Technische OndersteuningsGroep
Thomas van Aquinostraat 4.00.51
tel: 024-3612035
fax: 024-3612351
email: [hidden email]
hp: http://www.ru.nl/fsw/rtog/

=====================
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: How to make overlay histogram with SPSS?

P.van Groenestijn
The maximum values/categories of histogram 1 are the same as the mimimum
values/categories in histogram 2.

Pieter van Groenestijn
University of Nijmegen




RadboudUniversiteit Nijmegen
Faculteit Sociale Wetenschappen
Research Technische OndersteuningsGroep
Thomas van Aquinostraat 4.00.51
tel: 024-3612035
fax: 024-3612351
email: [hidden email]
hp: http://www.ru.nl/fsw/rtog/



ViAnn Beadle wrote:

> Can you be more specific. What things are overlaid?
>
> -----Original Message-----
> From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of
> P.van Groenestijn
> Sent: Monday, March 15, 2010 6:29 AM
> To: [hidden email]
> Subject: How to make overlay histogram with SPSS?
>
> Dear List,
>
> Is it possible to make an overlay picture of two histograms in SPSS and if
> so, how?
> I looked on the internet, for example on Levesque's site and in de SPSS-list
> archive, but did not succeed.
> Please help!
>
> Pieter van Groenestijn
> University of Nijmegen
>
>
> --
> RadboudUniversiteit Nijmegen
> Faculteit Sociale Wetenschappen
> Research Technische OndersteuningsGroep
> Thomas van Aquinostraat 4.00.51
> tel: 024-3612035
> fax: 024-3612351
> email: [hidden email]
> hp: http://www.ru.nl/fsw/rtog/
>
> =====================
> 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
>
>

=====================
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: How to make overlay histogram with SPSS?

ViAnn Beadle
So you have two scale level variables that you want to place in one chart
with no overlapping values? Do you want to visually distinguish the bars in
one from the bars in the other?

-----Original Message-----
From: P.van Groenestijn [mailto:[hidden email]]
Sent: Monday, March 15, 2010 8:32 AM
To: ViAnn Beadle
Cc: [hidden email]
Subject: Re: How to make overlay histogram with SPSS?

The maximum values/categories of histogram 1 are the same as the mimimum
values/categories in histogram 2.

Pieter van Groenestijn
University of Nijmegen




RadboudUniversiteit Nijmegen
Faculteit Sociale Wetenschappen
Research Technische OndersteuningsGroep
Thomas van Aquinostraat 4.00.51
tel: 024-3612035
fax: 024-3612351
email: [hidden email]
hp: http://www.ru.nl/fsw/rtog/



ViAnn Beadle wrote:

> Can you be more specific. What things are overlaid?
>
> -----Original Message-----
> From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf
> Of P.van Groenestijn
> Sent: Monday, March 15, 2010 6:29 AM
> To: [hidden email]
> Subject: How to make overlay histogram with SPSS?
>
> Dear List,
>
> Is it possible to make an overlay picture of two histograms in SPSS
> and if so, how?
> I looked on the internet, for example on Levesque's site and in de
> SPSS-list archive, but did not succeed.
> Please help!
>
> Pieter van Groenestijn
> University of Nijmegen
>
>
> --
> RadboudUniversiteit Nijmegen
> Faculteit Sociale Wetenschappen
> Research Technische OndersteuningsGroep Thomas van Aquinostraat
> 4.00.51
> tel: 024-3612035
> fax: 024-3612351
> email: [hidden email]
> hp: http://www.ru.nl/fsw/rtog/
>
> =====================
> 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
>
>

=====================
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: How to make overlay histogram with SPSS?

Albert-Jan Roskam
In reply to this post by ViAnn Beadle
hi,

See if the program below works for you. It generates overlaid density plots and overlaid histograms. It should also be possible to do both in one picture.

BEGIN PROGRAM R.

install.packages("ggplot2") # in case you don't have the ggplot2 package
library(ggplot2)

# real data
df <- spssdata.GetDataFromSPSS()

# sample data
df <- data.frame(X=rnorm(1000, mean=10), Y=rnorm(1000, mean=15))
df2 <- melt(df)

# density plot
ggplot(df2) + geom_freqpoly(aes(x = value,
     y = ..density.., colour = variable)) +
     labs(x = NULL) + opts(legend.position = "none") +
     opts(title = "Some density plots")

# overlay histograms
ggplot(df) +
 geom_histogram(aes(x=X), binwidth=0.1, colour="red", position = "identity") +
 geom_histogram(aes(x=Y), binwidth=0.1, colour="black", position = "identity") +
 opts(title = "Some histograms")

END PROGRAM.

Cheers!!
Albert-Jan

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In the face of ambiguity, refuse the temptation to guess.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

--- On Mon, 3/15/10, ViAnn Beadle <[hidden email]> wrote:

From: ViAnn Beadle <[hidden email]>
Subject: Re: [SPSSX-L] How to make overlay histogram with SPSS?
To: [hidden email]
Date: Monday, March 15, 2010, 3:15 PM

Can you be more specific. What things are overlaid?

-----Original Message-----
From: SPSSX(r) Discussion [mailto:SPSSX-L@...] On Behalf Of
P.van Groenestijn
Sent: Monday, March 15, 2010 6:29 AM
To: SPSSX-L@...
Subject: How to make overlay histogram with SPSS?

Dear List,

Is it possible to make an overlay picture of two histograms in SPSS and if
so, how?
I looked on the internet, for example on Levesque's site and in de SPSS-list
archive, but did not succeed.
Please help!

Pieter van Groenestijn
University of Nijmegen


--
RadboudUniversiteit Nijmegen
Faculteit Sociale Wetenschappen
Research Technische OndersteuningsGroep
Thomas van Aquinostraat 4.00.51
tel: 024-3612035
fax: 024-3612351
email: p.vangroenestijn@...
hp: http://www.ru.nl/fsw/rtog/

=====================
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

=====================
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: How to make overlay histogram with SPSS?

Albert-Jan Roskam
In reply to this post by P.van Groenestijn
Hi Jon,

Thank you! I read in Bob Muenchen's book (which I know you know as your name is mentioned in the front) that Gpl and Ggplot2 have the same basis, but I didn't know it came from Spss. It's incredibly powerful and the pictures can look really slick. I find ggplot2 somewhat slow though. In Gpl, is it also possible to overlay a graph of dataset A with a similar graph of dataset B, without actually having to physically merge them?

Actually, I was indeed wondering if a call to chooseCRANmirror() or
install.packages() works as intended when done under spss. Good to know that it's better to install things from within R.

Cheers!!
Albert-Jan

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In the face of ambiguity, refuse the temptation to guess.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

--- On Mon, 3/15/10, Jon K Peck <[hidden email]> wrote:

From: Jon K Peck <[hidden email]>
Subject: Re: [SPSSX-L] How to make overlay histogram with SPSS?
To: "Albert-Jan Roskam" <[hidden email]>, [hidden email]
Date: Monday, March 15, 2010, 9:26 PM


Two comments.

You might be interested to know that ggplot2 is an R implementation of the grammar of graphics developed by Lee Wilkinson at SPSS. GoG is what you see in GPL.  You could do something like this with the following syntax.  I have made one histogram red and the other blue and added some transparency so that you can see both sets of bars


* Chart Builder.
GGRAPH
  /GRAPHDATASET NAME="graphdataset" VARIABLES=salary salbegin MISSING=LISTWISE REPORTMISSING=NO
  /GRAPHSPEC SOURCE=INLINE.
BEGIN GPL
  SOURCE: s=userSource(id("graphdataset"))
  DATA: salary=col(source(s), name("salary"))
  DATA: salbegin=col(source(s), name("salbegin"))
  GUIDE: axis(dim(1), label("Salary"))
  GUIDE: axis(dim(2), label("Frequency"))
  ELEMENT: interval(position(summary.count(bin.rect(salary))),
shape.interior(shape.square),color(color.red),transparency.interior(transparency."0.5")))
  ELEMENT: interval(position(summary.count(bin.rect(salbegin))), shape.interior(shape.square),color(color.blue),transparency.interior(transparency.0.5")))
END GPL.

Second, if you install the R package this way, it will be visible in your SPSS installation but not in R run standalone.  It's better to install the package using the standalone R if you intend to use it more generally.  Also, you will probably get stopped by a firewall alert when install.packages is called, so watch out for a permission dialog that may well be buried under serveral layers of windows.
Jon Peck
SPSS, an IBM Company
[hidden email]
312-651-3435



From: Albert-Jan Roskam <[hidden email]>
To: [hidden email]
Date: 03/15/2010 01:55 PM
Subject: Re: [SPSSX-L] How to make overlay histogram with SPSS?
Sent by: "SPSSX(r) Discussion" <[hidden email]>





hi,

See if the program below works for you. It generates overlaid density plots and overlaid histograms. It should also be possible to do both in one picture.

BEGIN PROGRAM R.

install.packages("ggplot2") # in case you don't have the ggplot2 package
library(ggplot2)

# real data
df <- spssdata.GetDataFromSPSS()

# sample data
df <- data.frame(X=rnorm(1000, mean=10), Y=rnorm(1000, mean=15))
df2 <- melt(df)

# density plot
ggplot(df2) + geom_freqpoly(aes(x = value,
    y = ..density.., colour = variable)) +
    labs(x = NULL) + opts(legend.position = "none") +
    opts(title = "Some density plots")

# overlay histograms
ggplot(df) +
geom_histogram(aes(x=X), binwidth=0.1, colour="red", position = "identity") +
geom_histogram(aes(x=Y), binwidth=0.1, colour="black", position = "identity") +
opts(title = "Some histograms")

END PROGRAM.

Cheers!!
Albert-Jan

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In the face of ambiguity, refuse the temptation to guess.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

--- On Mon, 3/15/10, ViAnn Beadle <[hidden email]> wrote:


From: ViAnn Beadle <[hidden email]>
Subject: Re: [SPSSX-L] How to make overlay histogram with SPSS?
To: [hidden email]
Date: Monday, March 15, 2010, 3:15 PM

Can you be more specific. What things are overlaid?

-----Original Message-----
From: SPSSX(r) Discussion [mailto:
[hidden email]] On Behalf Of
P.van Groenestijn
Sent: Monday, March 15, 2010 6:29 AM
To:
[hidden email]
Subject: How to make overlay histogram with SPSS?

Dear List,

Is it possible to make an overlay picture of two histograms in SPSS and if
so, how?
I looked on the internet, for example on Levesque's site and in de SPSS-list
archive, but did not succeed.
Please help!

Pieter van Groenestijn
University of Nijmegen


--
RadboudUniversiteit Nijmegen
Faculteit Sociale Wetenschappen
Research Technische OndersteuningsGroep
Thomas van Aquinostraat 4.00.51
tel: 024-3612035
fax: 024-3612351
email:
[hidden email]
hp:
http://www.ru.nl/fsw/rtog/

=====================
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: How to make overlay histogram with SPSS?

ViAnn Beadle

Yes, it’s possible to overlay histograms from different datasets via different sources in the GPL but I suspect that the usual mechanism for defining a source in GPL via the GGRAPH procedure cannot do that. You’re always welcome to try it and tell us (<grin>).

 

From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Albert-Jan Roskam
Sent: Tuesday, March 16, 2010 12:44 PM
To: [hidden email]
Subject: Re: How to make overlay histogram with SPSS?

 

Hi Jon,

Thank you! I read in Bob Muenchen's book (which I know you know as your name is mentioned in the front) that Gpl and Ggplot2 have the same basis, but I didn't know it came from Spss. It's incredibly powerful and the pictures can look really slick. I find ggplot2 somewhat slow though. In Gpl, is it also possible to overlay a graph of dataset A with a similar graph of dataset B, without actually having to physically merge them?

Actually, I was indeed wondering if a call to chooseCRANmirror() or
install.packages() works as intended when done under spss. Good to know that it's better to install things from within R.

Cheers!!
Albert-Jan

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In the face of ambiguity, refuse the temptation to guess.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

--- On Mon, 3/15/10, Jon K Peck <[hidden email]> wrote:


From: Jon K Peck <[hidden email]>
Subject: Re: [SPSSX-L] How to make overlay histogram with SPSS?
To: "Albert-Jan Roskam" <[hidden email]>, [hidden email]
Date: Monday, March 15, 2010, 9:26 PM


Two comments.

You might be interested to know that ggplot2 is an R implementation of the grammar of graphics developed by Lee Wilkinson at SPSS. GoG is what you see in GPL.  You could do something like this with the following syntax.  I have made one histogram red and the other blue and added some transparency so that you can see both sets of bars


* Chart Builder.
GGRAPH
  /GRAPHDATASET NAME="graphdataset" VARIABLES=salary salbegin MISSING=LISTWISE REPORTMISSING=NO
  /GRAPHSPEC SOURCE=INLINE.
BEGIN GPL
  SOURCE: s=userSource(id("graphdataset"))
  DATA: salary=col(source(s), name("salary"))
  DATA: salbegin=col(source(s), name("salbegin"))
  GUIDE: axis(dim(1), label("Salary"))
  GUIDE: axis(dim(2), label("Frequency"))
  ELEMENT: interval(position(summary.count(bin.rect(salary))),
shape.interior(shape.square),color(color.red),transparency.interior(transparency."0.5")))
  ELEMENT: interval(position(summary.count(bin.rect(salbegin))), shape.interior(shape.square),color(color.blue),transparency.interior(transparency.0.5")))
END GPL.

Second, if you install the R package this way, it will be visible in your SPSS installation but not in R run standalone.  It's better to install the package using the standalone R if you intend to use it more generally.  Also, you will probably get stopped by a firewall alert when install.packages is called, so watch out for a permission dialog that may well be buried under serveral layers of windows.
Jon Peck
SPSS, an IBM Company
[hidden email]
312-651-3435


From:

Albert-Jan Roskam <[hidden email]>

To:

[hidden email]

Date:

03/15/2010 01:55 PM

Subject:

Re: [SPSSX-L] How to make overlay histogram with SPSS?

Sent by:

"SPSSX(r) Discussion" <[hidden email]>

 




hi,

See if the program below works for you. It generates overlaid density plots and overlaid histograms. It should also be possible to do both in one picture.

BEGIN PROGRAM R.

install.packages("ggplot2") # in case you don't have the ggplot2 package
library(ggplot2)

# real data
df <- spssdata.GetDataFromSPSS()

# sample data
df <- data.frame(X=rnorm(1000, mean=10), Y=rnorm(1000, mean=15))
df2 <- melt(df)

# density plot
ggplot(df2) + geom_freqpoly(aes(x = value,
    y = ..density.., colour = variable)) +
    labs(x = NULL) + opts(legend.position = "none") +
    opts(title = "Some density plots")

# overlay histograms
ggplot(df) +
geom_histogram(aes(x=X), binwidth=0.1, colour="red", position = "identity") +
geom_histogram(aes(x=Y), binwidth=0.1, colour="black", position = "identity") +
opts(title = "Some histograms")

END PROGRAM.

Cheers!!
Albert-Jan

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In the face of ambiguity, refuse the temptation to guess.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

--- On Mon, 3/15/10, ViAnn Beadle <[hidden email]> wrote:

From: ViAnn Beadle <[hidden email]>
Subject: Re: [SPSSX-L] How to make overlay histogram with SPSS?
To: [hidden email]
Date: Monday, March 15, 2010, 3:15 PM

Can you be more specific. What things are overlaid?

-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of
P.van Groenestijn
Sent: Monday, March 15, 2010 6:29 AM
To: [hidden email]
Subject: How to make overlay histogram with SPSS?

Dear List,

Is it possible to make an overlay picture of two histograms in SPSS and if
so, how?
I looked on the internet, for example on Levesque's site and in de SPSS-list
archive, but did not succeed.
Please help!

Pieter van Groenestijn
University of Nijmegen


--
RadboudUniversiteit Nijmegen
Faculteit Sociale Wetenschappen
Research Technische OndersteuningsGroep
Thomas van Aquinostraat 4.00.51
tel: 024-3612035
fax: 024-3612351
email: [hidden email]
hp: http://www.ru.nl/fsw/rtog/

=====================
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: How to make overlay histogram with SPSS?

P.van Groenestijn
Jon,

Superb solution, this is exactly I needed.
Thanks!

Pieter van Groenestijn

By the way the second 0.5 should be: "0.5"


RadboudUniversiteit Nijmegen
Faculteit Sociale Wetenschappen
Research Technische OndersteuningsGroep
Thomas van Aquinostraat 4.00.51
tel: 024-3612035
fax: 024-3612351
email: [hidden email]
hp: http://www.ru.nl/fsw/rtog/



ViAnn Beadle wrote:

>
> Yes, it’s possible to overlay histograms from different datasets via
> different sources in the GPL but I suspect that the usual mechanism
> for defining a source in GPL via the GGRAPH procedure cannot do that.
> You’re always welcome to try it and tell us (<grin>).
>
> *From:* SPSSX(r) Discussion [mailto:[hidden email]] *On
> Behalf Of *Albert-Jan Roskam
> *Sent:* Tuesday, March 16, 2010 12:44 PM
> *To:* [hidden email]
> *Subject:* Re: How to make overlay histogram with SPSS?
>
> Hi Jon,
>
> Thank you! I read in Bob Muenchen's book (which I know you know as
> your name is mentioned in the front) that Gpl and Ggplot2 have the
> same basis, but I didn't know it came from Spss. It's incredibly
> powerful and the pictures can look really slick. I find ggplot2
> somewhat slow though. In Gpl, is it also possible to overlay a graph
> of dataset A with a similar graph of dataset B, without actually
> having to physically merge them?
>
> Actually, I was indeed wondering if a call to chooseCRANmirror() or
> install.packages() works as intended when done under spss. Good to
> know that it's better to install things from within R.
>
> Cheers!!
> Albert-Jan
>
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> In the face of ambiguity, refuse the temptation to guess.
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>
> --- On *Mon, 3/15/10, Jon K Peck /<[hidden email]
> <mailto:[hidden email]>>/* wrote:
>
>
> From: Jon K Peck <[hidden email] <mailto:[hidden email]>>
> Subject: Re: [SPSSX-L] How to make overlay histogram with SPSS?
> To: "Albert-Jan Roskam" <[hidden email] <mailto:[hidden email]>>,
> [hidden email] <mailto:[hidden email]>
> Date: Monday, March 15, 2010, 9:26 PM
>
>
> Two comments.
>
> You might be interested to know that ggplot2 is an R implementation of
> the grammar of graphics developed by Lee Wilkinson at SPSS. GoG is
> what you see in GPL. You could do something like this with the
> following syntax. I have made one histogram red and the other blue and
> added some transparency so that you can see both sets of bars
>
>
> * Chart Builder.
> GGRAPH
> /GRAPHDATASET NAME="graphdataset" VARIABLES=salary salbegin
> MISSING=LISTWISE REPORTMISSING=NO
> /GRAPHSPEC SOURCE=INLINE.
> BEGIN GPL
> SOURCE: s=userSource(id("graphdataset"))
> DATA: salary=col(source(s), name("salary"))
> DATA: salbegin=col(source(s), name("salbegin"))
> GUIDE: axis(dim(1), label("Salary"))
> GUIDE: axis(dim(2), label("Frequency"))
> ELEMENT: interval(position(summary.count(bin.rect(salary))),
> shape.interior(shape.square),color(color.red),transparency.interior(transparency."0.5")))
>
> ELEMENT: interval(position(summary.count(bin.rect(salbegin))),
> shape.interior(shape.square),color(color.blue),transparency.interior(transparency.0.5")))
>
> END GPL.
>
> Second, if you install the R package this way, it will be visible in
> your SPSS installation but not in R run standalone. It's better to
> install the package using the standalone R if you intend to use it
> more generally. Also, you will probably get stopped by a firewall
> alert when install.packages is called, so watch out for a permission
> dialog that may well be buried under serveral layers of windows.
> Jon Peck
> SPSS, an IBM Company
> [hidden email] <mailto:[hidden email]>
> 312-651-3435
>
> From:
>
>
>
> Albert-Jan Roskam <[hidden email]>
>
> To:
>
>
>
> [hidden email]
>
> Date:
>
>
>
> 03/15/2010 01:55 PM
>
> Subject:
>
>
>
> Re: [SPSSX-L] How to make overlay histogram with SPSS?
>
> Sent by:
>
>
>
> "SPSSX(r) Discussion" <[hidden email]>
>
> ------------------------------------------------------------------------
>
>
>
> hi,
>
> See if the program below works for you. It generates overlaid density
> plots and overlaid histograms. It should also be possible to do both
> in one picture.
>
> BEGIN PROGRAM R.
>
> install.packages("ggplot2") # in case you don't have the ggplot2 package
> library(ggplot2)
>
> # real data
> df <- spssdata.GetDataFromSPSS()
>
> # sample data
> df <- data.frame(X=rnorm(1000, mean=10), Y=rnorm(1000, mean=15))
> df2 <- melt(df)
>
> # density plot
> ggplot(df2) + geom_freqpoly(aes(x = value,
> y = ..density.., colour = variable)) +
> labs(x = NULL) + opts(legend.position = "none") +
> opts(title = "Some density plots")
>
> # overlay histograms
> ggplot(df) +
> geom_histogram(aes(x=X), binwidth=0.1, colour="red", position =
> "identity") +
> geom_histogram(aes(x=Y), binwidth=0.1, colour="black", position =
> "identity") +
> opts(title = "Some histograms")
>
> END PROGRAM.
>
> Cheers!!
> Albert-Jan
>
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> In the face of ambiguity, refuse the temptation to guess.
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>
> --- On *Mon, 3/15/10, ViAnn Beadle /<[hidden email]
> <mailto:[hidden email]>>/* wrote:
>
> From: ViAnn Beadle <[hidden email] <mailto:[hidden email]>>
> Subject: Re: [SPSSX-L] How to make overlay histogram with SPSS?
> To: [hidden email] <mailto:[hidden email]>
> Date: Monday, March 15, 2010, 3:15 PM
>
> Can you be more specific. What things are overlaid?
>
> -----Original Message-----
> From: SPSSX(r) Discussion [mailto:[hidden email].EDU_] On Behalf Of
> P.van Groenestijn
> Sent: Monday, March 15, 2010 6:29 AM
> To: [hidden email].EDU_
> Subject: How to make overlay histogram with SPSS?
>
> Dear List,
>
> Is it possible to make an overlay picture of two histograms in SPSS and if
> so, how?
> I looked on the internet, for example on Levesque's site and in de
> SPSS-list
> archive, but did not succeed.
> Please help!
>
> Pieter van Groenestijn
> University of Nijmegen
>
>
> --
> RadboudUniversiteit Nijmegen
> Faculteit Sociale Wetenschappen
> Research Technische OndersteuningsGroep
> Thomas van Aquinostraat 4.00.51
> tel: 024-3612035
> fax: 024-3612351
> email: [hidden email] <mailto:[hidden email]>_
> hp: http://www.ru.nl/fsw/rtog/
>
> =====================
> To manage your subscription to SPSSX-L, send a message to_
> [hidden email] <mailto:[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] <mailto:[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