plot in package psych with function error.bars.by

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

plot in package psych with function error.bars.by

Tham Tran
Hi,

I have a problem with the function "error.bars.by" in package "psych".
This is the code for example of a graph:

keys.list=list(Agree=c(-1,2:5),Conscientious=c(6:8,-9,-10),Extraversion=c(-11,-12,13:15),Neuroticism=c(16:20),Openness = c(21,-22,23,24,-25))
keys = make.keys(28,keys.list,item.labels=colnames(bfi))
scores = score.items(keys,bfi,min=1,max=6)
require(psych)
error.bars.by(scores$scores,round(bfi$age/10)*10,by.var=TRUE,
main="BFI age trends",legend=3,labels=colnames(scores$scores),
xlab="Age",ylab="Mean item score")

I need to change the plotting character and line type of the graph according to the scores (Agree,Conscientious,Extraticism,Openness).

I have tried with:
error.bars.by(scores$scores,round(bfi$age/10)*10,by.var=TRUE,
main="BFI age trends",legend=3,labels=colnames(scores$scores), pch=c(1,2,3,4), lty=1
,xlab="Age",ylab="Mean item score")

But there is a problem:
Error in localWindow(xlim, ylim, log, asp, ...) :  formal argument "pch" matched by multiple actual arguments

Anyone can help me for this problem.
Many thanks.

Tham Tran
Reply | Threaded
Open this post in threaded view
|

Re: plot in package psych with function error.bars.by

Jim Lemon
On Mon, 2 Jun 2014 11:28:19 PM Tham Tran wrote:
> Hi,
>
> I have a problem with the function "error.bars.by" in package
"psych".
> This is the code for example of a graph:
>
>
keys.list=list(Agree=c(-1,2:5),Conscientious=c(6:8,-9,-10),Extraversion=c(-1
> 1,-12,13:15),Neuroticism=c(16:20),Openness =
c(21,-22,23,24,-25))
> keys = make.keys(28,keys.list,item.labels=colnames(bfi))
> scores = score.items(keys,bfi,min=1,max=6)
> require(psych)
> error.bars.by(scores$scores,round(bfi$age/10)*10,by.var=TRUE,
> main="BFI age trends",legend=3,labels=colnames(scores$scores),
> xlab="Age",ylab="Mean item score")
>
> I need to change the plotting character and line type of the graph
according

> to the scores (Agree,Conscientious,Extraticism,Openness).
>
> I have tried with:
> error.bars.by(scores$scores,round(bfi$age/10)*10,by.var=TRUE,
> main="BFI age trends",legend=3,labels=colnames(scores$scores),
> pch=c(1,2,3,4), lty=1
> ,xlab="Age",ylab="Mean item score")
>
> But there is a problem:
> Error in localWindow(xlim, ylim, log, asp, ...) :  formal argument "pch"
> matched by multiple actual arguments
>
> Anyone can help me for this problem.

Hi Tham,
When I run your example, I get the following error:

Error in seq.default(clim, -clim, 0.01) :
  'from' cannot be NA, NaN or infinite
In addition: Warning messages:
1: In qt(1 - alpha/2, group.stats[[g]]$n - 1) : NaNs produced
2: In dt(ln, n - 1) : NaNs produced
3: In qt(alpha/2, n - 1) : NaNs produced

As I don't know what is happening here, I can't do anything about the
pch problem.

Jim

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: plot in package psych with function error.bars.by

Tham Tran
Hi Jim,

Thank you for your answers.

I also don't know where does the error like you mentioned come from. But for me, R works normally with the codes following:

require(psych)
keys.list=list(Agree=c(-1,2:5),Conscientious=c(6:8,-9,-10),Extraversion=c(-11,-12,13:15),Neuroticism=c(16:20),Openness = c(21,-22,23,24,-25))
keys = make.keys(28,keys.list,item.labels=colnames(bfi))
scores = score.items(keys,bfi,min=1,max=6)
error.bars.by(scores$scores,round(bfi$age/10)*10,by.var=TRUE,main="BFI age trends",legend=3,labels=colnames(scores$scores),xlab="Age",ylab="Mean item score")

I have retried and it is running
Except when i want to change the plotting character and line type of the graph by the code below:

error.bars.by(scores$scores,round(bfi$age/10)*10,by.var=TRUE,main="BFI age trends",legend=3,labels=colnames(scores$scores),xlab="Age",ylab="Mean item score",pch=c(1,2,3,4), lty=1)

i get the error.

Tham.  
Reply | Threaded
Open this post in threaded view
|

Re: plot in package psych with function error.bars.by

William Revelle
In reply to this post by Jim Lemon
Tham and Jim,
  As usual, my first response to this is when you find a problem with the psych package, write me (as author) as well as the R-help list.

In addition, always include which version of psych you are running.  That will help in the debugging.  The current version 1.4.5 on CRAN draws “cats eyes” instead of error bars, unless you turn off that option.
You might find that useful.


Then, my comment to Tham,

Yes, you have found a weakness (some would say a bug) in that I currently default the base plot character to be 15. I will correct this in the next release (which won’t be shipped to CRAN until mid to late July).  In the interim, I will try to get a fix up on the personality-project.org/r  repository by early next week.

To Jim,  I can not get your error at all.  Tham was finding a problem with the basic example, which works, unless you try to specify the pch, which doesn’t work.

Bill





On Jun 3, 2014, at 4:10 PM, Jim Lemon <[hidden email]> wrote:

> On Mon, 2 Jun 2014 11:28:19 PM Tham Tran wrote:
>> Hi,
>>
>> I have a problem with the function "error.bars.by" in package
> "psych".
>> This is the code for example of a graph:
>>
>>
> keys.list=list(Agree=c(-1,2:5),Conscientious=c(6:8,-9,-10),Extraversion=c(-1
>> 1,-12,13:15),Neuroticism=c(16:20),Openness =
> c(21,-22,23,24,-25))
>> keys = make.keys(28,keys.list,item.labels=colnames(bfi))
>> scores = score.items(keys,bfi,min=1,max=6)
>> require(psych)
>> error.bars.by(scores$scores,round(bfi$age/10)*10,by.var=TRUE,
>> main="BFI age trends",legend=3,labels=colnames(scores$scores),
>> xlab="Age",ylab="Mean item score")
>>
>> I need to change the plotting character and line type of the graph
> according
>> to the scores (Agree,Conscientious,Extraticism,Openness).
>>
>> I have tried with:
>> error.bars.by(scores$scores,round(bfi$age/10)*10,by.var=TRUE,
>> main="BFI age trends",legend=3,labels=colnames(scores$scores),
>> pch=c(1,2,3,4), lty=1
>> ,xlab="Age",ylab="Mean item score")
>>
>> But there is a problem:
>> Error in localWindow(xlim, ylim, log, asp, ...) :  formal argument "pch"
>> matched by multiple actual arguments
>>
>> Anyone can help me for this problem.
>
> Hi Tham,
> When I run your example, I get the following error:
>
> Error in seq.default(clim, -clim, 0.01) :
>  'from' cannot be NA, NaN or infinite
> In addition: Warning messages:
> 1: In qt(1 - alpha/2, group.stats[[g]]$n - 1) : NaNs produced
> 2: In dt(ln, n - 1) : NaNs produced
> 3: In qt(alpha/2, n - 1) : NaNs produced
>
> As I don't know what is happening here, I can't do anything about the
> pch problem.
>
> Jim
>
> ______________________________________________
> [hidden email] 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.
>

William Revelle           http://personality-project.org/revelle.html
Professor           http://personality-project.org
Department of Psychology   http://www.wcas.northwestern.edu/psych/
Northwestern University   http://www.northwestern.edu/
Use R for psychology             http://personality-project.org/r
It is 5 minutes to midnight   http://www.thebulletin.org

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: plot in package psych with function error.bars.by

Tham Tran
Dear William,

Thanks to your answer, i no longer waste time trying to get a solution for this question. I'm waiting your next release.

Tham

Reply | Threaded
Open this post in threaded view
|

Re: plot in package psych with function error.bars.by

William Revelle
In reply to this post by William Revelle
Tham and Jim,

The Mac version of psych_1.4.6.11 is now on the personalty.project.org/r   server  repository.  The PC version  is at personality-project/r/src/contrib/  as a zip file:  psych_1.4.6.11.zip

For a Mac, just set your other repository to personalty.project.org/r and install the source version.  For a PC you need to ftp or http to personality-project/r/src/contrib/ to get the zip file.

This partially fixes the pch request from Tham.  (That is to say, you can set the first pch.  The others are just the sequence above that one.).

Let me know if you have problems.

Bill

 
On Jun 7, 2014, at 3:10 PM, William Revelle <[hidden email]> wrote:

> Tham and Jim,
>  As usual, my first response to this is when you find a problem with the psych package, write me (as author) as well as the R-help list.
>
> In addition, always include which version of psych you are running.  That will help in the debugging.  The current version 1.4.5 on CRAN draws “cats eyes” instead of error bars, unless you turn off that option.
> You might find that useful.
>
>
> Then, my comment to Tham,
>
> Yes, you have found a weakness (some would say a bug) in that I currently default the base plot character to be 15. I will correct this in the next release (which won’t be shipped to CRAN until mid to late July).  In the interim, I will try to get a fix up on the personality-project.org/r  repository by early next week.
>
> To Jim,  I can not get your error at all.  Tham was finding a problem with the basic example, which works, unless you try to specify the pch, which doesn’t work.
>
> Bill
>
>
>
>
>
> On Jun 3, 2014, at 4:10 PM, Jim Lemon <[hidden email]> wrote:
>
>> On Mon, 2 Jun 2014 11:28:19 PM Tham Tran wrote:
>>> Hi,
>>>
>>> I have a problem with the function "error.bars.by" in package
>> "psych".
>>> This is the code for example of a graph:
>>>
>>>
>> keys.list=list(Agree=c(-1,2:5),Conscientious=c(6:8,-9,-10),Extraversion=c(-1
>>> 1,-12,13:15),Neuroticism=c(16:20),Openness =
>> c(21,-22,23,24,-25))
>>> keys = make.keys(28,keys.list,item.labels=colnames(bfi))
>>> scores = score.items(keys,bfi,min=1,max=6)
>>> require(psych)
>>> error.bars.by(scores$scores,round(bfi$age/10)*10,by.var=TRUE,
>>> main="BFI age trends",legend=3,labels=colnames(scores$scores),
>>> xlab="Age",ylab="Mean item score")
>>>
>>> I need to change the plotting character and line type of the graph
>> according
>>> to the scores (Agree,Conscientious,Extraticism,Openness).
>>>
>>> I have tried with:
>>> error.bars.by(scores$scores,round(bfi$age/10)*10,by.var=TRUE,
>>> main="BFI age trends",legend=3,labels=colnames(scores$scores),
>>> pch=c(1,2,3,4), lty=1
>>> ,xlab="Age",ylab="Mean item score")
>>>
>>> But there is a problem:
>>> Error in localWindow(xlim, ylim, log, asp, ...) :  formal argument "pch"
>>> matched by multiple actual arguments
>>>
>>> Anyone can help me for this problem.
>>
>> Hi Tham,
>> When I run your example, I get the following error:
>>
>> Error in seq.default(clim, -clim, 0.01) :
>> 'from' cannot be NA, NaN or infinite
>> In addition: Warning messages:
>> 1: In qt(1 - alpha/2, group.stats[[g]]$n - 1) : NaNs produced
>> 2: In dt(ln, n - 1) : NaNs produced
>> 3: In qt(alpha/2, n - 1) : NaNs produced
>>
>> As I don't know what is happening here, I can't do anything about the
>> pch problem.
>>
>> Jim
>>
>> ______________________________________________
>> [hidden email] 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.
>>
>
> William Revelle           http://personality-project.org/revelle.html
> Professor           http://personality-project.org
> Department of Psychology   http://www.wcas.northwestern.edu/psych/
> Northwestern University   http://www.northwestern.edu/
> Use R for psychology             http://personality-project.org/r
> It is 5 minutes to midnight   http://www.thebulletin.org
>
> ______________________________________________
> [hidden email] 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.
>

William Revelle           http://personality-project.org/revelle.html
Professor           http://personality-project.org
Department of Psychology   http://www.wcas.northwestern.edu/psych/
Northwestern University   http://www.northwestern.edu/
Use R for psychology             http://personality-project.org/r
It is 5 minutes to midnight   http://www.thebulletin.org

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: plot in package psych with function error.bars.by

Tham Tran
Hi William,

I've just updated your latest package "psych_1.4.6.11.zip" from server "personality-project/r/src/contrib/". One time the updating process was finished, i tried to run based samples code:

require(psych)
keys.list=list(Agree=c(-1,2:5),Conscientious=c(6:8,-9,-10),Extraversion=c(-11,-12,13:15),Neuroticism=c(16:20),Openness = c(21,-22,23,24,-25))
keys = make.keys(28,keys.list,item.labels=colnames(bfi))
scores = scoreItems(keys,bfi,min=1,max=6)
error.bars.by(scores$scores,round(bfi$age/10)*10,by.var=TRUE,main="BFI age trends",legend=3,labels=colnames(scores$scores),xlab="Age",ylab="Mean item score")

then i had an error following:

Erreur dans if (del == 0 && to == 0) return(to) :
  valeur manquante là où TRUE / FALSE est requis
De plus : Messages d'avis :
1: In qt(1 - alpha/2, group.stats[[g]]$n - 1) : production de NaN
2: In dt(ln, n - 1) : production de NaN
3: In qt(alpha/2, n - 1) : production de NaN

Could you tell me how to fix these issues? May i had a mistake of updating your lasted package?

Sincerly
Tham


Reply | Threaded
Open this post in threaded view
|

Re: plot in package psych with function error.bars.by

William Revelle-3
Tham,
   What you have found is that the cats eyes of the error bars will throw an error if there no variance for a cell (or, just one person in a cell). This I will fix so that it complains but doesn’t quit.

The example you were running was filtering out the subjects less than 10 years old and more than 80.  This was done to avoid the problem you detected.

You can actually draw the plot with error bars and the pch specified as you wanted, if you set eyes=FALSE.  This gives the error bars without the offending cats eyes.

I will have an update on the server in about two days.

Bill

On Jun 16, 2014, at 2:52 AM, Tham Tran <[hidden email]> wrote:

> Hi William,
>
> I've just updated your latest package "psych_1.4.6.11.zip" from server
> "personality-project/r/src/contrib/". One time the updating process was
> finished, i tried to run based samples code:
>
> require(psych)
> keys.list=list(Agree=c(-1,2:5),Conscientious=c(6:8,-9,-10),Extraversion=c(-11,-12,13:15),Neuroticism=c(16:20),Openness
> = c(21,-22,23,24,-25))
> keys = make.keys(28,keys.list,item.labels=colnames(bfi))
> scores = scoreItems(keys,bfi,min=1,max=6)
> error.bars.by(scores$scores,round(bfi$age/10)*10,by.var=TRUE,main="BFI age
> trends",legend=3,labels=colnames(scores$scores),xlab="Age",ylab="Mean item
> score")
>
> then i had an error following:
>
> Erreur dans if (del == 0 && to == 0) return(to) :
>  valeur manquante là où TRUE / FALSE est requis
> De plus : Messages d'avis :
> 1: In qt(1 - alpha/2, group.stats[[g]]$n - 1) : production de NaN
> 2: In dt(ln, n - 1) : production de NaN
> 3: In qt(alpha/2, n - 1) : production de NaN
>
> Could you tell me how to fix these issues? May i had a mistake of updating
> your lasted package?
>
> Sincerly
> Tham
>
>
>
>
>
>
> --
> View this message in context: http://r.789695.n4.nabble.com/plot-in-package-psych-with-function-error-bars-by-tp4691632p4692177.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> [hidden email] 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.

William Revelle           http://personality-project.org/revelle.html
Professor           http://personality-project.org
Department of Psychology   http://www.wcas.northwestern.edu/psych/
Northwestern University   http://www.northwestern.edu/
Use R for psychology             http://personality-project.org/r
It is 5 minutes to midnight   http://www.thebulletin.org

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: plot in package psych with function error.bars.by

William Revelle
In reply to this post by Tham Tran

Dear Tham,

The example you were running was filtering out the subjects less than 10 years old and more than 80.  Somehow you suppressed this filtering which lead to the error message.  The filtering was done to avoid the problem you detected.

I have fixed error.bars.by so that it now will just complain if there is only one case (and thus no error) in a cell.  In this case, it will not draw the “cats eye” error bars.

The Mac version of psych_1.4.6.18 is now on the personalty.project.org/r   server  repository.  The PC version  is at personality-project/r/src/contrib/  as a zip file:  psych_1.4.6.18.zip

For a Mac, just set your other repository to personalty.project.org/r and install the source version.  For a PC you need to ftp or http to personality-project/r/src/contrib/ to get the zip file.

Once again, when you discover a problem with the psych package, make sure to write me directly as well as the list.  You will get much faster turnaround.

Bill

On Jun 16, 2014, at 2:52 AM, Tham Tran <[hidden email]> wrote:

> Hi William,
>
> I've just updated your latest package "psych_1.4.6.11.zip" from server
> "personality-project/r/src/contrib/". One time the updating process was
> finished, i tried to run based samples code:
>
> require(psych)
> keys.list=list(Agree=c(-1,2:5),Conscientious=c(6:8,-9,-10),Extraversion=c(-11,-12,13:15),Neuroticism=c(16:20),Openness
> = c(21,-22,23,24,-25))
> keys = make.keys(28,keys.list,item.labels=colnames(bfi))
> scores = scoreItems(keys,bfi,min=1,max=6)
> error.bars.by(scores$scores,round(bfi$age/10)*10,by.var=TRUE,main="BFI age
> trends",legend=3,labels=colnames(scores$scores),xlab="Age",ylab="Mean item
> score")
>
> then i had an error following:
>
> Erreur dans if (del == 0 && to == 0) return(to) :
>  valeur manquante là où TRUE / FALSE est requis
> De plus : Messages d'avis :
> 1: In qt(1 - alpha/2, group.stats[[g]]$n - 1) : production de NaN
> 2: In dt(ln, n - 1) : production de NaN
> 3: In qt(alpha/2, n - 1) : production de NaN
>
> Could you tell me how to fix these issues? May i had a mistake of updating
> your lasted package?
>
> Sincerly
> Tham
>
>
>
>
>
>
> --
> View this message in context: http://r.789695.n4.nabble.com/plot-in-package-psych-with-function-error-bars-by-tp4691632p4692177.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> [hidden email] 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.

William Revelle           http://personality-project.org/revelle.html
Professor           http://personality-project.org
Department of Psychology   http://www.wcas.northwestern.edu/psych/
Northwestern University   http://www.northwestern.edu/
Use R for psychology             http://personality-project.org/r
It is 5 minutes to midnight   http://www.thebulletin.org

______________________________________________
[hidden email] 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.