Re: [R] low resolution word map

2012-08-01 Thread Thomas Steiner
Hi Ray,

2012/7/31 Ray Brownrigg :
> On 07/28/12 23:46, Thomas Steiner wrote:
>> Hi,
>> I'd like to have a low resolution word map in R.
>> The "maps" package has this option, but if I use the argument, the map
>> looses sense: Russia and Australia get empty etc
>>
>> library("maps")
>> m=map(col="skyblue",fill=TRUE,plot=TRUE,resolution=10)
>> length(m$x)
>>
>> If I drop the "fill=TRUE", the effect of "resolutaion=1" is lost,
>
> I don't know why this is so, I hadn't realised that effect of resolution
> with fill=TRUE.

I don't understand either, but I left this observation to the developpers ;-)

>
>> ie no change. Is there any other package or could I use the resolution
>> argument differently?
>
> Well, you could say:
> m=map(col=0,fill=TRUE, resolution=10)
>
> Is that what you want?

no, if you look at the output (ie the map) you know why: little
islands like hawaii do still exist, but brazil is a rectangle of say 8
points...

>
> Ray
>
>> Thanks,
>> Thomas
>>
>> __
>> 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.


[R] low resolution word map

2012-07-28 Thread Thomas Steiner
Hi,
I'd like to have a low resolution word map in R.
The "maps" package has this option, but if I use the argument, the map
looses sense: Russia and Australia get empty etc

library("maps")
m=map(col="skyblue",fill=TRUE,plot=TRUE,resolution=10)
length(m$x)

If I drop the "fill=TRUE", the effect of "resolutaion=1" is lost,
ie no change. Is there any other package or could I use the resolution
argument differently?
Thanks,
Thomas

__
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] low resolution word map

2012-07-28 Thread Thomas Steiner
Hi,
I'd like to have a low resolution word map in R.
The "maps" package has this option, but if I use the argument, the map
looses sense: Russia and Australia get empty etc

library("maps")
m=map(col="skyblue",fill=TRUE,plot=TRUE,resolution=10)
length(m$x)

If I drop the "fill=TRUE", the effect of "resolutaion=1" is lost,
ie no change. Is there any other package or could I use the resolution
argument differently?
Thanks,
Thomas

__
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] add map to plot

2012-06-10 Thread Thomas Steiner
Hi,
I'd like to add a world map (equirectangular projection) in the
background of a normal R-plot and the world map should be shifted (the
center of the map should be c(163.87,23.581) where the center of the
plot is c(180,35)):

plot(c(0,360),c(0,70),type="n",main="My worldmap")
m=map("world", proj="rectangular", parameters=0, col="bisque",
fill=TRUE, resolution=0, lty=0,add=TRUE)
abline(v=180,h=47.162,col="red")
points(mapproject(list(y=0,x=16.13)),col="coral",pch="x",cex=2)
text(180,47.162,"Coordinates: 0°N 16.130°E")

adding a ",oritentation=c(163.87,23.581,0)" to the map() does not
change anything. Why? Could be that something with "parameters=90" is
wrong?
Thanks for hints,
Thomas

__
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] strange behaviour of CairoPNG

2010-06-26 Thread Thomas Steiner
Thank you Henrik for your answer.

I hope now I am inline with the posting huide and perhaps I get an
answer, thank you.

> sessionInfo()
R version 2.9.0 alpha (2009-03-23 r48200)
i386-pc-mingw32

locale:
LC_COLLATE=German_Austria.1252;LC_CTYPE=German_Austria.1252;LC_MONETARY=German_Austria.1252;LC_NUMERIC=C;LC_TIME=German_Austria.1252

attached base packages:
[1] stats graphics  grDevices utils datasets  methods   base

other attached packages:
[1] Cairo_1.4-4



2010/6/5 Henrik Bengtsson :
> FYI, follow the information in the email footer:
>
>> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>
> and make sure at a minimum to report your sessionInfo(). That
> increases your chances to get a response.
>
> /Henrik
>
> On Sat, Jun 5, 2010 at 11:42 AM, Thomas Steiner  
> wrote:
>> OK, no reply. :-(
>> I'm more offensive: this is a bug!
>> the font-parameter of the text fucntion does not work properly in the
>> Cairo-package
>> thomas
>>
>>
>> 2010/6/4 Thomas Steiner :
>>> Hi,
>>> could it be that the text() fuction gives different output for normal
>>> png() and CarioPNG()?
>>> See the following example and the attached images: the font=2 and
>>> font=3 seem to be exchanged!
>>> Thanks for help,
>>> Thomas
>>>
>>> CairoPNG("Test-cairo.png",width=750,height=690)
>>> #png("Test-normal.png",width=750,height=690)
>>>
>>> plot(1,1,type="n",main="normal")
>>> text(1,1,"normal",adj=c(1,1))
>>> text(1,1,"bold",font=2,adj=c(-1,-1))
>>> text(1,1,"italic",font=3,adj=c(1,-1))
>>> text(1,1,"italic&bold",font=4,adj=c(-1,1))
>>>
>>> dev.off()
>>>
>>
>> __
>> 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] strange behaviour of CairoPNG

2010-06-05 Thread Thomas Steiner
OK, no reply. :-(
I'm more offensive: this is a bug!
the font-parameter of the text fucntion does not work properly in the
Cairo-package
thomas


2010/6/4 Thomas Steiner :
> Hi,
> could it be that the text() fuction gives different output for normal
> png() and CarioPNG()?
> See the following example and the attached images: the font=2 and
> font=3 seem to be exchanged!
> Thanks for help,
> Thomas
>
> CairoPNG("Test-cairo.png",width=750,height=690)
> #png("Test-normal.png",width=750,height=690)
>
> plot(1,1,type="n",main="normal")
> text(1,1,"normal",adj=c(1,1))
> text(1,1,"bold",font=2,adj=c(-1,-1))
> text(1,1,"italic",font=3,adj=c(1,-1))
> text(1,1,"italic&bold",font=4,adj=c(-1,1))
>
> dev.off()
>

__
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] plot polar coordinates

2010-06-04 Thread Thomas Steiner
Thank you Jim,
I had a liitle off-list conversation with Greg and finally I got the solution.
All the code is now on
http://commons.wikimedia.org/wiki/File:Sonnenstand.png  I got the
workaround with my own "(sun)lines" function which does the shift from
cartesian coordiantes to polar coordinates. An example result is
attached.
The negative vales where just a stupid try from my side, it does of
course make no sense.
Best,
Thomas



2010/6/4 Jim Lemon :
> On 06/04/2010 05:05 AM, Thomas Steiner wrote:
>>
>> Thank you Greg,
>>
>> I'll add 180 then.
>>
>> Thanks for the hint with longer radial.lim arguments it works woderfull.
>>
>>> The lines function is plotting in Cartesian coordinates, not the polar
>>> coordinates.
>>
>> Is there any (lines) function that plots polar coordinates to an existing
>> plot?
>>
> Hi Thomas,
> Greg has already given you most of the solutions. I was a bit surprised to
> find that if you include the negative values in the radial.lim argument, the
> polygon appears _and_ in the right place! I'll have to add this to the help
> page. Note that your labels may not be where you think they should be, as 0
> degrees is east in your example. Maybe you want start=90?
>
> I have thought about reprogramming the radial plot functions with an "add"
> argument, but haven't gotten around to it. I'll have a look and if I can do
> this without too much work, I'll let you know.
>
> As far as 100 being prettier than 90, my experience is that I ain't gettin'
> any prettier as I get older.
>
> Jim
>
<>__
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] strange behaviour of CairoPNG

2010-06-04 Thread Thomas Steiner
Hi,
could it be that the text() fuction gives different output for normal
png() and CarioPNG()?
See the following example and the attached images: the font=2 and
font=3 seem to be exchanged!
Thanks for help,
Thomas

CairoPNG("Test-cairo.png",width=750,height=690)
#png("Test-normal.png",width=750,height=690)

plot(1,1,type="n",main="normal")
text(1,1,"normal",adj=c(1,1))
text(1,1,"bold",font=2,adj=c(-1,-1))
text(1,1,"italic",font=3,adj=c(1,-1))
text(1,1,"italic&bold",font=4,adj=c(-1,1))

dev.off()
<><>__
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] plot polar coordinates

2010-06-03 Thread Thomas Steiner
Thank you Greg,

I'll add 180 then.

Thanks for the hint with longer radial.lim arguments it works woderfull.

> The lines function is plotting in Cartesian coordinates, not the polar 
> coordinates.

Is there any (lines) function that plots polar coordinates to an existing plot?

Thank you very much!
Thomas


2010/6/3 Greg Snow :
> It looks like polar.plot does not handle negative lengths, you can preprocess 
> the data and just add 180 degrees to the angles corresponding to negative 
> lengths and then use their absolute values.
>
> The radial.lim is not ignored, based on the documentation the range is then 
> made pretty (and 100 is apparently prettier than 90), if you pass a longer 
> vector (e.g. c(30,60,90) ) then those exact values will be used.
>
> The lines function is plotting in Cartesian coordinates, not the polar 
> coordinates.
>
> --
> Gregory (Greg) L. Snow Ph.D.
> Statistical Data Center
> Intermountain Healthcare
> greg.s...@imail.org
> 801.408.8111
>
>
>> -Original Message-
>> From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-
>> project.org] On Behalf Of Thomas Steiner
>> Sent: Thursday, June 03, 2010 8:09 AM
>> To: r-help@r-project.org
>> Subject: [R] plot polar coordinates
>>
>> Hi,
>> I'd like to plot in in polar coordinates a line which is given as a
>> vector of lengths and angles.
>>
>> library("plotrix")
>> polar.plot(length=c(1,-13,3,-
>> 1),polar.pos=c(20,20,45,55),rp.type="p",line.col="red",lwd=3,clockwise=
>> TRUE,label.pos=seq(30,360,by=30),labels=c("ESE","SSE","S","SSW","WSW","
>> W","WNW","NNW","N","NNE","ENE","E"),radial.lim=c(0,90))
>> lines(seq(0,285,by=15),rep(c(40,60),times=10),col="blue")
>>
>> My questions:
>> a) Why is the radial.lim=c(0,90) ignored?
>> b) Why is there no red line?
>> c) Why is the blue line not "jumping" between two circles of radius 40
>> respectively 60 (The first argument of "line" should be the angle, the
>> second the length.)? Or: which function plots in existing polar plots?
>> (Remark the the polygone is not complete, eg going around)
>>
>> My final goal will be such a plot:
>> http://www.mysundial.ca/tsp/images/sun_chart_50_solar_polar.jpg which
>> is the polar-coordinate version of my wikimedia plot
>> http://commons.wikimedia.org/wiki/File:Sonnenstand.png (made in R, see
>> source)
>> Thanks for hints and help,
>> Thomas
>>
>> PS: I asked a close question last year:
>> http://www.mail-archive.com/r-help@r-project.org/msg64998.html
>>
>> __
>> 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.


[R] plot polar coordinates

2010-06-03 Thread Thomas Steiner
Hi,
I'd like to plot in in polar coordinates a line which is given as a
vector of lengths and angles.

library("plotrix")
polar.plot(length=c(1,-13,3,-1),polar.pos=c(20,20,45,55),rp.type="p",line.col="red",lwd=3,clockwise=TRUE,label.pos=seq(30,360,by=30),labels=c("ESE","SSE","S","SSW","WSW","W","WNW","NNW","N","NNE","ENE","E"),radial.lim=c(0,90))
lines(seq(0,285,by=15),rep(c(40,60),times=10),col="blue")

My questions:
a) Why is the radial.lim=c(0,90) ignored?
b) Why is there no red line?
c) Why is the blue line not "jumping" between two circles of radius 40
respectively 60 (The first argument of "line" should be the angle, the
second the length.)? Or: which function plots in existing polar plots?
(Remark the the polygone is not complete, eg going around)

My final goal will be such a plot:
http://www.mysundial.ca/tsp/images/sun_chart_50_solar_polar.jpg which
is the polar-coordinate version of my wikimedia plot
http://commons.wikimedia.org/wiki/File:Sonnenstand.png (made in R, see
source)
Thanks for hints and help,
Thomas

PS: I asked a close question last year:
http://www.mail-archive.com/r-help@r-project.org/msg64998.html

__
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] pdf pagesize

2009-12-04 Thread Thomas Steiner
Hi,
when I create huge pdf files (width is 6meters) with R I cannot open
them in Adobe Acrobat reader (I tried version 9 and some lower). I use
pdf() of grDevices version 2.8.1 and CairoPDF from Cairo version
1.4-4. When I add the (perhaps since pdf version 1.7 pagesizes of more
than 200in are possible?) version="1.7" I get an error ("ungültige PDF
Version") from pdf() and no error from CairoPDF() (but it is ignored).
I use R version 2.8.1.
How can I make version 1.7 pdf files to make these big files view- and
printable?
Thanks
Thomas

PS: To make it quick, the IMHO crutial part of the ?pdf help:
The version argument declares the version of PDF that gets produced.
The version must be at least 1.4 for semi-transparent output to be
understood, and at least 1.3 if CID fonts are to be used: if these
features are used the version number will be increased (with a
warning). Specifying a low version number is useful if you want to
produce PDF output that can be viewed on older or non-Adobe PDF
viewers. (PDF 1.4 requires Acrobat 5 or later.)

__
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] Roman numerical output

2009-11-29 Thread Thomas Steiner
I have integers and I want R to give them back/output as Roman numerals:
s=c(7,17)
format(s,roman=T)
is obviously wrong. Is there any other way/function to do this?
Thanks,
Thomas

__
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] fill map with gradient: package?

2009-11-08 Thread Thomas Steiner
Thanks Paul.
I'm still struggeling with some beginners issues on the ps-import
(windows troubles with installing ghostscript), but when I resolved
them I'm sure that I can use your example code which loos great to me.
Thanks a lot,
Thomas


2009/11/4 Paul Murrell :
> Hi
>
>
> Thomas Steiner wrote:
>>
>> Hi,
>> I'd like to fill an existing svg (or png) map with gradient colors.
>> In detail: The file
>>
>> http://commons.wikimedia.org/wiki/File:Karte_%C3%96sterreich_Bundesl%C3%A4nder.svg
>> should be filled with the population density data from this table:
>> http://de.wikipedia.org/wiki/%C3%96sterreich#Verwaltungsgliederung
>> choosing the right color saturation (or whatever). The final result
>> should be something like this map:
>>
>> http://commons.wikimedia.org/wiki/Image:Bevoelkerungsdichte_-_Oesterreich.svg
>> Is there a package or so for these two tasks (filling and color
>> density ploting)?
>
>
> The 'grImport' package can help with getting the SVG into R (see
> http://www.jstatsoft.org/v30/i04).
>
> First step is to convert the SVG to PostScript (I used InkScape - you can
> play around with how the text comes across, but I'm going to ignore that and
> concentrate on the map regions).
>
> Having done that, the following code loads the map into R and draws it ...
>
> library(grImport)
> PostScriptTrace("Austria-Map-withFonts.ps", charpath=FALSE)
> map <- readPicture("Austria-Map-withFonts.ps.xml")
> grid.picture(map)
>
> ... (the orientation may be 90 degrees out and you may get some warnings
> about character encodings;  the former is easy to fix [see below] and the
> latter can just be ignored for now because we are ignoring the text).  The
> next code shows the breakdown of the map into separate "paths" ...
>
> grid.newpage()
> picturePaths(map)
>
> ... from which we can see that the regions are the first 10 paths ...
>
> grid.newpage()
> grid.picture(map[1:10], use.gc=FALSE)
>
> At this point, you can use grImport to draw the regions with different fill
> colours, or you can just extract the x,y coordinates of the regions and
> go-it-alone.  The following code takes the latter path, setting up 10
> different colours, and drawing each region using grid.polygon().  The
> orientation is fixed by pushing a rotated viewport first ...
>
>
> colours <- hcl(240, 60, seq(30, 80, length=10))
> grid.newpage()
> pushViewport(viewport(angle=-90),
>             grImport:::pictureVP(map[1:10]))
> mapply(function(p, col) {
>           grid.polygon(p$x, p$y, default.units="native",
>                        gp=gpar(fill=col))
>       },
>       regions, colours)
>
>
> Hope that helps.
>
> Paul
>
>
>> Thanks for your help,
>> Thomas
>>
>> __
>> 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] fill map with gradient: package?

2009-11-03 Thread Thomas Steiner
Hi,
I'd like to fill an existing svg (or png) map with gradient colors.
In detail: The file
http://commons.wikimedia.org/wiki/File:Karte_%C3%96sterreich_Bundesl%C3%A4nder.svg
should be filled with the population density data from this table:
http://de.wikipedia.org/wiki/%C3%96sterreich#Verwaltungsgliederung
choosing the right color saturation (or whatever). The final result
should be something like this map:
http://commons.wikimedia.org/wiki/Image:Bevoelkerungsdichte_-_Oesterreich.svg
Is there a package or so for these two tasks (filling and color
density ploting)?
Thanks for your help,
Thomas

__
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] plotrix: reverse axis in polar.plot

2009-08-10 Thread Thomas Steiner
Hi,
how can I reverse the radius axis of plotrix's polar.plot function?
Perhaps this sounds strange, but I use the radians for angles as well:
In the center is zenith and the corresponding angle is 90°, not 0. See
an example plot at
http://www.mysundial.ca/tsp/images/sun_chart_50_solar_polar.jpg

dirs<-c("S","E","N","W")
polar.plot(NA,NA,label.pos=seq(0,270,length=4),labels=dirs,main="Sun
Chart",rp.type="p",radial.lim=c(0,90))
lines(c(4,12,15,22,45,55),c(10,83,118,90,72,61),col="red")

And why is the radial limit in the above example 0..100 and not 0..90
as requested by the radial.lim argument?

Thanks for your help,
Thomas

__
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] package to convert coordiantes to timezone

2009-08-04 Thread Thomas Steiner
Thanks you, this helps.
Great,
Thomas


2009/8/3 Michael Denslow :
> Hi Thomas,
>
> On Sun, Aug 2, 2009 at 11:02 AM, Thomas Steiner wrote:
>> Is there a R-package with a function that returns me the timezone, if
>> I hand over longitude and latitude?
>> I know online services like
>> http://ws.geonames.org/timezone?lat=-38.01&lng=147 and
>> http://www.earthtools.org/webservices.htm#timezone and wodner if this
>> exists for R too.
>> Thanks for helping,
>> thomas
>>
>
> There is a geonames package.
>
>> library(geonames)
> Loading required package: rjson
>> GNtimezone(-38.01,147)
>              time countryName rawOffset dstOffset countryCode
> gmtOffset lng          timezoneId    lat
> 1 2009-08-03 10:23   Australia        10        10          AU
> 11 147 Australia/Melbourne -38.01
> Warning message:
> In readLines(u) :
>  incomplete final line found on
> 'http://ws.geonames.org/timezoneJSON?lat=-38.01&lng=147'
>
> Not sure why I get this error but I think this is what you are after,
>
> Michael
>
> _
>> 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.
>>
>
>
>
> --
> Michael Denslow
>
> Graduate Student
> I.W. Carpenter Jr. Herbarium [BOON]
> Department of Biology
> Appalachian State University
> Boone, North Carolina U.S.A.
>
> -- AND --
>
> Communications Manager
> Southeast Regional Network of Expertise and Collections
> sernec.org
>

__
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] package to convert coordiantes to timezone

2009-08-02 Thread Thomas Steiner
Is there a R-package with a function that returns me the timezone, if
I hand over longitude and latitude?
I know online services like
http://ws.geonames.org/timezone?lat=-38.01&lng=147 and
http://www.earthtools.org/webservices.htm#timezone and wodner if this
exists for R too.
Thanks for helping,
thomas

__
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] unicode only works with a second one

2009-04-05 Thread Thomas Steiner
Hi Greg and Paul,

I tried several things, but I did not succeed:

* I could not find the library(EBImage) on CRAN in Austria to open an
png image in R.

* I could not import the image via pixmap (read.pnm) as described on
http://wiki.r-project.org/rwiki/doku.php?id=tips:graphics-misc:translucency
because my GIMP cannot write pnm format.

* I could not manage use the 'grImport' package to trace the svg:
> readPicture("Aries.svg")
Fehler in readPicture("Aries.svg") :
  Version mismatch: RGML file needs to be recreated with PostScriptTrace()

* I gave up modifiying the svg code from wikipedia to make it an R
array (structure) as you greg described it above.

If you have any hint for me please let me know. I am willing to
contribute something to TeachingDemos (although I am not sure if this
is not a license problem as I trace the (public domain) images from
wikimedia.

Otherwise I am happy with the Hershey fonts so far.
Thomas

__
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] unicode only works with a second one

2009-04-01 Thread Thomas Steiner
Hi,
thanks for all your hints.

> One of the points of my.symbols is that you can define your own symbols to 
> use with it (hence the my).

I tried this and it works fine. I need all the symbols and I will
probably not trace them, but copy the svg code and modify them from
http://commons.wikimedia.org/wiki/Zodiac
I will do this on the weekend.

> Paul:
> Another workaround is to use the Hershey fonts.  For example ...

\\VE \\MA work fine, but I need all twelve zodiac symbols.

Thomas

__
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] unicode only works with a second one

2009-03-31 Thread Thomas Steiner
unfortunately in my.symbols there are no zodiac signs, so I have to
choose unicode which does not work for me yet.
Thomas


2009/3/31 Thomas Steiner :
> Thanks for the feedback.
> I did now try Vista (2.8.1), XP (2.9.0alpha) and Win2000 (2.8.1) and
> non did work compeletely, only on Vista/2.8.1 I got some symbols if I
> add the other sign. I will try the my.symbols later today, when i am
> at home.
> Thomas
>

__
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] unicode only works with a second one

2009-03-31 Thread Thomas Steiner
Thanks for the feedback.
I did now try Vista (2.8.1), XP (2.9.0alpha) and Win2000 (2.8.1) and
non did work compeletely, only on Vista/2.8.1 I got some symbols if I
add the other sign. I will try the my.symbols later today, when i am
at home.
Thomas

__
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] unicode only works with a second one

2009-03-28 Thread Thomas Steiner
I forgot to ad some info:

> sessionInfo()
R version 2.9.0 alpha (2009-03-23 r48200)
i386-pc-mingw32

locale:
LC_COLLATE=German_Austria.1252;LC_CTYPE=German_Austria.1252;LC_MONETARY=German_Austria.1252;LC_NUMERIC=C;LC_TIME=German_Austria.1252

attached base packages:
[1] stats graphics  grDevices utils datasets  methods   base


and from http://www.mail-archive.com/r-help@r-project.org/msg44163.html
I learned that it depends on my runing OS / installation. I know that
this is not an R question, but I have no idea how to proceed...

Thomas


2009/3/29 Thomas Steiner :
> I now tried a differnt R version under a drifferent OS, even worse: R
> version 2.9.0 alpha (2009-03-23 r48200) with Windwos XP does only show
> "\u2642". Do I need to install some fonts or so?
> Thanks
> Thomas
>
>
> 2009/3/28 Thomas Steiner :
>> I'd like to paste a zodiac sign on a graph, but it only prints it when
>> I add another unicode ( \u3030) to the desired \u2648 - why?
>> See the examplecode (compare the orange with the skyblue):
>>
>> plot(c(-1,1),c(-4,-2),type="n")
>> text(x=0,y=-3.0,labels="\u2648 \u3030",cex=2.3,col="skyblue")
>> text(x=0,y=-3.2,labels="\u2648",cex=2.3,col="orange")
>> zodiac=c("\u2642 \u2643 \u2644 \u2645 \u2646 \u2647 \u2648 \u2649
>> \u2650 \u2651 \u2652 \u2653")
>> text(x=0,y=-3.5,labels=paste(zodiac,"\u3030"),cex=2.3,col="navy")
>>
>> I use R version 2.8.1 (2008-12-22) under MS Windows Vista.
>> Thanks for help
>> Thomas
>>
>

__
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] unicode only works with a second one

2009-03-28 Thread Thomas Steiner
I now tried a differnt R version under a drifferent OS, even worse: R
version 2.9.0 alpha (2009-03-23 r48200) with Windwos XP does only show
"\u2642". Do I need to install some fonts or so?
Thanks
Thomas


2009/3/28 Thomas Steiner :
> I'd like to paste a zodiac sign on a graph, but it only prints it when
> I add another unicode ( \u3030) to the desired \u2648 - why?
> See the examplecode (compare the orange with the skyblue):
>
> plot(c(-1,1),c(-4,-2),type="n")
> text(x=0,y=-3.0,labels="\u2648 \u3030",cex=2.3,col="skyblue")
> text(x=0,y=-3.2,labels="\u2648",cex=2.3,col="orange")
> zodiac=c("\u2642 \u2643 \u2644 \u2645 \u2646 \u2647 \u2648 \u2649
> \u2650 \u2651 \u2652 \u2653")
> text(x=0,y=-3.5,labels=paste(zodiac,"\u3030"),cex=2.3,col="navy")
>
> I use R version 2.8.1 (2008-12-22) under MS Windows Vista.
> Thanks for help
> Thomas
>

__
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] unicode only works with a second one

2009-03-28 Thread Thomas Steiner
I'd like to paste a zodiac sign on a graph, but it only prints it when
I add another unicode ( \u3030) to the desired \u2648 - why?
See the examplecode (compare the orange with the skyblue):

plot(c(-1,1),c(-4,-2),type="n")
text(x=0,y=-3.0,labels="\u2648 \u3030",cex=2.3,col="skyblue")
text(x=0,y=-3.2,labels="\u2648",cex=2.3,col="orange")
zodiac=c("\u2642 \u2643 \u2644 \u2645 \u2646 \u2647 \u2648 \u2649
\u2650 \u2651 \u2652 \u2653")
text(x=0,y=-3.5,labels=paste(zodiac,"\u3030"),cex=2.3,col="navy")

I use R version 2.8.1 (2008-12-22) under MS Windows Vista.
Thanks for help
Thomas

__
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] r online

2009-03-24 Thread Thomas Steiner
Hi,
I'd like to execute simple commands and functions in R through a
website, is there any service like this somewhere?
I only found http://www.osvisions.com/r-online/ but it does not work
(last update 2003) and the links to releated websites only give errors
(if I calculate 7+3).
Thanks for help & hints,
Thomas

__
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] D'Hondt method

2009-02-04 Thread Thomas Steiner
very cool, easier than I thought... (although I am not fully familiar
with sapply() and friends)

quick reality-check (no proof!) at
http://icon.cat/util/elections/isuHqUyDYh shows that the results
coincide:

votes <- c(42201,38635,247736,170627,48236,117151,61379,35889,92321)
dHont(c("BGLD","KTN","NÖ","OÖ","SLBG","STMK","T","VLBG","W"), votes, 26)

so thanks a lot, have a great day!

Thomas

__
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] D'Hondt method

2009-02-04 Thread Thomas Steiner
Is there a R function to calculate the seats in parliament given the
total number of seats and the votes for each party -- for different
methods including the method of D'Hont?
http://en.wikipedia.org/wiki/D%27Hondt_method
Thanks,
thomas

__
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] pass longer arguments to adj of text()

2008-10-20 Thread Thomas Steiner
Brian, thank you for your reply.

> Why do you expect this to be vectorized when the help page clearly says
> otherwise?

Sure, it's in line with the help, no problem there. I just asked if
this feature is somehow possible.
I expected it, because "pos" does take arrays and it "overrides any
adj value given" (see help). So if "pos" does, why not "adj"?

> What is wrong with two or more text() calls?

it's quicker and more beautiful.
See my code at the end (last loop) of
http://commons.wikimedia.org/wiki/Image:Sonnenstand.png

Thomas

> NB: library(fortunes); fortune("WTFM") applies.

This one I didn't get. They help to do it without a loop?

__
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] pass longer arguments to adj of text()

2008-10-20 Thread Thomas Steiner
...and the offset argument can't handle arrays either:

text(c(0,0),c(0,0),c("a","b"),pos=c(1,2),offset=c(1,0.5),col="darkgreen")

The second argument does not have any effect.
Can I pass arrays to text and use diffent locations?
Thomas

PS: I use R version 2.5.0 (2007-04-23) under Win2000.

__
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] pass longer arguments to adj of text()

2008-10-20 Thread Thomas Steiner
Hi,

text()'s pos does handle more dimensional labels, while adj does not -
or how can I pass an array to text() and use the adj argument (skyblue
text)?

plot(-1:1,-1:1)
text(c(0,0),c(0,0),c("a","b"),pos=c(1,2),col="red")
text(c(0,0),c(0,0),c("a","b"),adj=cbind(c(1,2),c(1,1)),col="skyblue")

Thomas

__
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] convert lines to inches

2008-10-19 Thread Thomas Steiner
Ok, thanks Peter, I try to be more accurate:

pdf("test.pdf",width=(20+2+4)/2.54,height=(10+3+1)/2.54)
x=seq(0,pi,length=100)
par( mai=c(2,3,4,1)/2.54 )
plot(x,cos(x),type="l",xlim=c(0,3),ylim=c(-1.2,1.2),xaxs="i",yaxs="i",asp=1)
conv=par("mar")/par("mai")
box("figure", col="darkblue")
dev.off()

Then figure has as expected the size 26x14cm.
But the size of the *Plot Area* is not as expected 20x10cm, but
22x8cm, although I chose the margins in inches as 2 and 4 cm below and
above (=26-(2+4)). Probably I confuse something with lines and inches.
I'd like to have a plot area of 20x10cm and around it a (2,3,4,1)cm
margin.
Thanks for hints and have a nice Sunday,
Thomas

__
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] convert lines to inches

2008-10-19 Thread Thomas Steiner
Hi,

how can I convert the unit "lines" of par("mar") into inches?
par("mai") could help, but does not (see code below).

I want to plot a curve in a predefined size in pdf (I add some margin
space to the plot width&height, everything is in cm):
pdf("test.pdf",width=(20+2+4)/2.54,height=(10+3+1)/2.54)
plot(10:30, 
9*cos(10:30),type="l",xlim=c(10,30),ylim=c(-10,15),xaxs="i",yaxs="i",asp=1)
#par(mar=c(0,0,0,0))
par(mai=c(2,3,4,1)/2.54)
box("figure", col="darkblue")
dev.off()

The size of the darkblue box is fine, but I cannot yet control the
size of the plot area (although
http://research.stowers-institute.org/efg/R/Graphics/Basics/mar-oma/index.htm
helped me a lot). And seeting the mar to zero (#) works in a R figure,
but not in a pdf. Why?

I already asked ("draw a 5cm x 3cm rectangle") a related question
three days ago, but I was unable to get a more complicated example in
the grid package (solution there) running.

Thanks for giving hints,
Thomas

__
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] draw a 5cm x 3cm rectangle

2008-10-17 Thread Thomas Steiner
Thanks Erik,
grid.lines() gives me exactly what I wanted.
Have a nice weekend!
Thomas


library(grid)
pdf("rect.pdf", paper="a4r")
grid.lines(x=c(1,1,3),c(1,2,2),default.units="cm")
grid.lines(x=c(1,1,3)+1,c(1,2,2)+0.5,default.units="cm",gp=gpar(col="blue"))
dev.off()

__
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] draw a 5cm x 3cm rectangle

2008-10-16 Thread Thomas Steiner
Hi I want to draw sth in a pdf file with a predefined defined size.
Say a 5cm x 3cm rectangle (a ruler):

pdf("rect.pdf", paper="a4")
plot(c(1,5,5,1,1),c(1,1,3,3,1),asp=1,axes="n")
dev.off()

but how do I fix that one unit is 1cm?
Thanks
thomas

__
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] fft: characteristic function to distribution

2008-05-13 Thread Thomas Steiner
Matthias Kohl was so kind and provided me the following lines in this issue:

library(distrEx)
chf <- function(t, D){
  E(D, function(x){exp(1i*t*x)}, useApply = FALSE)
}

## Normalverteilung
D <- Norm()
t <- seq(-3, 3, by = 0.05)
chf.norm <- sapply(t, chf, D = D)
chf.exakt <- exp(-t^2/2)
chf.diff <- chf.norm - chf.exakt
plot(chf.diff)
abs(chf.diff)


This is nice BUT:
* Only built-in distributions can be used
* I want to understand the fft() function, instead here you used E()
of the distrEx package.

Apart from this it was exactly what i was looking for: I know the
characteristic function and want to get the distribution. (My porposal
was to use fft(,inverse=T).)
Any help appreciated,
Thomas

__
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] fft: characteristic function to distribution

2008-05-07 Thread Thomas Steiner
Thank you Prof Ripley for your answer.

> > The characteristic function is the inverse Fourier transform of the
> > distribution function. The characteristic function of a normaly
> > distributed random variable is exp(-t^2/2).
> >
>
> The fft is a discrete Fourier transforn, not a continuous one.

This is correct. I try to approximate the continous normal
distribution with infinite support by a set of discrete and bounded
points. A real discrete baby example would be the bernoulli
distribution:

p=0.4
t=seq(-0.01,1.001,length=100)
char=1-p+p*exp(1i*t)
cdf=stepfun(c(0,1),c(0,1-p,1))
plot(t,cdf(t),type="l",col="red",ylim=range(cdf(t),Re(fft(char)[2:99])))
lines(t,fft(char),col="blue")

This is more or less like the normal example.

> Further in each case where the normalizing constants are placed and the
> units of frequecy differ from source to source.
>
> ?fft has references to exactly what it computes: please consult them.

I read the documentation/help page. More details there would be
helpful. For example an example (it says "example*s*") something where
explicit expressions are known (as I tried it here).
Another possible improvement could be to make for example the
following sentence nicer/clearer: "(the inverse has a + in the
exponent of e, but here, we do not divide by 1/length(x))."
I did not consult the two given references (two old but surely valuable books).

Enough prattled. Can you give a working example where the cummulative
distribution function and the fourier transform are explicitly known?

I cannot add any value neither to wonderful R nor to this helpful
function. But perhaps my question isn't that stupid and you can give a
hint to proceed. Thank you very much in advance,
Thomas

__
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] fft: characteristic function to distribution

2008-04-30 Thread Thomas Steiner
The characteristic function is the inverse Fourier transform of the
distribution function. The characteristic function of a normaly
distributed random variable is exp(-t^2/2).

x=seq(-2,2,length=100)
fft(pnorm(x),inverse=T)/length(x)
exp(-x^2/2)

Why aren't the inverse fft and the mentioned function the same?
Thanks for help,
Thomas

__
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] little subplot in corner

2008-03-24 Thread Thomas Steiner
Wonderful, thanks a lot.
I just have to call the plot first and then the rect (and then I can
plot it again)... %D
Have a nice day,
Thomas

__
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] little subplot in corner

2008-03-24 Thread Thomas Steiner
Henrique,

Although your solution is perfect, I had later a problem with setting
the background. Perhaps you know how to get this as well:

set.seed(24032008)
plot(rnorm(10),type="l",col="red")
grid()
front=c(0.5, .97, 0.5, .97)
par(fig=front, new=T)#, bg="skyblue" does not work
rec=c(par("usr")[1]+(par("usr")[2]-par("usr")[1])*front[1],
par("usr")[3]+(par("usr")[4]-par("usr")[3])*front[3],
par("usr")[1]+(par("usr")[2]-par("usr")[1])*front[3],
par("usr")[1]+(par("usr")[2]-par("usr")[1])*front[4])
#rect(rec[1],rec[2],rec[3],rec[4],col="yellow")
plot(rnorm(4),type="l",col="blue",xlab="",ylab="")

as you can see it would be good to be able to set the background of
the subfigure. as the par(bg=) does not work, I tried to plot a
rectangle. Just uncomment the send-last line and you will see that the
original plot disappears after some strange rectangle is drawn.

If you have any idea again, it would be evry much appreaciated to let me know.
Thomas

PS: to see my first attempts, look at
http://commons.wikimedia.org/wiki/Image:Eurusd-id.png

__
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] intraday OHLC plot

2008-03-24 Thread Thomas Steiner
Dear all,

thank you very much for continuing to look into this issue!
I checked the versions and in Gabor's code the spaces and tabs, but
still the problem remains (see code and error below).

To install quantmod, I used this time Rforge and it did not work. I
had to install the "Defaults" package from cran first by hand (ie not
like zoo and xts where it recognizes the dependence). And to get the
most recent version of the package I had to upgrade R as well (my
mistake of course). The link mentioned by Jeff points to 0.3.4, but I
got by the command
install.packages("quantmod",repos="http://R-Forge.R-project.org";) the
version 0.3.3 as you see below.

> Lines <- '17-03-2008 00:00:001,57641,57661,57471,5750
+ 17-03-2008 00:05:001,57491,57501,57411,5744
+ 17-03-2008 00:10:001,57451,57621,57411,5749'
> DF <- read.delim2(textConnection(Lines))
> library(quantmod)
Lade nötiges Paket: Defaults
quantmod: Quantitative Financial Modelling Framework

Version 0.3-3
http://www.quantmod.com

Warning message:
ungenutzte Verbindung 3 (Lines) geschlossen
> z <- read.zoo(textConnection(Lines), # replace with "myfile.dat"
+header = F, sep = "\t", dec = ",",
+format = "%d-%m-%Y %H:%M:%S", tz = "")
Fehler in read.zoo(textConnection(Lines), header = F, sep = "\t", dec = ",",  :
  index contains NAs
> q <- as.quantmod.OHLC(z, col.names = c("Open", "High", "Low", "Close"))
Fehler in ncol(x) : objekt "z" nicht gefunden
> chartSeries(q)
Fehler in UseMethod("as.xts") : keine anwendbare Methode für "as.xts"
>
> sessionInfo()
R version 2.6.2 (2008-02-08)
i386-pc-mingw32

locale:
LC_COLLATE=German_Austria.1252;LC_CTYPE=German_Austria.1252;LC_MONETARY=German_Austria.1252;LC_NUMERIC=C;LC_TIME=German_Austria.1252

attached base packages:
[1] stats graphics  grDevices utils datasets  methods   base

other attached packages:
[1] quantmod_0.3-3 Defaults_1.1-1 xts_0.0-11 zoo_1.4-2

loaded via a namespace (and not attached):
[1] grid_2.6.2 lattice_0.17-4 tools_2.6.2
>


Anyway, after the upgarde and Jeff's hint to use the chartSeries
function it works. Now I still have to play around to make the labels
look nice...

Thanks a lot for all your help,
Thomas

__
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] update win FAQ q1?

2008-03-24 Thread Thomas Steiner
Hi,
on 
http://cran.at.r-project.org/bin/windows/base/rw-FAQ.html#Where-can-I-find-the-latest-version_003f
it says:
... The current release is distributed as an installer
`R-2.6.1-win32.exe' of about 30Mb. ...
however I find this file as well:
http://cran.at.r-project.org/bin/windows/base/R-2.6.2-win32.exe
I guess that in the FAQ it should read as 2.6.2
Have a nice holiday,
Thomas

__
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] intraday OHLC plot

2008-03-23 Thread Thomas Steiner
Dear Gabor and Jeff,

thanks for your hint! I tried it out and played around but could not
succeed completely:

> library(quantmod)
> raw=read.table(file="eurusd-id.csv",sep="\t",dec=",",header =T)
> date.d=as.POSIXct(raw$Date..GMT)
> z=zoo(cbind(raw$Open,raw$High,raw$Low,raw$Close),order.by=date.d)
> q <- as.quantmod.OHLC(z, col.names = c("Open", "High", "Low", "Close"))
> barChart(q,show.vol=F, show.grid=F,theme="white",name="EURUSD Intraday 
> data",up.col="black",dn.col="black",xlab="time",ylab="FX")
Fehler in as.graphicsAnnot(labels) : objekt "x.labels" nicht gefunden

So it does not find the object "x.labels"... I just fould in the
pdf-documentation that this should be of type character.

Perhaps you know why it fails,
Thomas

__
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] intraday OHLC plot

2008-03-22 Thread Thomas Steiner
I want to create a open/high/low/last plot of intraday data.
I try to use the function plotOHLC from the tsteries package. I create
my own multiple time series and then try to plot it.

raw Data Format (file eurusd2.csv):
"Date (GMT)""Open"  "High"  "Low"   "Last"
17-03-2008 00:00:00 1,5764  1,5766  1,5747  1,5750
17-03-2008 00:05:00 1,5749  1,5750  1,5741  1,5744
17-03-2008 00:10:00 1,5745  1,5762  1,5741  1,5749

> library("tseries")
> raw=read.delim2("eurusd2.csv")
> date.d=strptime(raw$Date..GMT,"%d-%m-%Y %H:%M:%S")
> x=ts(data=c(raw$Open,raw$High,raw$Low,raw$Last),c="mts")
> plotOHLC(x)
Fehler in if ((!is.mts(x)) || (colnames(x)[1] != "Open") ||
(colnames(x)[2] !=  :
Fehlender Wert, wo TRUE/FALSE nötig ist
>

so there is a value missing where it expected a T/F...

In Details of the help on the function plotOHLC it says:
The time scale of x must be in Julian dates (days since the origin).

Perhaps anyone can provide help here?
Thanks,
Thomas

__
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] little subplot in corner

2008-03-20 Thread Thomas Steiner
perfect, exactly what I was looking for. Thanks a lot!
many eggs to you...
Thomas

__
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] little subplot in corner

2008-03-20 Thread Thomas Steiner
I want to draw a little subplot ("overview") into my detailed plot. It
should be placed in say the top right corner and have the size of some
legend (like legend(x="topright", inset=0.03, ...)

#main plot
plot(rnorm(100))
#give little density in corner
plot(seq(-2,2,length=300),dnorm(seq(-2,2,length=300)),type="l")

I don't want something like par(mfrow=c(1,2)) as this gives subplots
of equal size.
I saw that gridBase is very flexible, but could not find a suitable example.

Thanks for help,
Thomas

__
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] legend: bold and color of border

2008-03-15 Thread Thomas Steiner
Hi Jim,

thank you very much for your answers!

>  > How do I write bold face in the legend - the function does not accept
>  > font=2 as argument?

>  par(font=2)

perfect, thanks.

>  > How do I plot a legend box with a background color, but not a border?
>  > Or, better: How do I specify the color of the legend-box-borderline?

>  before calling legend.
>  If you just want a label as in your example, it might be easier to use:
>
>  boxed.labels(strptime("01/02/02","%d/%m/%y"),1.5,
>   "Beeblebrox",bg="lightblue",border=FALSE,col="white")

unfortunately this does not work. In the new code on
http://commons.wikimedia.org/wiki/Image:EurUsd.png I included the
following:
#library("plotrix")
#boxed.labels(x=10800,y=1.5,labels="Beeblebrox",bg="steelblue",border=FALSE,col="white",font=2,cex=3,adj=0)

which gives a much too smal box.
Perhaps the boxsize is not adjusted if the "cex" argument is used for the text?

Have a nice weekend,
Thomas

__
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] legend: bold and color of border

2008-03-14 Thread Thomas Steiner
How do I write bold face in the legend - the function does not accept
font=2 as argument?

How do I plot a legend box with a background color, but not a border?
Or, better: How do I specify the color of the legend-box-borderline?

Okay, I abuse the legend, but have a look at
http://de.wikipedia.org/wiki/Bild:EurUsd.png if you want... Any
help/feedback appreciated!
Thomas

__
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] internet proxy settings (win)

2008-03-13 Thread Thomas Steiner
Thank you Philipp for your suggestions.
In Rprofile.site every line is commented out and I could not find any
.Rprofile. I even tried starting R with additional cmdline arguments
--no-environ and --no-init-file.
Still
> update.packages(ask='graphics')
--- Please select a CRAN mirror for use in this session ---
Fehler: Indizierung außerhalb der Grenzen
Zusätzlich: Warning messages:
1: In read.dcf(file = tmpf) : Line starting ' ...' is malformed!
2: In read.dcf(file = tmpf) : Line starting '...' is malformed!
3: In read.dcf(file = tmpf) : Line starting ' ...' is malformed!
>

This is as far as I allready have been - or not?
Thomas

__
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] internet proxy settings (win)

2008-03-12 Thread Thomas Steiner
Thanks Liviu, I am trying out what is proposed in the mentioned thread.

I start R by
"C:\Program Files\R\R-2.6.2\bin\Rgui.exe"
http_proxy="http://proxy.haifis.org:8080";

Then I do the following (selecting "Austria" as mirror)

> install.packages("package", method="wget")
--- Please select a CRAN mirror for use in this session ---
Fehler in gzfile(file, "r") : kann Verbindung nicht öffnen
Zusätzlich: Warning message:
In gzfile(file, "r") :
  cannot open compressed file
'C:\DOCUME~1\n301545\LOCALS~1\Temp\RtmpnsKQdi\file678418be', probable
reason 'No such file or directory'
> setwd('C:\\DOCUME~1\\n301545\\LOCALS~1\\Temp\\RtmpnsKQdi')
> install.packages("package", method="wget")
Fehler in gzfile(file, "r") : kann Verbindung nicht öffnen
Zusätzlich: Warning message:
In gzfile(file, "r") :
  cannot open compressed file
'C:\DOCUME~1\n301545\LOCALS~1\Temp\RtmpnsKQdi\file3d6c4ae1', probable
reason 'No such file or directory'
> update.packages(ask='graphics')
Fehler: Indizierung außerhalb der Grenzen
Zusätzlich: Warning messages:
1: In read.dcf(file = tmpf) : Line starting ' ...' is malformed!
2: In read.dcf(file = tmpf) : Line starting '...' is malformed!
3: In read.dcf(file = tmpf) : Line starting ' ...' is malformed!
> options(download.file.method="wget")
> update.packages(ask='graphics')
Fehler in gzfile(file, "r") : kann Verbindung nicht öffnen
Zusätzlich: Warning message:
In gzfile(file, "r") :
  cannot open compressed file
'C:\DOCUME~1\n301545\LOCALS~1\Temp\RtmpnsKQdi\file5f906952', probable
reason 'No such file or directory'

Obviously the update.packages does have access to internet, but has
problems with the html tag. Who can help?

Thomas

__
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] internet proxy settings (win)

2008-03-10 Thread Thomas Steiner
> OK, that's perfect. Then the proxy configuration is still wrong. MAybe
> you want to try the other way given in the R for Windows FAQs and
> re-check your proxy settings.

I did try the other ways and the above trial shows some progress:
> utils:::menuInstallPkgs()
--- Please select a CRAN mirror for use in this session ---
Warnung: unable to access index for repository
http://cran.at.r-project.org/bin/windows/contrib/2.6
Warnung: unable to access index for repository
http://www.stats.ox.ac.uk/pub/RWin/bin/windows/contrib/2.6
Fehler in install.packages(NULL, .libPaths()[1], dependencies = NA,
type = type) :
  no packages were specified
Zusätzlich: Warning message:
In open.connection(con, "r") : kann 'cran.r-project.org' nicht auflösen


starting with --internet2:
> utils:::menuInstallPkgs()
--- Please select a CRAN mirror for use in this session ---
Fehler: Indizierung außerhalb der Grenzen
Zusätzlich: Warning messages:
1: In read.dcf(file = tmpf) : Line starting ' ...' is malformed!
2: In read.dcf(file = tmpf) : Line starting '...' is malformed!
3: In read.dcf(file = tmpf) : Line starting ' ...' is malformed!


I also tried
"C:\Program Files\R\R-2.6.2\bin\Rgui.exe"
http_proxy=myproxy.mycompany.com http_port=8080

but it gives the same resuat as the very frist solution ("malformed").

What about the firewall settings mentoined in the FAQ?

Thomas

__
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] internet proxy settings (win)

2008-03-10 Thread Thomas Steiner
> Which mirror do you use?

As I am living in Vienna, I use "Austria". Which should I try?
Thomas

__
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] internet proxy settings (win)

2008-03-10 Thread Thomas Steiner
I cannot access internet through R.
My IT-guys told me that I should set the proxy and the port and then
everything will be fine. Where can I set them?
I use R 2.6.2 under Windows 2000 and these settings are those of the
Internet Explorer (no password).

I read 
http://cran.at.r-project.org/bin/windows/base/rw-FAQ.html#The-Internet-download-functions-fail_002e
but staring R by
"C:\Program Files\R\R-2.6.2\bin\Rgui.exe" --internet2
a package update still gives me an error:

> update.packages(ask='graphics')
--- Please select a CRAN mirror for use in this session ---
Fehler: Indizierung außerhalb der Grenzen
Zusätzlich: Warning messages:
1: In read.dcf(file = tmpf) : Line starting ' ...' is malformed!
2: In read.dcf(file = tmpf) : Line starting '...' is malformed!
3: In read.dcf(file = tmpf) : Line starting ' ...' is malformed!

Do you know what I could try next?
Thanks
Thomas

__
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] R object as a function

2008-01-22 Thread Thomas Steiner
Dear Duncan,

thanks a lot for your answer. I was think a was distracted by the FED
rate cut ;)
Now it works.
Have a nice day
Thomas

myfun1<-function(x,pa) {
  return(pa[1]*x^2+pa[2]*x+pa[3])
}
myfun2<-function(x,param,myfunk1,pa) {
  return(param[1]*myfunk1(x,pa)+param[2]*myfunk1(-x,pa))
}
test<-function(pars1,pars2,lo,up){
  
integ=integrate(f=myfun2,lower=lo,upper=up,param=pars2,myfunk1=myfun1,pa=pars1)
  return( integ$value )
}
test(pars1=c(1,2,3),pars2=c(-1,0),lo=1,up=7)

__
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] R object as a function

2008-01-22 Thread Thomas Steiner
Thank you very much Duncan for your quick answers.

> You're not passing a function as myfunk1, you're passing mf, which is
> the result of evaluating myfun1, so it's a numeric vector.

Yes, this is exacty my problem.
If I leave it away, the problem will not be resolved (it needs pa or not)

myfun1<-function(x,pa) {
  return(pa[1]*x^2+pa[2]*x+pa[3])
}
myfun2<-function(x,param,myfunk1) {
  return(param[1]*myfunk1(x)+param[2]*myfunk1(x))
}
test<-function(pars1,pars2,lo,up){
  
integ=integrate(f=myfun2,lower=lo,upper=up,param=pars2,myfunk1=myfun1)#pa=pars1
  return( 2*integ$value )
}
test(pars1=c(1,2,3),pars2=c(-1,1),lo=2,up=7)

Which gives an error:
Once the "argument pa" is missing  and if you add the "pa=pars1" in
the comment, it says that the argument pa is redundant.

Thanks for help,
Thomas

__
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] R object as a function

2008-01-22 Thread Thomas Steiner
Okay, let me try to better say what I meant:

myfun1<-function(x=5,pa) {
  return(pa[1]*x^2+pa[2]*x+pa[3])
}
myfun2<-function(x=5,param,myfunk1) {
  return(param[1]*myfunk1(x)+param[2]*myfunk1(x))
}
test<-function(pars1,pars2,lo,up){
  mf=myfun1(x=2,pa=8*pars1)
  integ=integrate(f=myfun2,lower=lo,upper=up,param=pars2,myfunk1=mf)
  return( 2*integ$value )
}
test(pars1=c(1,2,3),pars2=c(-1,1),lo=2,up=7)

So the function myfun2 will be integrated and has a function (myfunk1)
itself as an argument.
Why is this not possible?
Thanks,
Thomas

PS: the "x=5" and "pa=8*" has no influence...

__
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] R object as a function

2008-01-22 Thread Thomas Steiner
I want to use a function as an argument to ingtegrate it twice.
See the following (senseless) example of a double integration:

test<-function(sf,lo,up,rest) {
  innerFkn<-function(sf,lo) {
inte=integrate(f=sf,lower=lo,upper=4)
return( inte$value )
  }
  integral=integrate(f=innerFkn,lower=1,upper=2,sf=sf,lo=lo,up=up)
  return( integral$vlaue+rest )
}
test(sf=stepfun(c(0,1),c(2,-1,3)),lo=0,up=2,rest=12)

Why isn't it possible to define the "innerFkn" inside "test"?
"sf" is a stepfun, but it should possibly be any function.
How can I define some R object like a stepfun (depending on variables)
which can be evaluated like a function at some "lo"?
Thanks for help,
Thomas

__
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] legend of type "b"

2007-11-10 Thread Thomas Steiner
How can I choose the (line/plot) type "b"oth in the legend?

plot(1:5,rnorm(1:5),type="b")
legend("topright","random",lty=10)

Thanks,
Thomas

__
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.