[R] plot in package psych with function error.bars.by

Jim Lemon jim at bitwrit.com.au
Tue Jun 3 23:10:37 CEST 2014


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



More information about the R-help mailing list