Sorry I added the postscript and dev.off commands in the interactive R
session generated by GRETL. I have the same problem when I try to run
the script from R. Like Allin I can not see what is wrong. It is
almost right. If I start R and generate an interactive session as
follows
R version 2.7.1 (2008-06-23)
Copyright (C) 2008 The R Foundation for Statistical Computing
ISBN 3-900051-07-0
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.
Natural language support but running in an English locale
R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.
Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
setwd("C:\\Documents and Settings\\John C Frain\\Application
Data\\gretl")
getwd()
[1] "C:/Documents and Settings/John C Frain/Application
Data/gretl"
source("Rsrc",echo=TRUE)
# load data from gretl
gretldata <- read.table("C:/Documents and Settings/John C Frain/Application
Data/gretl/Rdata.tmp", header=TRUE)
gretldata <- ts(gretldata, start=c(1950, 1), frequency = 4)
# load script from gretl
library(graphics);
postscript("myRfile.ps")
plot(gretldata[,"realgdp"],gretldata[,"realcons"]);
dev.off()
null device
1
########################### End Session
##############################################
everything works properly.
If
1. I start Tinn-R and load the file Rsrc into the editor.
(Tinn-R is configured to start without starting R. If I load an
R-script into Tinn-R and start R the directory holding the script
becomes the working directory. It is not necessary to load the
Sciviews package or to make any Tinn-R specific additions to the
Rprofile file if one wishes to work in this way if one wishes to work
in this way)
2 Start R from within Tinn-R
3 Run the Rsrc script line by line or as a block
everything also runs properly. If anything is wrong it must be very
small. (famous last words)
Best Regards
John
2008/8/4 Sven Schreiber <svetosch(a)gmx.net>:
> John,
> thanks for your advice! Unfortunately I get an R error (in the Rterm):
>> sink("C:/Dokumente und
Einstellungen/svenne/Anwendungsdaten/gretl/R.out")
> Fehler in eval.with.vis(expr, envir, enclos) :
> konnte Funktion "postscript" nicht finden
> (= couldn't find function "postscript")
> Here's the script I'm running from gretl,
following your suggestions:
> library(graphics);
postscript("myRfile.ps")
plot(gretldata[,"realgdp"],gretldata[,"realcons"]);
dev.off()
> Any
ideas?
> thanks,
> sven
> John C Frain schrieb:
>
>> Load the sample data set green5_1.gdt into gretl.
>
>> Do a crossplot of say realgdp and realcons in Gretl
>
>> The following script run from GRETL will produce the
corresponding
>> default graph in R
>
>> library(graphics);
>
plot(gretldata[,"realgdp"],gretldata[,"realcons"]);
>
>> If you put a command
>
>> postscript(file="myfile.ps")
>
>> before the plot command it will write a postscript
version to of the
>> the specified file in the R working directory. You should put a
>
>
dev.off()
>
>> command after the plot command. There are many ways
to beautify the
>> file. You might want to consult Murrell (2006), "R Graphics", Chapman
>> & Hall or any of the many books on R for more details.
>
>> I would use R for Graphics when i am working in R. I
think that the
>> front end on gnuplot in Gretl is superb and would use it unless I am
>> already in R. (I also think that R graphics are very good and more
>> flexible but they can often they require a bit more work. I have
>> tried to use gnuplot directly and would definitely prefer R. Perhaps
>> this is because I am not as familiar with gnuplot.
>
>> Best regards
>
>> John
>
>
>
>>
2008/8/2 Sven Schreiber <svetosch(a)gmx.net>:
>>
>>> Hello everybody,
>>
>>> I'm wondering
whether it could make sense to produce graphs with R, given
>>> the brand new gretl functionality to embed R commands. I would like to
>>> compare the output quality of the standard gretl approach (using gnuplot)
>>> with what embedded R would provide.
>>
>>> However, I have no
experience with R, so I need help: does anybody have a
>>> minimal script example (say, simple scatter plot of two variables) that
>>> could be run in gretl and produce the graph, ideally saveable in pdf?
>>
>>> thanks,
>>> sven
>>> _______________________________________________
>>> Gretl-users mailing list
>>> Gretl-users(a)lists.wfu.edu
>>>
http://lists.wfu.edu/mailman/listinfo/gretl-users
>>
>
>
>
>
_______________________________________________
> Gretl-users mailing list
> Gretl-users(a)lists.wfu.edu
>
http://lists.wfu.edu/mailman/listinfo/gretl-users
--
John C Frain
Trinity College Dublin
Dublin 2
Ireland
www.tcd.ie/Economics/staff/frainj/home.html
mailto:frainj@tcd.ie
mailto:frainj@gmail.com