[R] adjust font in ggplot2 to LaTeX document

2012-10-01 Thread Jonas Stein
Hi,

how can i adjust the font in a ggplot2 qplot so that it will look 
similar to the LaTeX font? 
Computer Modern Sans Serif in the same size would be nice.

My output device is 
ggsave(filename=test.pdf, width=5.5, height=3, dpi=300)
and i will include the graphic with 5.5 inch in LaTeX.

I found some pages about that topic but all solutions that i found have
been very complicate and confusing to me. 
But the articles have been from 2009 too, so i guess there will be
some easy solution today...

Is theme the keyword to find the solution?
Or will i have to include a binary font file?

Can someone give me a link to an example?

Kind regards and thanks a lot,

-- 
Jonas Stein n...@jonasstein.de

__
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] how to qplot two x-axis x1:Farenheit x2:Celsius

2012-09-12 Thread Jonas Stein
Hi,

how can i plot two different x axis in a ggplot2 qplot?
I want to plot Farenheit and Celsius in one diagram.
x1:Farenheit x2:Celsius

kind regards,

-- 
Jonas Stein n...@jonasstein.de

__
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] qplot with many files (each one curve)

2012-09-10 Thread Jonas Stein
Hi,

i would like to plot a few hundred .csv files. 
Each file contains one curve with x,y values to plot.

I have been searching for gnu r read many files qplot 
and similar words. I found for loops that use assign to generate 
one variable containing a dataframe.

When i uesed the classic plot' command i could add 
the curves with something like

for... {
data-read.csv
points(data$x, data$y, col=myrainbow, type=l)
}

How would you solve it in ggplot?

Kind regards,

-- 
Jonas Stein n...@jonasstein.de

__
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] nls problem: singular gradient

2012-07-12 Thread Jonas Stein

On 07/12/2012 01:39 AM, Duncan Murdoch wrote:

On 12-07-11 2:34 PM, Jonas Stein wrote:

Take a look at the predicted values at your starting fit: there's a
discontinuity at 0.4, which sure makes it look as though overflow is
occurring. I'd recommend expanding tanh() in terms of exponentials and
rewrite the prediction in a way that won't overflow.

Duncan Murdoch


Hi Duncan,
Thank you for your suggestion. I wrote a function mytanh and
nls terminates a bit later with another error message:

Error in nls(data = dd, y ~ 1/2 * (1 - mytanh((x - ttt)/1e-04) *
exp(-x/tau2)), :
number of iterations exceeded maximum of 50

How can i fix that?
Kind regards,
Jonas

 R CODE STARTS HERE ===

mytanh- function(x){
return(x - x^3/3 + 2*x^5 /15 - 17 * x^7/315)
}


That looks like it would overflow as soon as abs(x-ttt) got large, just
like the original. You might be able to fix it by following the advice I
gave last time, or maybe you need to rescale the parameters. In most
cases optimizers work best when the uncertainty in the parameters is all
on the same scale, typically around 1.


I am not shure what you mean with rescale paramaeters, but i changed 
ttt and tau2 to 1 but nls still fails. Do you mean i can only use 
functions with tau2 and ttt close to 1?


Is there a better fit function then nls for R? Even origin can find 
the parameters without any problems.


nlsfit - nls(data=dd,  y ~  1/2 * ( 1- mytanh((x - ttt)/0.0001) * 
exp(-x / tau2) ), start=list(ttt=1, tau2=1) , trace=TRUE, control = 
list(maxiter = 100))




--
Jonas Stein n...@jonasstein.de

__
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] nls problem: singular gradient

2012-07-11 Thread Jonas Stein
Why fails nls with singular gradient here?
I post a minimal example on the bottom and would be very 
happy if someone could help me.
Kind regards,

###

# define some constants
smallc - 0.0001
t - seq(0,1,0.001)
t0 - 0.5
tau1 - 0.02

# generate yy(t)

yy - 1/2 * ( 1- tanh((t - t0)/smallc) * exp(-t / tau1) ) + 
rnorm(length(t))*0.01

# show the curve

plot(x=t, y=yy, pch=18)

# prepare data

dd - data.frame(y=yy, x=t)

nlsfit - nls(data=dd,  y ~  1/2 * ( 1- tanh((x - ttt)/smallc) * exp(-x / tau2) 
), start=list(ttt=0.4, tau2=0.1) , trace=TRUE)

# get error:
# Error in nls(data = dd, y ~ 1/2 * (1 - tanh((x - ttt)/smallc) * 
exp(-x/tau2)),  : 
#   singular gradient

-- 
Jonas Stein n...@jonasstein.de

__
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] nls problem: singular gradient

2012-07-11 Thread Jonas Stein
 Take a look at the predicted values at your starting fit:  there's a 
 discontinuity at 0.4, which sure makes it look as though overflow is 
 occurring.  I'd recommend expanding tanh() in terms of exponentials and 
 rewrite the prediction in a way that won't overflow.

 Duncan Murdoch

Hi Duncan,
Thank you for your suggestion. I wrote a function mytanh and 
nls terminates a bit later with another error message:

Error in nls(data = dd, y ~ 1/2 * (1 - mytanh((x - ttt)/1e-04) * exp(-x/tau2)), 
 : 
  number of iterations exceeded maximum of 50

How can i fix that?
Kind regards,
Jonas

 R CODE STARTS HERE ===

mytanh - function(x){
  return(x - x^3/3 + 2*x^5 /15 - 17 * x^7/315)
}

t - seq(0,1,0.001)
t0 - 0.5
tau1 - 0.02

yy - 1/2 * ( 1- tanh((t - t0)/0.0001) * exp(-t / tau1) ) + 
rnorm(length(t))*0.001

plot(x=t, y=yy, pch=18)

dd - data.frame(y=yy, x=t)

nlsfit - nls(data=dd,  y ~  1/2 * ( 1- mytanh((x - ttt)/0.0001) * exp(-x / 
tau2) ), start=list(ttt=0.5, tau2=0.02) , trace=TRUE)

 R CODE ENDS HERE ===

-- 
Jonas Stein n...@jonasstein.de

__
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] cairo_pdf() vs. pdf() what is the difference?

2012-04-16 Thread Jonas Stein
cairo_pdf() vs. pdf() what is the difference between them and 
which one would you suggest to use in combination with pdflatex?

kind regards,

-- 
Jonas Stein n...@jonasstein.de

__
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] how to plot 2d matrix as coloured squares?

2012-04-10 Thread Jonas Stein
i have a matrix like 

x1  x2  x3
y1  2   34  5656
y2  34  434 342
y3  234 43  34

i want to plot these values like here
http://www.almob.org/content/2/1/12/figure/F5?highres=y

The rainbow function could calculate a colour for each value.
But how van i generate the square pattern?
 
Kind regards,

-- 
Jonas Stein n...@jonasstein.de

__
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] fit data to y~A+B*sin(C*x)

2012-02-14 Thread Jonas Stein
I want to fit discrete data that was measured on a wavegenerator.
In this minimal example i generate some artificial data:

testsin - 2+ 5 * sin(1:100) #generate sin data
testsin -  testsin+ rnorm(length(testsin), sd = 0.01) #add noise

mydata - list(X=1:100, Y=testsin) # generate mydata object

nlmod - nls(X ~ A+B*sin(C* Y), data=mydata, start=list(A=2, B=4, C=1), 
trace=TRUE)

# this nls fit fails. 

Who can help me to fit this type of data?
Kind regards,

-- 
Jonas Stein n...@jonasstein.de

__
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] how to plot a nice legend?

2012-02-11 Thread Jonas Stein
i'd like to plot a legend in my diagram. The diagram will be included 
in a TikZ LaTeX document later.

I tried the legend() function, but 
- it can not find a good place it self where the legend fits
  and playing around with coordinates and scaling consumes a lot time

- standard settings for the text need adjustment 
  (linespacing is quite large and so on)

Is there an alternative to legend()?

Is it possible to place the legend() outside of the plot area?

Kind regards,

-- 
Jonas Stein n...@jonasstein.de

__
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] how to plot a nice legend?

2012-02-11 Thread Jonas Stein
 There are various alternatives available; you can also write your own, 
 by modifying the standard one.

 Generally there are lots of possibilities for customizing within the 
 standard one; e.g. y.intersp will affect the line spacing, using a 
 negative value for inset (together with xpd=NA) will allow the legend to 
 be moved outside the plot.

i tried without success:

plot(1:10)
legend(1,3, legend=c(one, two), inset=-1, xpd=NA)

The legend is still placed inside the plot on point (1,3)

What could i have done wrong?

Can i include a legend like this in a standard plot like 
plot(1:10) too?
http://www.r-bloggers.com/wp-content/uploads/2011/03/heatmap.png

kind regards,

-- 
Jonas Stein n...@jonasstein.de

__
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] how to plot a nice legend?

2012-02-11 Thread Jonas Stein
 Wrong? Nothing. You told R to put the legend at c(1,3)
 so it did. If you want it elsewhere you need to specify that.
 legend(-1,3, legend=c(one, two), inset=-1, xpd=NA)
 maybe, or some other location?

ok that works fine. Now i understand how to use it.
If i create several plots it would be nice if all legends would 
have the same distance to plots with different scaling.

Can the legend be placed vertically centered, 1cm right to the plot aera?

 Can i include a legend like this in a standard plot like
 plot(1:10) too?
 http://www.r-bloggers.com/wp-content/uploads/2011/03/heatmap.png

 Yes.

 What part of that do you want to duplicate? 

The coloured squares.
for the reader who got to this article and had the same question:
I have just found another nice solution for a colour legend a minute ago
http://www.r-bloggers.com/rethinking-loess-for-binomial-response-pitch-fx-strike-zone-maps/

 You can specify colors, symbols, labels, etc. in legend().

can i even invent my own symbols?

 Also, please link to the original blog post, not just the figure, so that
 the author gets some credit and we can see the code used.

sure 
http://www.r-bloggers.com/ggheat-a-ggplot2-style-heatmap-function/

kind regards,

-- 
Jonas Stein n...@jonasstein.de

__
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 package dev: how to export constant?

2012-01-19 Thread Jonas Stein
 Jonas, I've just seen your function 'sistring' code and it's different from
 the code in

Thanks a lot for reporting this bug. It is fixed now in the git 
repository.

I added some examples, but they do not work:

R CMD check sitools

= snip
 ### ** Examples
 
 library(sitools)
 
 # volume of a dice in metres
 a - 1 * centi
Error: object 'centi' not found
= snap

Any hints?
Do you think i should rename the convert function to 
float2si or something like that?
Perhaps someone needs a si2float converter in future...

Betatesters are welcome. After some more testing i want to upload the 
package to the R package collection.

kind regards,

-- 
Jonas Stein n...@jonasstein.de

__
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 package dev: how to export constant?

2012-01-18 Thread Jonas Stein
On 2012-01-18, William Dunlap wdun...@tibco.com wrote:
 Try adding
   LazyData: yes
 to the DESCRIPTION file.
 [3] https://github.com/jonasstein/sitools

Thank you. Now it works and I could add all SI prefixes.


-- 
Jonas Stein n...@jonasstein.de

__
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] howto test a package without installation

2012-01-17 Thread Jonas Stein
 Look at Hadley Wickham's devtools package.  It is designed with this
 sort of thing.  That said, it really is not too difficult to install
 as long as you have a working tool chain (which you will need to test
 it anyway).

I cound not find it with google and found no devtools on this page 
http://had.co.nz/
can you give more details please.


 R CMD INSTALL /tmp/sitools
 R
 require(sitools)

This seems not to be what i want:

$ R CMD INSTALL sitools
* installing to library ‘/usr/local/lib/R/site-library’
Error: ERROR: no permission to install to directory 
‘/usr/local/lib/R/site-library’

R tries to install something in my system. That may confuse my 
debian packagemanagement.

kind regards,

-- 
Jonas Stein n...@jonasstein.de

__
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] howto test a package without installation

2012-01-17 Thread Jonas Stein

 I don't believe you can. However, you need not install it into a system-wide 
 library directory... your personal library (e.g. 
 /home/jonas/R/x86_64-pc-linux-gnu-library/2.14) should be sufficient.

Finally i created a new testuser to install the library locally as you wrote.
It works. Thank you.
How can i get my R clean again afterwards to test the next version? 

kind regards,

-- 
Jonas Stein n...@jonasstein.de

__
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 package dev: how to export constant?

2012-01-17 Thread Jonas Stein
Hi,
i create two constants kilo and milli in [1]. These should be available
after loading 

library(sitools)

How should i export them and what have i done wrong?
(Other suggestions for improving the package are welcome too)

The ready to use .tar.gz and the source can be found on github [2,3]

kind regatds,

[1] https://github.com/jonasstein/sitools/blob/master/init.R
[2] https://github.com/jonasstein/sitools/downloads
[3] https://github.com/jonasstein/sitools

-- 
Jonas Stein n...@jonasstein.de

__
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] howto test a package without installation

2012-01-15 Thread Jonas Stein
Hi,

how can i play around with my first selfwritten package [*]
without to install it to my debian system?

I think of something like doing this:

/tmp/$ R
R version 2.11.1 (2010-05-31)
Copyright (C) 2010 The R Foundation for Statistical Computing
ISBN 3-900051-07-0

 library(/tmp/sitools)

3 * kilo
[1] 3000


[*] https://github.com/jonasstein/sitools

-- 
Jonas Stein n...@jonasstein.de

__
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] par.plot() for repeated measurements

2012-01-14 Thread Jonas Stein
 I am using the package gamlss in R to plot repeated measurements. The
 command I am using is par.plot(). It works great except one thing about the
 label of the axises. I tried to label both x and y axises using ylab and
 xlab options. But the plot only gives variable variables. The labels did not
 show up. Below is the code I used.  Any comments are appreciated! Thanks. 

 library(gamlss)
 enable2r=read.csv(D:\\lzg\\jointmodel\\enable2r.csv,header=T)
 enable2r$ID-factor(enable2r$ID)
 par.plot(factpal~timetodeath2,data=enable2r,sub=ID,ylim=c(45,184),ylab='FACIT-PAL',xlab='Time
 to death',color=FALSE,lwd=1)

i can not use your example, as i have no enable2r.csv, but perhaps
you have luck if you change 

xlab='Time to death'
to
xlab=Time to death

kind regards,

-- 
Jonas Stein n...@jonasstein.de
https://github.com/jonasstein/R-Reference-Card

__
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] find inflexion point of discrete value list with R

2012-01-13 Thread Jonas Stein
  d2y - diff(dy)
  which(dy==0)  ## critical values
  sign(s2y)[which(dy==0)]  ## test for max/min/saddle
  which(d2y==0)   ## inflection points
 
 I would think that testing for d2y==0 would be akin to the error in
 numeric analysis warned about in FAQ 7.31. Seems unlikely that in real
 data that there would always be three points in a row with equal
 differences at a true inflection and even then, many of the ones you
 did find satisfying that criterion would not be in fact inflection
 points. Wouldn't it be better to fit a spline and then do your testing
 on the spline approximation?
 
 Counter-example:
  x=1:10
 y=c(1,2,3,5,7,10,13,16,20,24)
  dy - diff(y)
  d2y - diff(dy)
 which(d2y==0)
 [1] 1 3 5 6 8
 
 And actually the original data was a pretty good counter-example as well.


   The original post wasn't entirely clear, but I thought the data were
 indeed integers and that the discrete-state version of
 min/max/inflection point was indeed what was wanted.  Yes, if the
 underlying variable is continuous you might want to use splinefun(),
 with its deriv= argument, and uniroot(), to find maxima and minima.
 Might be a little tricky in general, although with an interpolation
 spline between a finite set of points you can at least deal with it
 exhaustively.

my real data is not limited to integer. Do you know a ready to use code
example for this?

Would it be a good idea to create a function and make it public to the
community? And if yes as single .R file, or as a library?

kind regards,

-- 
Jonas Stein n...@jonasstein.de

__
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] Rpad.org down? Searching latest R-Reference card

2012-01-12 Thread Jonas Stein

 i'd like to update my R-Reference card and commit some edits,
 but i could not get the source from rpad.org 

R Reference Card is dead? No! Long live the R Reference Card. ;-)

Tom Short granted to the public domain 2004-11-07 and got permission to 
include material from Emmanuel Paradis (R for Beginners)
I have uploaded the source to
https://github.com/jonasstein/R-Reference-Card

It is my favourite R Reference Card and I am looking forward to recieve
your suggestion for improvement.

Is there a prominent place where i should push the compiled .PDF to?

Kind regards,

-- 
Jonas Stein n...@jonasstein.de

__
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] Rpad.org down? Searching latest R-Reference card

2012-01-10 Thread Jonas Stein
Hi,

i'd like to update my R-Reference card and commit some edits,
but i could not get the source from rpad.org 

Did it move?

kind regards,

-- 
Jonas Stein n...@jonasstein.de

__
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] automatic SI prefixes as ticklabels on axis

2012-01-05 Thread Jonas Stein
i want to plot values with frequency on a logarithmic x axis.
similar to this example that i found in the web:
http://www.usspeaker.com/jensen%20p15n-graph.gif

I would like to convert long numbers to si prefix notation 
like in the example

(20 to 200k, 3500 to 3.5 M)

Of course i could create labels by hand, but
i have many files so i need some automatic function.

Has anyone done that in R?

Kind regards and thank you for your help,

-- 
Jonas Stein n...@jonasstein.de

__
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] wish: enable joining this Mailinglist via Gmane

2012-01-05 Thread Jonas Stein
Hi,

if you are not member of this list, you can not post. 
That is fine so far.

This list is mirrored via Gmane as a nntp gateway.
It would be great if a new user could 
subscribe this Mailinglist as gmane.comp.lang.r.general

On reply to his first posting he will get a verification mail
(same thing like mailman does here 
https://stat.ethz.ch/mailman/listinfo/r-help

If he can reply he will be permanently accepted as member.

If you like this idea, could the responible person check 
the optionflag in gmane?

Kind regards,

-- 
Jonas Stein n...@jonasstein.de

__
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] automatic SI prefixes as ticklabels on axis

2012-01-05 Thread Jonas Stein
On 2012-01-05, Jonas Stein n...@jonasstein.de wrote:
 i want to plot values with frequency on a logarithmic x axis.
 similar to this example that i found in the web:
 http://www.usspeaker.com/jensen%20p15n-graph.gif

 I would like to convert long numbers to si prefix notation 
 like in the example

 (20 to 200k, 3500 to 3.5 M)

 Of course i could create labels by hand, but
 i have many files so i need some automatic function.

 Has anyone done that in R?

 Kind regards and thank you for your help,

my first try looks like this:
==

getSIstring - function(x){

  sistring - paste(x);
  
  prefixpairs - data.frame(c(1e24,1e21,1e18,1e15,1e12,1e9,1e6,1e3,1e0,
  1e-3,1e-6,1e-9,1e-12,1e-15,1e-18,1e-21,1e-24),
c(Y, Z, E, P, T, G, M, k,  ,
  m, u, n, p, f, a, z, y))
  
  colnames(prefixpairs) - c(factor, prefix)
  i=0
  repeat{i=i+1;
 if (x  prefixpairs$factor[i]) {
   sistring - paste(x/prefixpairs$factor[i], prefixpairs$prefix[i]); 
break;}
 if (i = length(prefixpairs$factor)) break}

   return(sistring)
}

==

 getSIstring(2e7)
[1] 20 M

How can i improve this function?
It would be nice if it could handle lists too like sin() can do
 sin(1:4)
[1]  0.8414710  0.9092974  0.1411200 -0.7568025

kind regards,

-- 
Jonas Stein n...@jonasstein.de

__
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] find inflexion point of discrete value list with R

2012-01-02 Thread Jonas Stein
i have a list of values like this

x y
1 3
2 2
3 3
4 4
5 5
6 4
7 3
8 2
9 3

and need the inflexion points (and all max and min).
Is there a nice way to get the local max, min and inflexion points?

kind regards,

-- 
Jonas Stein n...@jonasstein.de

__
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] position of first and last axis tick

2011-10-17 Thread Jonas Stein

 how can i set the position of the first and last tick to the
 borderline of a plot?

 The plot should look like this one made in Gnuplot [1].
 Gnu-R adds some space between the ticks and the end of plot.

 do you mean like this?

 plot(rnorm(25),rnorm(25), xaxs =i, yaxs=i, xlim=c(-2,2),  
 ylim=c(-2,2))

That is exactly what i have been looking for. Thank you.

 [1] 
 http://commons.wikimedia.org/wiki/File:Atmospheric_radiocarbon_1954-1993.svg



-- 
Jonas Stein n...@jonasstein.de

__
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] position of first and last axis tick

2011-10-16 Thread Jonas Stein
Hi,

how can i set the position of the first and last tick to the 
borderline of a plot?

The plot should look like this one made in Gnuplot [1].
Gnu-R adds some space between the ticks and the end of plot.

[1] http://commons.wikimedia.org/wiki/File:Atmospheric_radiocarbon_1954-1993.svg

kind regards,

-- 
Jonas Stein n...@jonasstein.de

__
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 with same font like in LaTeX

2011-03-02 Thread Jonas Stein
Hi,

i want to make my plots look uniform in LaTeX documents.

- usage of the same font on axes and in legend like LaTeX uses
  (for example Computer Modern)

- put real LaTeX formulas on the axes 

Have you any hints how i can achieve that?
I had no luck two years ago, but i want to try it again now.

kind regards,

-- 
Jonas Stein n...@jonasstein.de

__
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] Sweave: Howto write real TeX formula in plot

2009-05-12 Thread Jonas Stein
Thank you, Baptiste and Charlie.
I found some examples wich look great on:
http://www.texample.net/tikz/examples/

 
 Perhaps try the pgfSweave package on r-forge?
 http://r-forge.r-project.org/projects/pgfsweave/ 
 [..]
 accomplished using the java utility eps2pgf and requires the PGF/TiKZ
 package for LaTeX:
 http://sourceforge.net/projects/pgf/

I have installed pgf with apt-get install pgf. That worked fine, but
installing pgfSweave fails.

I did this:

,[ in R interpreter (running as root) ]
| 
| install.packages('pgfSweave',,'http://www.rforge.net/') 
| 
| Warning in install.packages(pgfSweave, , http://www.rforge.net/;) :
|   argument 'lib' is missing: using '/usr/local/lib/R/site-library'
| trying URL 'http://www.rforge.net/src/contrib/pgfSweave_0.7.1.tar.gz'
| Content type 'application/x-tar' length 1017992 bytes (994 Kb)
| opened URL
| ==
| downloaded 994 Kb
| 
| * Installing *source* package 'pgfSweave' ...
| ** R
| ** exec
| ** inst
| ** preparing package for lazy loading
| Loading required package: stashR
| Warning in library(pkg, character.only = TRUE, logical.return = TRUE, lib.loc 
= lib.loc) :
|   there is no package called 'stashR'
| Error: package 'stashR' could not be loaded
| Execution halted
| ERROR: lazy loading failed for package 'pgfSweave'
| ** Removing '/usr/local/lib/R/site-library/pgfSweave'
| 
| The downloaded packages are in
| /tmp/Rtmp6huu9t/downloaded_packages
| Warning messages:
| 1: In install.packages(pgfSweave, , http://www.rforge.net/;) :
|   dependencies ‘stashR’, ‘filehash’, ‘digest’, ‘cacheSweave’ are not available
| 2: In install.packages(pgfSweave, , http://www.rforge.net/;) :
|   installation of package 'pgfSweave' had non-zero exit status
|
`

what will i have to do now?

And could someone give me an example how to write a formula in a plot?
Like plot(... title=$\sigma^2 + \int x$)

Thank you very much,

-- 
Jonas Stein n...@jonasstein.de

__
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] how to calculace the Observational error of an variable (nls fit)

2009-05-08 Thread Jonas Stein
Hi,

ich have a List of measured valuepairs (w, AmpNorm) and a formula 
f(w, a, b) = AmpNorm

i used nls to find the two coefficiants a and b:

ctfit.nls - nls(AmpNorm ~ 1/(1 + (w * a - b /w)^2) ...)


R ctfit.nls returns
Nonlinear regression model
  model:  AmpNorm ~  1/(1 + (w * a - b /w)^2)
   data:  parent.frame() 
a b 
1.447e-05 9.386e+06 
 residual sum-of-squares: 0.005164

Number of iterations to convergence: 5 
Achieved convergence tolerance: 1.271e-06 


Now i want to find out the observational error. So i could write something
like

a = 1.4e-05 +/- 0.1e-05

or a = 1.4e-05 with 98% confidence

Thank you for reading so far and thank you for any help.


-- 
Jonas Stein n...@jonasstein.de

__
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] howto find x value where x=max(x)

2009-05-08 Thread Jonas Stein
Hi,

fp is a data frame like this

,[ fp ]
|Frequenz  AmpNorm
| 1  3322 0.0379490639
| 2  3061 0.0476033058
| 3  2833 0.0592954124
| 4  2242 0.1275510204
`

i want to find the Frequenz where AmpNorm is max.

I use this line as workaround:
PeakFreqHz = subset(fp, AmpNorm == max(AmpNorm))$Frequenz[1]

Is there something nicer?
And is there an easy way to do the same on predict()

Thank you and kind regards,

-- 
Jonas Stein n...@jonasstein.de

__
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] Sweave: Howto write real TeX formula in plot

2009-04-19 Thread Jonas Stein
Hi,

i use Sweave to put plots in my .tex Documents. (pdflatex)
Is there a nice solution for this:

a) get a real LaTeX formula in the plot area. 
I have only found very complicate solutions. Is there sth. like 
\formula{x^2 = \oint f} 

b) how can i format axis and legend to get exact the same font that is
used in the TeX-document? 

Thank you for any help. 

-- 
Jonas Stein n...@jonasstein.de

__
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] How to rotate axis labels? 2009

2009-03-26 Thread Jonas Stein
Hi,

while searching for a solution i found many solutions in the internet.
But the postings seemed to be many years old and the workaround was a
dirty hack like this:

http://cran.r-project.org/doc/FAQ/R-FAQ.html#How-can-I-create-rotated-axis-labels_003f

Now its the year 2009 and there might have been some improvement...
Does anyone know a nice and easy way to turn labels on the y axis in the
same direction as the x labels?

Thank you very much for reading and hints,

-- 
Jonas Stein n...@jonasstein.de

__
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] howto get significant digits for round()

2008-05-14 Thread Jonas Stein
i have a table like this of an value and its tolerance

length   delta-length
12.2232  0.4
123.422  0.034123
1234 12

i want to round the value to the significant digits in this way:

my-round(length,delta-length)

12.2   ,  0.4
123.42 ,  0.03
1234   ,  12

how can i do this with R? 

please CC to email,
thanks so far,

-- 
Jonas Stein [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] PC configuration you are using

2008-05-14 Thread Jonas Stein
 As I mentioned in the previous message we are developing solution for
 wholesale companies to analyze their sales transactions by associative
 rules. I would very much appreciated if the community could give us
 some hint of what is a typical PC configuration of a professional
 statist (processor, RAM, HDD...)?

It is debain linux on a 3.2 GHz AMD with 2 GB RAM and 400 GB HDD here.
Using Emacs (ESS)

-- 
Jonas Stein [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.


[R] howto import .xls and .ods

2008-05-01 Thread Jonas Stein
Hi,

i want to import data from .ods and .xls files in R on a linux system.
Seems it was a faq in the past, but i found only solutions for Windows.

Is there a handy solution for linux? The best would be something like

mytab -read.ods(...)

Any hints? Thanks a lot for reading so far,

-- 
Jonas Stein [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.


[R] read data into list of matrix

2008-04-14 Thread Jonas Stein
Hi 

i have a list of many files and want to load them into a list of tables, that
can be adressed with a variable 'i'.

something like 

files = c(0125um,2000um,2200um,2500um,2700um)

for (i in 1:5)  
{
fp[i] - read.table( files[i] )
}

but this does not work of course. 

Has anyone a good hint? 

Thank you,

-- 
Jonas Stein [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] read data into list of matrix

2008-04-14 Thread Jonas Stein
 i have a list of many files and want to load them into a list of tables,
 that
 can be adressed with a variable 'i'.


 fp - lapply(files, read.table, header = T)

Thank you that works fine.

But how can i access the data in column fp$foo now?

fp[1]$foo does not work.

ps: thank you all for the replies per mail and the list here.

-- 
Jonas Stein [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.


[R] How to include files in .R?

2008-04-04 Thread Jonas Stein
Hi,

may be its a very simple question, but i did not find any documentation
about a 'include' command or something like this.

I have to set many constants in my R-files and want to move all these to
one file, so that i can reuse it in all other R-files.

Something like 

include(~/R/myconstants.R)

kind regards,

-- 
Jonas Stein [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.


[R] howto find corresponding values in datasource?

2008-03-12 Thread Jonas Stein
Hi,


i am sure, that this is a noob-question, but i have searched for 
hours without any good result. 

I want to draw a vertical line through the maximum of the first derivation.

Here is a small example. 

--8-[mydata.csv]
HM
115
222
323
417
510
--8-[myquestion.R]--
mydata - read.table(mydata.csv, header=TRUE, sep=\t)

attach(mydata)
# make a smooth fit through the points and calculate the first derivation d/dx
myspl - smooth.spline(H, M, all.knots = FALSE, nknots = 10, spar=0.5) 
mydiff - predict(myspl, 0:max(H), deriv=1)


# find the maximum peak max(y)
y1=y2= max(mydiff$y)

# now i want to plot a line through the maximum of the derivation
# how can i get the x-coordinate?
# segments(x1,y1,x2,y2)

detach()
--8-

Thank you,

-- 
Jonas Stein

__
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] howto examine axis intercepts of hysteresis curve?

2008-02-07 Thread Jonas Stein
I have a dozen plots that looks similar to the linked one [1]

How can R calculate the intercepts with x-axis and y-axis in best way?
As there are many data files to process, the solution should not need 
a lot manual work per data file. 

Thanks a lot,

-- 
Jonas Stein [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] howto examine axis intercepts of hysteresis curve?

2008-02-07 Thread Jonas Stein
 I have a dozen plots that looks similar to the linked one [1]
 
 How can R calculate the intercepts with x-axis and y-axis in best way?
 As there are many data files to process, the solution should not need a
 lot manual work per data file.
 
 Thanks a lot,


[1] 
http://pl.physik.tu-berlin.de/groups/pg262/Protokolle/Hysterese/sv4084103.gif


-- 
Jonas Stein [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.


[R] R + LaTeX formula

2007-12-08 Thread Jonas Stein
Hi,

what is actually the best method to include R-plots into LaTeX documents?
At the moment i use 

postscript(myplot.eps, width = 12.0, height = 9.0, horizontal = FALSE, 
onefile = TRUE, paper = special,encoding = TeXtext.enc)
plot(foo,bar)
dev.off()  

But it is a bit unhandy to scale later and its difficult to get nice 
formula in the plots.

And how should i write formulas on the axis or at specific points? 
Has someone had some effort in exporting plots to pstricks or pictex?

kind regards and thank you for reading so far,


-- 
Jonas Stein [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.


[R] howto remove all variables (cleanup)

2007-11-25 Thread Jonas Stein
Hi,

as i am quite new to R i often play around with commands in R until my graph
looks nice. 

After testing things there are often lots of variables left. How can i reset
all vars in one command before i do the final plot?

At the moment i restart rkward (my editor) but thats a bit uncomfortable...

-- 
kind regards,

Jonas Stein [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.


[R] how to wait after plotting in BATCH mode?

2007-11-25 Thread Jonas Stein
when i plot with the following command on console:
$ R CMD BATCH cp_messung.R

in the R-script i wrote x11() in the beginning, so it draws a nice plot on
my screen.

But sadly it disappeares after a second or two. How can i make it to wait
until i press a key or something?

thank you.

-- 
kind regards,

Jonas Stein [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.


[R] looking for function like rollmean()

2007-11-23 Thread Jonas Stein
Hi,

i have some data, that has 1-5 % noise. 
I want to smooth this data without loosing rows.

rollmean() would be great, but it returns a vector of different size as the
initial vector.

-- 
kind regards,

Jonas Stein [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.