[R] batch mode problem

2005-12-13 Thread Jörg Schaber
Hi,

ok, I know I should be using a later version than 1.7.1 (64 bit) but 
it's not in my power.
So here is the problem:
In my R script I declare a data.frame that consists of  40 vectors, each 
having 125 numeric elements. This is no problem as long as I run the 
sript in interactive mode, but running it in batch mode I get strange 
error messages.
Apparently, it has to do with the size of the data.frame because 
reducing the data.frame to 36 vector a 125 elements, I have no problems.

How can I declare my large data.frame and still run the script in batch 
mode?

Thanks,

joerg

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] batch mode problem

2005-12-13 Thread Uwe Ligges
Jörg Schaber wrote:

> Hi,
> 
> ok, I know I should be using a later version than 1.7.1 (64 bit) but 
> it's not in my power.
> So here is the problem:
> In my R script I declare a data.frame that consists of  40 vectors, each 
> having 125 numeric elements. This is no problem as long as I run the 
> sript in interactive mode, but running it in batch mode I get strange 
> error messages.
> Apparently, it has to do with the size of the data.frame because 
> reducing the data.frame to 36 vector a 125 elements, I have no problems.
> 
> How can I declare my large data.frame and still run the script in batch 
> mode?

Put the data.frame in a seperate file and source that one.

Uwe Ligges

> Thanks,
> 
> joerg
> 
> __
> R-help@stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] Batch mode problem: figure margins too large

2005-05-12 Thread Lapointe, Pierre
Hello, I have a program that works well in Rgui but that does not work in a
batch file (Execution halted)

Here's the code (it will work on you side, but you need internet access
through R as it will download a table from a US gov site)


download.file("http://www.cftc.gov/files/dea/history/deacot2005.zip";,
"c:/deacot2005.zip",
"internal", quiet = FALSE, mode = "wb",cacheOK = TRUE)
unzipped<-zip.file.extract("c:/annual.txt", zipname =
"deacot2005.zip")  #Unzip
data <-read.table(unzipped, header=TRUE, sep=',')
#windows(height=11,width=8.5)
z <- layout(matrix(c(1:8), 4,2, byrow = TRUE))
for (i in 1:8) {  #loop to fill layout
tbonds<-data[data$'Market.and.Exchange.Names'=="U.S.
TREASURY BONDS - CHICAGO BOARD OF TRADE ",] #choose only T-Bonds
ordered<-tbonds[order(tbonds[,3]),]#order by date
longb<-ordered[,c(3,9)]
longb[,1]<-as.Date(longb[,1],format="%Y%m%d") #to transform
to date format
par(mar=c(2.5, 3.5, 2, 4.5)) #need this par for mtext

plot(longb,type="l",las=1,xlab="",ylab="",bty="l",cex.axis=0.9)
end<-(longb)[nrow(ordered),]  #mtext text
end0<-(longb)[nrow(ordered)-1,]   #mtext text
now<- paste(' Last:',end[,2],"\n",'Prev:',end0[,2])
#mtext text
mtext(now,side=4, las=2,adj=0,padj=0.5,cex=0.5) #mtext text
}
dev.print(pdf,
file="c:/CFTC.pdf",height=10,width=8,paper="letter")

As you can see, I need a special par(mar) to make room for the margin text
(mtext)

When I run this program through a batch file I get this message :

...
> unzipped<-zip.file.extract("c:/annual.txt", zipname =
"deacot2005.zip")  #Unzip
> data <-read.table(unzipped, header=TRUE, sep=',')
> 
> windows(height=11,width=8.5)
> z <- layout(matrix(c(1:8), 4,2, byrow = TRUE))
> 
> for (i in 1:8) {  #loop to fill layout
+ 
+ tbonds<-data[data$'Market.and.Exchange.Names'=="U.S.
TREASURY BONDS - CHICAGO BOARD OF TRADE ",] #choose only T-Bonds
+ ordered<-tbonds[order(tbonds[,3]),]#order by date
+ longb<-ordered[,c(3,9)]
+ longb[,1]<-as.Date(longb[,1],format="%Y%m%d") #to
transform to date format
+ par(mar=c(2.5, 3.5, 2, 4.5)) #need this par for mtext
+
plot(longb,type="l",las=1,xlab="",ylab="",bty="l",cex.axis=0.9)
+ end<-(longb)[nrow(ordered),]  #mtext text
+ end0<-(longb)[nrow(ordered)-1,]   #mtext text
+ now<- paste(' Last:',end[,2],"\n",'Prev:',end0[,2])
#mtext text
+ mtext(now,side=4, las=2,adj=0,padj=0.5,cex=0.5) #mtext
text
+ }
Error in plot.new() : figure margins too large
Execution halted

I tried to remove the windows(height=11,width=8.5) as I don't need it in
batch mode, but it prevented the PDF creation as it  " can only print from
screen device".

dev.print(pdf,
file="c:/CFTC.pdf",height=10,width=8,paper="letter")
Error in dev.print(pdf, file = "c:/CFTC.pdf", height = 10,
width = 8,  : 
can only print from screen device
Execution halted

Here's what I have in my windows batch file

Set TZ=GMT
PATH C:\Program Files\R\rw2010\bin
Rterm --internet2 --no-restore --no-save 
result.txt 2>&1

I'm on win2k,

> version
 _  
platform i386-pc-mingw32
arch i386   
os   mingw32
system   i386, mingw32  
status   Patched
major2  
minor1.0
year 2005   
month05 
day  09 
language R

Be nice with me.  I've been a R user for only 2 weeks.

Regards,

Pierre Lapointe
Assistant Market Strategist
National Bank Financial
1155 Metcalfe Street, 5th Floor
Montreal (Qc)
H3B 4S9
(514) 879-2378



***
 
AVIS DE NON-RESPONSABILITE: 
Ce document transmis par courrier electronique est destine uniquement a la 
personne ou a l'entite a qui il est adresse et peut contenir des 
renseignements confidentiels et assujettis au secret professionnel. La 
confidentialite et le secret professionnel demeurent malgre l'envoi de ce 
document a la mauvaise adresse electronique. Si vous n'etes pas le 
destinataire vise ou la personne chargee de remettre ce document a son 
destinataire, veuillez nous en informer sans delai et detruire ce document 
ainsi que toute copie qui en aurait ete faite.Toute distribution, reproduction 
ou autre utilisation de ce document est 
strictement interdite. De plus, le Groupe Financiere Banque Nationale

[R] Batch mode problem: figure margins too large (code corrected for word wrap)

2005-05-12 Thread Lapointe, Pierre
First of all, I apologize for the triple post, but I did not see that the
word wrap on the r-help list site would render my code unusable. So here it
is again.  Hoping that this time it will work if you cut and paste it in
your Rgui.

I have a program that works well in Rgui but that does not work in a batch
file (Execution halted).

Here's the code (it will work on your R, but you need internet access
through R as it will download a table from a US gov site).

#Code Start
download.file("http://www.cftc.gov/files/dea/history/deacot2005.zip";,
"c:/deacot2005.zip", "internal", quiet = FALSE, mode = "wb",cacheOK = TRUE)
unzipped<-zip.file.extract("c:/annual.txt", zipname = "deacot2005.zip")
#Unzip
data <-read.table(unzipped, header=TRUE, sep=',')
windows(height=11,width=8.5)
z <- layout(matrix(c(1:8), 4,2, byrow = TRUE))
for (i in 1:8) {  #loop to fill layout
tbonds<-data[data$'Market.and.Exchange.Names'==
"U.S. TREASURY BONDS - CHICAGO BOARD OF TRADE ",] #choose only T-Bonds
ordered<-tbonds[order(tbonds[,3]),]#order by date
longb<-ordered[,c(3,9)]
longb[,1]<-as.Date(longb[,1],format="%Y%m%d") #to transform to date format
par(mar=c(2.5, 3.5, 2, 4.5)) #need this par for mtext
plot(longb,type="l",las=1,xlab="",ylab="",bty="l",cex.axis=0.9)
end<-(longb)[nrow(ordered),]  #mtext text
end0<-(longb)[nrow(ordered)-1,]   #mtext text
now<- paste(' Last:',end[,2],"\n",'Prev:',end0[,2])#mtext text
mtext(now,side=4, las=2,adj=0,padj=0.5,cex=0.5) #mtext text
}
dev.print(pdf, file="c:/CFTC.pdf",height=10,width=8,paper="letter")
#Code end

As you can see, I need a special par(mar) to make room for the margin text
(mtext).

When I run this program through a batch file I get this message :

...
+ longb<-ordered[,c(3,9)]
+ longb[,1]<-as.Date(longb[,1],format="%Y%m%d") #to transform to date format
+ par(mar=c(2.5, 3.5, 2, 4.5)) #need this par for mtext
+ plot(longb,type="l",las=1,xlab="",ylab="",bty="l",cex.axis=0.9)
+ end<-(longb)[nrow(ordered),]  #mtext text
+ end0<-(longb)[nrow(ordered)-1,]   #mtext text
+ now<- paste(' Last:',end[,2],"\n",'Prev:',end0[,2])#mtext text
+ mtext(now,side=4, las=2,adj=0,padj=0.5,cex=0.5) #mtext text
+ }
Error in plot.new() : figure margins too large
Execution halted

I tried to remove the windows(height=11,width=8.5) as I don't need it in
batch mode, but it prevented the PDF creation as it  " can only print from
screen device".

dev.print(pdf, file="c:/CFTC.pdf",height=10,width=8,paper="letter")
Error in dev.print(pdf, file = "c:/CFTC.pdf", height = 10, width = 8,  : 
can only print from screen device
Execution halted

Here's what I have in my windows batch file

Set TZ=GMT
PATH C:\Program Files\R\rw2010\bin
Rterm --internet2 --no-restore --no-save  result.txt 2>&1

I'm on win2k,

> version
 _  
platform i386-pc-mingw32
arch i386   
os   mingw32
system   i386, mingw32  
status   Patched
major2  
minor1.0
year 2005   
month05 
day  09 
language R

Be nice with me.  I've been a R user for only 2 weeks.

Regards,

Pierre Lapointe
Assistant Market Strategist
National Bank Financial




***
 
AVIS DE NON-RESPONSABILITE: 
Ce document transmis par courrier electronique est destine uniquement a la 
personne ou a l'entite a qui il est adresse et peut contenir des 
renseignements confidentiels et assujettis au secret professionnel. La 
confidentialite et le secret professionnel demeurent malgre l'envoi de ce 
document a la mauvaise adresse electronique. Si vous n'etes pas le 
destinataire vise ou la personne chargee de remettre ce document a son 
destinataire, veuillez nous en informer sans delai et detruire ce document 
ainsi que toute copie qui en aurait ete faite.Toute distribution, reproduction 
ou autre utilisation de ce document est 
strictement interdite. De plus, le Groupe Financiere Banque Nationale et ses 
filiales ne peuvent pas etre tenus responsables des dommages pouvant etre 
causes par des virus ou des erreurs de transmission. 

DISCLAIMER:\ This documentation transmitted by electronic ma...{{dropped}}

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] Batch mode problem: figure margins too large (code corrected for word wrap)

2005-05-12 Thread Prof Brian Ripley
Thank you, the word wrap did make it impossible.
For me
pdf(file="c:/CFTC.pdf",height=10,width=8,paper="letter")
## plotting
dev.off()
works in interactive mode or from a file.  I don't understand why you are 
going via dev.print(), nor what exactly what is different about your 
invocation of `batch mode', as putting your commands in file test.R and 
doing

R CMD BATCH test.R
R CMD BATCH --internet2 test.R
also work.  So although I have not nailed the problem I hope I have 
provided some workarounds.

On Thu, 12 May 2005, Lapointe, Pierre wrote:
First of all, I apologize for the triple post, but I did not see that the
word wrap on the r-help list site would render my code unusable. So here it
is again.  Hoping that this time it will work if you cut and paste it in
your Rgui.
I have a program that works well in Rgui but that does not work in a batch
file (Execution halted).
Here's the code (it will work on your R, but you need internet access
through R as it will download a table from a US gov site).
#Code Start
download.file("http://www.cftc.gov/files/dea/history/deacot2005.zip";,
"c:/deacot2005.zip", "internal", quiet = FALSE, mode = "wb",cacheOK = TRUE)
unzipped<-zip.file.extract("c:/annual.txt", zipname = "deacot2005.zip")
#Unzip
data <-read.table(unzipped, header=TRUE, sep=',')
windows(height=11,width=8.5)
z <- layout(matrix(c(1:8), 4,2, byrow = TRUE))
for (i in 1:8) {  #loop to fill layout
tbonds<-data[data$'Market.and.Exchange.Names'==
"U.S. TREASURY BONDS - CHICAGO BOARD OF TRADE ",] #choose only T-Bonds
ordered<-tbonds[order(tbonds[,3]),]#order by date
longb<-ordered[,c(3,9)]
longb[,1]<-as.Date(longb[,1],format="%Y%m%d") #to transform to date format
par(mar=c(2.5, 3.5, 2, 4.5)) #need this par for mtext
plot(longb,type="l",las=1,xlab="",ylab="",bty="l",cex.axis=0.9)
end<-(longb)[nrow(ordered),]  #mtext text
end0<-(longb)[nrow(ordered)-1,]   #mtext text
now<- paste(' Last:',end[,2],"\n",'Prev:',end0[,2])#mtext text
mtext(now,side=4, las=2,adj=0,padj=0.5,cex=0.5) #mtext text
}
dev.print(pdf, file="c:/CFTC.pdf",height=10,width=8,paper="letter")
#Code end
As you can see, I need a special par(mar) to make room for the margin text
(mtext).
When I run this program through a batch file I get this message :
...
+ longb<-ordered[,c(3,9)]
+ longb[,1]<-as.Date(longb[,1],format="%Y%m%d") #to transform to date format
+ par(mar=c(2.5, 3.5, 2, 4.5)) #need this par for mtext
+ plot(longb,type="l",las=1,xlab="",ylab="",bty="l",cex.axis=0.9)
+ end<-(longb)[nrow(ordered),]  #mtext text
+ end0<-(longb)[nrow(ordered)-1,]   #mtext text
+ now<- paste(' Last:',end[,2],"\n",'Prev:',end0[,2])#mtext text
+ mtext(now,side=4, las=2,adj=0,padj=0.5,cex=0.5) #mtext text
+ }
Error in plot.new() : figure margins too large
Execution halted
I tried to remove the windows(height=11,width=8.5) as I don't need it in
batch mode, but it prevented the PDF creation as it  " can only print from
screen device".
dev.print(pdf, file="c:/CFTC.pdf",height=10,width=8,paper="letter")
Error in dev.print(pdf, file = "c:/CFTC.pdf", height = 10, width = 8,  :
can only print from screen device
Execution halted
Here's what I have in my windows batch file
Set TZ=GMT
PATH C:\Program Files\R\rw2010\bin
Rterm --internet2 --no-restore --no-save  result.txt 2>&1
I'm on win2k,
version
_
platform i386-pc-mingw32
arch i386
os   mingw32
system   i386, mingw32
status   Patched
major2
minor1.0
year 2005
month05
day  09
language R
Be nice with me.  I've been a R user for only 2 weeks.
Regards,
Pierre Lapointe
Assistant Market Strategist
National Bank Financial

***
AVIS DE NON-RESPONSABILITE:
Ce document transmis par courrier electronique est destine uniquement a la 
personne ou a l'entite a qui il est adresse et peut contenir des
renseignements confidentiels et assujettis au secret professionnel. La
confidentialite et le secret professionnel demeurent malgre l'envoi de ce
document a la mauvaise adresse electronique. Si vous n'etes pas le
destinataire vise ou la personne chargee de remettre ce document a son 
destinataire, veuillez nous en informer sans delai et detruire ce document 
ainsi que toute copie qui en aurait ete faite.Toute distribution, reproduction 
ou autre utilisation de ce document est
strictement interdite. De plus, le Groupe Financiere Banque Nationale et ses 
filiales ne peuvent pas etre tenus responsables des dommages pouvant etre 
causes par des virus ou des erreurs de transmission.
DISCLAIMER:\ This documentation transmitted by electronic ma...{{dropped}}
__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
--
Brian D. Ripley,  [EMAIL PROTECTED]
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford, 

Re: [R] Batch mode problem: figure margins too large (code corrected for word wrap)

2005-05-12 Thread Uwe Ligges
I'd like to recommend to open the pdf() device (and to plot in) 
directly. There is no reason to use the windows() device in BATCH mode, 
if you want to produce PDF.

Lapointe, Pierre wrote:
First of all, I apologize for the triple post, but I did not see that the
word wrap on the r-help list site would render my code unusable. So here it
is again.  Hoping that this time it will work if you cut and paste it in
your Rgui.
I have a program that works well in Rgui but that does not work in a batch
file (Execution halted).
Here's the code (it will work on your R, but you need internet access
through R as it will download a table from a US gov site).
#Code Start
download.file("http://www.cftc.gov/files/dea/history/deacot2005.zip";,
"c:/deacot2005.zip", "internal", quiet = FALSE, mode = "wb",cacheOK = TRUE)
unzipped<-zip.file.extract("c:/annual.txt", zipname = "deacot2005.zip")
#Unzip
data <-read.table(unzipped, header=TRUE, sep=',')
windows(height=11,width=8.5)
delete windows() and insert:
pdf(file="c:/CFTC.pdf",height=10,width=8,paper="letter")

z <- layout(matrix(c(1:8), 4,2, byrow = TRUE))
for (i in 1:8) {  #loop to fill layout
tbonds<-data[data$'Market.and.Exchange.Names'==
"U.S. TREASURY BONDS - CHICAGO BOARD OF TRADE ",] #choose only T-Bonds
ordered<-tbonds[order(tbonds[,3]),]#order by date
longb<-ordered[,c(3,9)]
longb[,1]<-as.Date(longb[,1],format="%Y%m%d") #to transform to date format
par(mar=c(2.5, 3.5, 2, 4.5)) #need this par for mtext
plot(longb,type="l",las=1,xlab="",ylab="",bty="l",cex.axis=0.9)
end<-(longb)[nrow(ordered),]  #mtext text
end0<-(longb)[nrow(ordered)-1,]   #mtext text
now<- paste(' Last:',end[,2],"\n",'Prev:',end0[,2])#mtext text
mtext(now,side=4, las=2,adj=0,padj=0.5,cex=0.5) #mtext text
}
dev.print(pdf, file="c:/CFTC.pdf",height=10,width=8,paper="letter")
#Code end

delete dev.print and insert dev.off()
[BTW: your code is almost unreadable, please try to format it before 
posting, and please read documentation on devices]

Uwe Ligges

As you can see, I need a special par(mar) to make room for the margin text
(mtext).
When I run this program through a batch file I get this message :
...
+ longb<-ordered[,c(3,9)]
+ longb[,1]<-as.Date(longb[,1],format="%Y%m%d") #to transform to date format
+ par(mar=c(2.5, 3.5, 2, 4.5)) #need this par for mtext
+ plot(longb,type="l",las=1,xlab="",ylab="",bty="l",cex.axis=0.9)
+ end<-(longb)[nrow(ordered),]  #mtext text
+ end0<-(longb)[nrow(ordered)-1,]   #mtext text
+ now<- paste(' Last:',end[,2],"\n",'Prev:',end0[,2])#mtext text
+ mtext(now,side=4, las=2,adj=0,padj=0.5,cex=0.5) #mtext text
+ }
Error in plot.new() : figure margins too large
Execution halted
I tried to remove the windows(height=11,width=8.5) as I don't need it in
batch mode, but it prevented the PDF creation as it  " can only print from
screen device".
dev.print(pdf, file="c:/CFTC.pdf",height=10,width=8,paper="letter")
Error in dev.print(pdf, file = "c:/CFTC.pdf", height = 10, width = 8,  : 
	can only print from screen device
Execution halted

Here's what I have in my windows batch file
Set TZ=GMT
PATH C:\Program Files\R\rw2010\bin
Rterm --internet2 --no-restore --no-save  result.txt 2>&1
I'm on win2k,

version
 _  
platform i386-pc-mingw32
arch i386   
os   mingw32
system   i386, mingw32  
status   Patched
major2  
minor1.0
year 2005   
month05 
day  09 
language R

Be nice with me.  I've been a R user for only 2 weeks.
Regards,
Pierre Lapointe
Assistant Market Strategist
National Bank Financial

*** 
AVIS DE NON-RESPONSABILITE: 
Ce document transmis par courrier electronique est destine uniquement a la personne ou a l'entite a qui il est adresse et peut contenir des 
renseignements confidentiels et assujettis au secret professionnel. La 
confidentialite et le secret professionnel demeurent malgre l'envoi de ce 
document a la mauvaise adresse electronique. Si vous n'etes pas le 
destinataire vise ou la personne chargee de remettre ce document a son destinataire, veuillez nous en informer sans delai et detruire ce document ainsi que toute copie qui en aurait ete faite.Toute distribution, reproduction ou autre utilisation de ce document est 
strictement interdite. De plus, le Groupe Financiere Banque Nationale et ses filiales ne peuvent pas etre tenus responsables des dommages pouvant etre causes par des virus ou des erreurs de transmission. 

DISCLAIMER:\ This documentation transmitted by electronic ma...{{dropped}}
__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the