Re: [R] Error when producing multiple graphes

2008-03-19 Thread bartjoosen

Could you provide us some working codo, so that we can reproduce the error
and see what went wrong?



Uli Kleinwechter wrote:
 
 Dear all,
 
 Within a larger script I use the following code to produce barplots for 
 all variables contained in a dataframe type3m:
 
 for(xn in names(type3m)) barplot(table(type3m[[xn]]), main = paste
 (Barplot of, xn), width=0.75,legend.text=barnamesm,
 xlim=c(0,4),ylim=c(0,400))
 
 The plots are produced and printed into a *.ps file. However, R gives an 
 error message and aborts the script. The error message is:
 
 Fehler in rect(as.double(xleft), as.double(ybottom),
 as.double(xright),  :
 ungültiges erstes Argument
 
 (it's in German. In English, it says something like Error in 
 rect(as.double(xleft), as.double(ybottom), as.double(xright),  : invalid 
 first argument)
 
 It seems to be some problem with the barplot function. The variables in 
 the dataframe are discrete variables taking values from 1 to 4 (hence, 
 the xlim=c(0,4) and the graph is supposed to show the frequency of each 
 value. Maybe the problem is related to the fact that not some variables 
 don't take all of the values, i.e., there are some that don't take the 
 value 1, for example.
 
 I spent quite some time trying to solve the problem, but can't manage 
 it. What's wrong here and how can it be solved?
 
 Thank you very much!
 
 Uli
 
 
   [[alternative HTML version deleted]]
 
 
 __
 R-help@r-project.org 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.
 
 

-- 
View this message in context: 
http://www.nabble.com/Error-when-producing-multiple-graphes-tp16123596p16140831.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org 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.


Re: [R] Error when producing multiple graphes

2008-03-19 Thread Uli Kleinwechter
bartjoosen schrieb:
 Could you provide us some working codo, so that we can reproduce the error
 and see what went wrong?
   
Of course. Here is the relevant part of the code I'm working with. I suppose it 
will be helpful for you to have the csv file, as well. But as an attachment 
will be deleted, I will send it to you upon request.




rm(list=ls(all.names=TRUE))

agr1-read.csv2(sales.csv)

attach(agr1)

# Select variables:

type3m-data.frame(cornmethod,maizemethod,paddymethod,ricemethod,rapemethod,ograinmethod,vegmethod,
fruitmethod,ocropmethod,pigmethod,cowmethod,poultrymethod,eggmethod,oanimalmethod,forestrymethod,fisherymethod,
rentmethod,processmethod,othermethod)

type3l-data.frame(cornloc,maizeloc,paddyloc,riceloc,rapeloc,ograinloc,vegloc,fruitloc,ocroploc,pigloc,
cowloc,poultryloc,eggloc,oanimalloc,forestryloc,fisheryloc,rentloc,processloc,otherloc)

#Define legends for bars

barnamesm-c(1=Village fair,2=State quota, 3=Trader, 4=Other)
barnamesloc-c(1=nat. vill.,2=admin. 
vill.,3=township,4=county,5=province,6=outside prov.)

#Print barplots into ps file
postscript(salemethods.ps, horizontal=TRUE)

for(xn in names(type3m)) barplot(table(type3m[[xn]]), main = paste 
(Barplot of, xn), width=0.75,legend.text=barnamesm, 
xlim=c(0,4),ylim=c(0,400))

dev.off()

#Print barplots into ps file
postscript(salelocations.ps, horizontal=FALSE)

for(xn in names(type3l)) barplot(table(type3l[[xn]]), main = 
paste(Barplot of, xn),legend.text=barnamesloc,xlim=c(0,6))

dev.off()

detach(agr1)



 Uli Kleinwechter wrote:
   
 Dear all,

 Within a larger script I use the following code to produce barplots for 
 all variables contained in a dataframe type3m:

 for(xn in names(type3m)) barplot(table(type3m[[xn]]), main = paste
 (Barplot of, xn), width=0.75,legend.text=barnamesm,
 xlim=c(0,4),ylim=c(0,400))

 The plots are produced and printed into a *.ps file. However, R gives an 
 error message and aborts the script. The error message is:

 Fehler in rect(as.double(xleft), as.double(ybottom),
 as.double(xright),  :
 ungültiges erstes Argument

 (it's in German. In English, it says something like Error in 
 rect(as.double(xleft), as.double(ybottom), as.double(xright),  : invalid 
 first argument)

 It seems to be some problem with the barplot function. The variables in 
 the dataframe are discrete variables taking values from 1 to 4 (hence, 
 the xlim=c(0,4) and the graph is supposed to show the frequency of each 
 value. Maybe the problem is related to the fact that not some variables 
 don't take all of the values, i.e., there are some that don't take the 
 value 1, for example.

 I spent quite some time trying to solve the problem, but can't manage 
 it. What's wrong here and how can it be solved?

 Thank you very much!

 Uli


  [[alternative HTML version deleted]]


 __
 R-help@r-project.org 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.


 

   


-- 
Uli Kleinwechter
Department of Agricultural Economics and Social Sciences
Faculty of Agriculture and Horticulture
Humboldt University of Berlin
Unter den Linden 6
D-10099 Berlin, Germany
Phone: (+49) 30 2093 6124, Fax. (+49) 30 2093 6301
E-mail: [EMAIL PROTECTED]

__
R-help@r-project.org 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.


Re: [R] Error when producing multiple graphes

2008-03-19 Thread Uli Kleinwechter
Sorry. My last message maybe was not very helpful. Please find here a 
more concise form of the code. It produces a dataframe of more or less 
the characteristics of the one that I use and yields the same error message:
*
x1-c(1,2,3,4,NA ,NA ,NA, 3, 1, 1, 1, 1, 2, 2, 3, 4, 4)

x2-c(2,3,4,3,4,3,4,2,2,3,4,NA,NA,NA,NA,4,3)

x3-c(NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA)

x4-c(1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,1,2)

type3m-data.frame(x1,x2,x3,x4)

barnamesm-c(1=One,2=Two, 3=Three, 4=Four)

for(xn in names(type3m)) barplot(table(type3m[[xn]]), main = paste 
(Barplot of, xn), width=0.75,legend.text=barnamesm, 
xlim=c(0,4),ylim=c(0,400))


Thanks again!

Uli

bartjoosen schrieb:
 Could you provide us some working codo, so that we can reproduce the error
 and see what went wrong?



 Uli Kleinwechter wrote:
   
 Dear all,

 Within a larger script I use the following code to produce barplots for 
 all variables contained in a dataframe type3m:

 for(xn in names(type3m)) barplot(table(type3m[[xn]]), main = paste
 (Barplot of, xn), width=0.75,legend.text=barnamesm,
 xlim=c(0,4),ylim=c(0,400))

 The plots are produced and printed into a *.ps file. However, R gives an 
 error message and aborts the script. The error message is:

 Fehler in rect(as.double(xleft), as.double(ybottom),
 as.double(xright),  :
 ungültiges erstes Argument

 (it's in German. In English, it says something like Error in 
 rect(as.double(xleft), as.double(ybottom), as.double(xright),  : invalid 
 first argument)

 It seems to be some problem with the barplot function. The variables in 
 the dataframe are discrete variables taking values from 1 to 4 (hence, 
 the xlim=c(0,4) and the graph is supposed to show the frequency of each 
 value. Maybe the problem is related to the fact that not some variables 
 don't take all of the values, i.e., there are some that don't take the 
 value 1, for example.

 I spent quite some time trying to solve the problem, but can't manage 
 it. What's wrong here and how can it be solved?

 Thank you very much!

 Uli


  [[alternative HTML version deleted]]


 __
 R-help@r-project.org 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.


 



__
R-help@r-project.org 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.


Re: [R] Error when producing multiple graphes

2008-03-19 Thread Uli Kleinwechter
I just solved the problem. The error happened because of the empty 
variables in the dataframe.

In any case, thanks for caring.
 

bartjoosen schrieb:
 Could you provide us some working codo, so that we can reproduce the error
 and see what went wrong?


 Uli Kleinwechter wrote:
   
 Dear all,

 Within a larger script I use the following code to produce barplots for 
 all variables contained in a dataframe type3m:

 for(xn in names(type3m)) barplot(table(type3m[[xn]]), main = paste
 (Barplot of, xn), width=0.75,legend.text=barnamesm,
 xlim=c(0,4),ylim=c(0,400))

 The plots are produced and printed into a *.ps file. However, R gives an 
 error message and aborts the script. The error message is:

 Fehler in rect(as.double(xleft), as.double(ybottom),
 as.double(xright),  :
 ungültiges erstes Argument

 (it's in German. In English, it says something like Error in 
 rect(as.double(xleft), as.double(ybottom), as.double(xright),  : invalid 
 first argument)

 It seems to be some problem with the barplot function. The variables in 
 the dataframe are discrete variables taking values from 1 to 4 (hence, 
 the xlim=c(0,4) and the graph is supposed to show the frequency of each 
 value. Maybe the problem is related to the fact that not some variables 
 don't take all of the values, i.e., there are some that don't take the 
 value 1, for example.

 I spent quite some time trying to solve the problem, but can't manage 
 it. What's wrong here and how can it be solved?

 Thank you very much!

 Uli


  [[alternative HTML version deleted]]


 __
 R-help@r-project.org 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.


 



__
R-help@r-project.org 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.