[R] Best way to organize this data for plotting

2011-02-17 Thread Andre Nathan
Hello

I have a number of data files which are outputs for each step of a
simulation. The data is organized like this:

dmindmax   coef
   5   6   0.490981
   3   8   0.098056
   5   6   0.425926
   6   6   0.517860
   2   4   0.527778

I would like to make a 3-d plot where one axis corresponds to (dmin,
dmax) pair, one axis is the simulation step and the other is the mean of
the coef column values that share the same (dmin, dmax).

What's the easiest way to do this? I guess my question could be
simplified to: what's the easiest way to get a list like

  (dmin1, dmax1) - mean(coef such that (dmin, dmax) = (dmin1, dmax1))
  (dmin2, dmax2) - mean(coef such that (dmin, dmax) = (dmin2, dmax2))
  ...
  (dminN, dmaxN) - mean(coef such that (dmin, dmax) = (dminN, dmaxN))

given a file like the one above?

Thanks,
Andre

__
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] contourplot help

2010-12-20 Thread Andre Nathan
Hello

I'm using the following call to create a contourplot:

library(lattice)
m - as.matrix(read.table(data.txt))

contourplot(m[,3] ~ m[,2] * -m[,1],
at = c(1e-6, 1e-5, 1e-4, 1e-3, 1e-2, 1e-1),
scales = list(x = list(log = 10,
   labels = c(1, 10, 100),
   at = c(1, 10, 100)),
  y = list(labels = c(14, 12, 10, 8,
  6, 4, 2)),
   at = c(-14, -12, -10, -8, -6, -4,
  -2)),
labels = c(expression(10^-6), expression(10^-5),
   expression(10^-4), expression(10^-3),
   expression(10^-2), expression(10^-1),
   expression(10^0)),
xlim = c(0.75, 10^2),
xlab = Out-degree, ylab = In-degree)


Which gives the the output in the file below

  http://ompldr.org/vNm4xag/contour.eps

As it can be seen, the level labels are not displayed nicely because
there's not enough room for them. Also, the 10^-1 label is not
displayed.

Is there a way for me to hardcode the position of each label? I tried
setting labels = F and then calling text() for each one, but that
doesn't work.

If that's not possible, one option would be to color each level line
differently and then add a legend. Is it possible to do that?

Finally, how can I remove the tick marks from the top and right axes?

Thanks,
Andre

__
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] Working with tables with missing levels

2009-07-27 Thread Andre Nathan
Hello

I'm trying to write a function to calculate the relative entropy between
two distributions. The data I have is in table format, for example:

 t1 - prop.table(table(c(0,0,2,4,4)))
 t2 - prop.table(table(c(0,2,2,2,3)))
 t1

  0   2   4 
0.4 0.2 0.4 
 t2

  0   2   3 
0.2 0.6 0.2

The relative entropy is given by

  H[P||Q] = sum(p * log2(p/q))

with the conventions that 0*log2(0/q) = 0 and p*log2(p/0) = Inf.

I'm not sure about what is the best way to achieve that. Is there a way
to test if a table has a value for a given level, so that I can detect
that, for example, t1 is missing levels 1 and 3 and t2 is missing levels
1 and 4 (is level the correct terminology here?)? Simply trying to
access t1[[1]], for example, gives a subscript out of bounds error.

Another option would be to expand the tables, so that, for example, t1
becomes

  0   1   2   3   4 
0.4 0.0 0.2 0.0 0.4

Is there a way to do that?

Thanks,
Andre

__
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] Working with tables with missing levels

2009-07-27 Thread Andre Nathan
On Mon, 2009-07-27 at 16:34 -0300, Henrique Dallazuanna wrote:
 Try this:
 
 t1 - prop.table(table(factor(c(0,0,2,4,4), levels = 0:4)))
 t2 - prop.table(table(factor(c(0,2,2,2,3), levels = 0:4)))

Is there a way to do this given an already existing table? The problem
is that I actually build the distributions as I read data from files,
something like

  distr - NULL
  for (file in files) {
x - as.matrix(read.table(file))
t - c(distr, table(x))
distr - tapply(t, names(t), sum)
  }
  distr - prop.table(distr)

So I only know the maximum level after the distributions are created.

Thanks,
Andre

__
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] Postcript font size

2009-06-11 Thread Andre Nathan
Hello

I'm doing a number of plots and in all of them I'm specifying the same
font size. However, comparing one plot to the other, they have fonts of
different sizes, so it appears some scaling is being done.

I tried using both postcript(pointsize = ...) and par(ps = ...), but the
results were the same.

Is there a way to specify a font size that is consistent among calls to
plot()?

Thanks,
Andre

__
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] Postcript font size

2009-06-11 Thread Andre Nathan
On Thu, 2009-06-11 at 19:09 -0300, Andre Nathan wrote:
 Is there a way to specify a font size that is consistent among calls to
 plot()?

To put it correctly: is there a way to specify a font size that is
consistent among calls to postcript()?

All the fonts in the same file have the same size, but comparing files,
even when par(ps = ...) or postcript(pointsize = ...) are specified the
same way, the fonts have different sizes.

Best regards,
Andre

__
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] Postcript font size

2009-06-11 Thread Andre Nathan
On Thu, 2009-06-11 at 23:48 +0100, ted.hard...@manchester.ac.uk wrote:
 How are you comparing?
 A: Looking into the PostScript code in the files, and identifying
the font-sizes where they are set in the code?

This. To get the size I wanted in both files, I had to use par(ps = 15)
in one of them, and par(ps = 18) in the other. Strangely, the generated
files had the following PS code:

  /ps 12 def /Font1 findfont 12 s

I don't know PostScript, but I assume this means pointsize = 12.

Best,
Andre

__
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] Axis label spanning multiple plots

2009-06-01 Thread Andre Nathan
Hello

On Wed, 2009-05-27 at 13:38 -0600, Greg Snow wrote:
 Create an outer margin (see ?par), then use mtext to put the title in the 
 outer margin.

Sorry for taking that long to reply...

I created an outer margin with

  par(oma = c (0, 2, 0, 0))

and then did

  par(mfrow = c(2, 1))
  plot(...)
  plot(...)
  mtext(title 1, side = 2, outer = T)

With that, the text title 1 appears to the left of the second plot,
and not to the left of both plots, centered between them, which is what
I was trying to do. Is there a way to accomplish that (without manual
text positioning, that is)?

Thanks,
Andre

__
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] Axis label spanning multiple plots

2009-05-27 Thread Andre Nathan
Hello

I need to plot 3 graphs in a single column; the top two plots have the
same title, and I would like it to be written only once, centered
horizontally and spanning the two plots. Something like


  t ++
||
  i ||
||
  t ++
  
  l ++
||
  e ||
||
  1 ++

  t ++
  i ||
  t ||
  l ||
  e ||
  2 ++

   x-title

Is there a parameter which allows me to do that automatically, or should
I use text() and position the title manually?

Thanks in advance,
Andre

__
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] Multiple plot margins

2009-05-13 Thread Andre Nathan
On Wed, 2009-05-13 at 11:22 +0200, Uwe Ligges wrote:
 If not, example:
 
 par(mfrow = c(2,3), mar = c(0,0,0,0), oma = c(5,5,0,0), xpd=NA)
 plot(1, xaxt=n, xlab=, ylab=A)
 plot(1, xaxt=n, yaxt=n, xlab=, ylab=)
 plot(1, xaxt=n, yaxt=n, xlab=, ylab=)
 plot(1, xlab=I, ylab=B)
 plot(1, xlab=II, ylab=, yaxt=n)
 plot(1, xlab=III, ylab=, yaxt=n)
 

Thank you. I don't know what I did wrong, but that worked.

Best regards,
Andre

__
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] Multiple plot margins

2009-05-12 Thread Andre Nathan
Hello

I'm plotting 6 graphs using mfrow = c(2, 3). In these plots, only
graphs in the first column have titles for the y axis, and only the ones
in the last row have titles for the x axis.

I'd like all plots to be of the same size, and I'm trying to keep them
as near each other as possible, but I'm having the following problem.

If I make a single call to par(mar = ...), to leave room on the left and
bottom for the axes titles, a lot of space will be wasted because not
all graphs need titles; however, if I make one call of par(mar = ...)
per plot, to have finer control of the margins, the first column and
last row plots will be smaller than the rest, because the titles use up
some of their space.

I thought that setting large enough values for oma would do what I
want, but it doesn't appear to work if mar is too small.

To illustrate better what I'm trying to do:

  l +-+ +-+ +-+
  a | | | | | |
  b | | | | | |
  e | | | | | |
  l +-+ +-+ +-+
  
  l +-+ +-+ +-+
  a | | | | | |
  b | | | | | |
  e | | | | | |
  l +-+ +-+ +-+
 label   label   label

where the margins between each plot should be narrow.

Should I just plot the graphs without axis titles and then use text() to
manually position them?

Thanks in advance,
Andre

__
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] Incrementally building histograms

2008-11-05 Thread Andre Nathan
Hello

I need to build a histogram from data (numbers in the [0,1] interval)
stored in a number of different files. The total amount of data is very
large, so I can't load everything to memory and then simply call hist().
Since what I actually need are the histogram counts, I'm currently doing
it like this:

breaks - seq(0, 1, by = 0.01)
files - list.files(pattern = some pattern)
counts - 0
for (file in files) {
  data - scan(file, quiet = T)
  h - hist(data, plot = F, breaks = breaks)
  counts - counts + h$counts
}
# and then work with `counts' here

Is there a more efficient and/or idiomatic way to do this?

Thanks,
Andre

__
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] Combining tables

2008-09-14 Thread Andre Nathan
Thanks Jim, it worked great!


On Sun, 2008-09-14 at 21:27 -0400, jim holtman wrote:
 try this:
 
  c(tx,ty)
 1 2 3 3 4
 3 2 1 4 1
  z - c(tx,ty)
  tapply(z, names(z), sum)
 1 2 3 4
 3 2 5 1
 

__
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] Combining tables

2008-09-14 Thread Andre Nathan
Hello

Say I have the following data, and it's distribution given by table():

   x - c(1, 1, 1, 2, 2, 3)
   tx - table(x)
   tx
  x
  1 2 3
  3 2 1

Now say I have new data,

   y - c(3, 3, 3, 3, 4)
   ty - table(y)
   ty
  y
  3 4
  4 1

Is there a way to combine tx and ty in such a way to give me the
distribution below?

  1 2 3 4
  3 2 5 1

Essentially what I'm looking for is something equivalent to
table(c(x,y)), but x and y are too large and I'd like to avoid the
concatenation.

Thanks in advance,
Andre

__
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 rpm for Mandriva 2008.1 ?

2008-09-13 Thread Andre Nathan
Hi Joanne

There is a package in Mandriva's repository, called R-base. You can
isntall it with urpmi R-base.

HTH,
Andre

On Sat, 2008-09-13 at 16:48 +0100, Joanne Demmler wrote:
 Are there any R rpm's for Mandriva 2008.1? I found a couple of dodgy 
 ones that wouldn't install so far (rpmfind.net).
 
 (Sorry that seems so far the only Linux distribution that recognizes my 
 hardware on my new laptop correctly. I'm more familiar to Fedora and 
 Suse so perhaps I'm just doing something wrong?)
 
 Joanne
 
 __
 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] Histograms without bars

2008-05-19 Thread Andre Nathan
Hello

I'd like to plot a histogram of some data composed of real numbers. The
bin width I'm using is ~ 0.01, which results in high values in the y
axis, so that the area under each bar corresponds to the probability of
the data in that range.

Is is possible to plot points whose y coordinate correspond to that
probability, instead of plotting the histogram bars? In other words,
instead of having a bar of width 0.01 and height, say, 80, I'd like to
have a single point at y = 0.8.

I know I could use the values returned from hist() and calculate that
manually, but maybe there's a better way to do that. I've been using
prop.table() to plot these histograms for integer numbers, but now I
need binning and I'm not sure what is the best way to proceed.

Thanks in advance,
Andre

__
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] Multiple plots question

2008-03-20 Thread Andre Nathan
Hello

(Sorry if this appears twice, had some mail problems...)

I have a number of different data sets, each loaded as a matrix. I'd
like to plot them in a way that the data in the first column of each
matrix is plotted on the same pair of axes.

What I'm doing now is to call plot() for the data on the first matrix,
then call points() for the other ones. However, the axes are set by R
according to the data passed to plot(), and sometimes the data passed to
points() has larger values on the x axis, and the plot ends up being
cut (the y axis is not a problem since they're all probabilities).

Is there a way to dynamically adapt the axes so that all data can be
seen? I know I could build a new matrix with the columns I want to plot
but each matrix has 1 million rows, so I figure this would be
inefficient.

Do I have to check beforehand which column has the largest value and
call plot() on it, and then points() on the others, or is there an
automatic way to do this?

Thanks in advance,
Andre

__
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] Multiple plots question

2008-03-19 Thread Andre Nathan
Hello

I have a number of different data sets, each loaded as a matrix. I'd
like to plot them in a way that the data in the first column of each
matrix is plotted on the same pair of axes.

What I'm doing now is to call plot() for the data on the first matrix,
then call points() for the other ones. However, the axes are set by R
according to the data passed to plot(), and sometimes the data passed to
points() has larger values on the x axis, and the plot ends up being
cut (the y axis is not a problem since they're all probabilities).

Is there a way to dynamically adapt the axes so that all data can be
seen? I know I could build a new matrix with the columns I want to plot
but each matrix has 1 million rows, so I figure this would be
inefficient.

Do I have to check beforehand which column has the largest value and
call plot() on it, and then points() on the others, or is there an
automatic way to do this?

Thanks in advance,
Andre

__
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] Raw histogram plots

2008-02-27 Thread Andre Nathan
On Wed, 2008-02-27 at 14:15 +1300, Peter Alspach wrote:
 If I understand you correctly, you could try a barplot() on the result
 of table().

Hmm, table() does the counting exactly the way I want, i.e., just
counting individual values. Is there a way to extract the counts vs. the
values from a table, so that I can pass them as the x and y arguments to
plot()?

Thanks,
Andre

__
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] Raw histogram plots

2008-02-27 Thread Andre Nathan
On Wed, 2008-02-27 at 08:48 -0500, Charilaos Skiadas wrote:
 x - table(rbinom(20,2,0.5))
 plot(names(x),x)
 
 should do it. You can also try just plot(x). Use prop.table on table  
 if you want the relative frequencies instead.

Yes, names is what I needed :) Thanks for the prop.table hint. I looked
everywhere but none of my searches hinted at table/table.prop. You guys'
help has been invaluable for me.

Thanks again,
Andre

__
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] Raw histogram plots

2008-02-26 Thread Andre Nathan
Hello

I need to plot a histogram, but insted of using bars, I'd like to plot
the data points. I've been doing it like this so far:

  h - hist(x, plot = F)
  plot(y = x$counts / sum(x$counts),
   x = x$breaks[2:length(x$breaks)],
   type = p, log = xy)

Sometimes I want to have a look at the raw data (avoiding any kind of
binning). When x only contains integers, it's easy to just use bins of
size 1 when generating h with breaks = seq(0, max(x)).

Is there any way to do something similar when x consists of fractional
data? What I'm doing is setting a small bin length (for example, breaks
= seq(0, 1, by = 1e-6), but there's still a chance that points will be
grouped in a single bin.

Is there a better way to do this kind of raw histogram plotting?

Thanks,
Andre

__
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] Raw histogram plots

2008-02-26 Thread Andre Nathan
I know about stem, but the data set has 1 million points, so it's not
very useful here. I want to avoid binning just to have an idea about the
shape of the distribution, before deciding how I'll bin it.

Andre

On Tue, 2008-02-26 at 16:20 -0600, roger koenker wrote:
 take a look at
 
   ?stem
 
 There is still a place for handtools in the age of integrated
 circuits.  Of course, avoiding binning isn't really desirable.
 
 url:www.econ.uiuc.edu/~rogerRoger Koenker
 email[EMAIL PROTECTED]Department of Economics
 vox: 217-333-4558University of Illinois
 fax:   217-244-6678Champaign, IL 61820
 
 
 On Feb 26, 2008, at 4:10 PM, Andre Nathan wrote:
 
  Hello
 
  I need to plot a histogram, but insted of using bars, I'd like to plot
  the data points. I've been doing it like this so far:
 
   h - hist(x, plot = F)
   plot(y = x$counts / sum(x$counts),
x = x$breaks[2:length(x$breaks)],
type = p, log = xy)
 
  Sometimes I want to have a look at the raw data (avoiding any kind  
  of
  binning). When x only contains integers, it's easy to just use bins of
  size 1 when generating h with breaks = seq(0, max(x)).
 
  Is there any way to do something similar when x consists of fractional
  data? What I'm doing is setting a small bin length (for example,  
  breaks
  = seq(0, 1, by = 1e-6), but there's still a chance that points will  
  be
  grouped in a single bin.
 
  Is there a better way to do this kind of raw histogram plotting?
 
  Thanks,
  Andre
 
  __
  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] A more idiomatic way to write this

2008-02-24 Thread Andre Nathan
Hello,

I have a vector of 1,000,000 numbers and another vector of 1,000
divisors. What I'd like to do is to divide the first 1,000 numbers of
the first vector by the first divisor, then the next 1,000 by the second
divisor and so on. I came up with this, but I was wondering if there is
a more idiomatic, R-like way to write it:

x - ...
divs - ...

for (i in seq(from = 1, to = 100, by = 1000)) {
  x[i:(i - 1 + 1000)] - x[i:(i - 1 + 1000)] / divs[i %/% 1000 + 1]
}

Any suggestions are welcome.

Thanks in advance,
Andre

__
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] A more idiomatic way to write this

2008-02-24 Thread Andre Nathan
On Mon, 2008-02-25 at 11:52 +1000, [EMAIL PROTECTED] wrote:
 x - x/rep(divs, each = 1000) 

Fantastic :)

Thanks Bill, Andrew and Rolf

Andre

__
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] Geometric progression

2008-02-24 Thread Andre Nathan
On Sun, 2008-02-24 at 23:26 -0300, Andre Nathan wrote:
  gp(1, 2, 10)
  [1]1248   16   32   64  128  256  512 1024
 

Actually,

[1]1248   16   32   64  128  256  512


Andre

__
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] Geometric progression

2008-02-24 Thread Andre Nathan
On Sun, 2008-02-24 at 21:39 -0500, Charilaos Skiadas wrote:
 2^(0:9)

I guess it's so simple that I'd never think of that...

Thanks!

Andre

__
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] Geometric progression

2008-02-24 Thread Andre Nathan
Hi

I'm pretty sure there's some built-in function to do the equivalent of
this, but I couldn't find one anywhere:

gp - function(init, mult, n)
{ 
  if (n == 1)
init
  else
pg(c(init, init[length(init)] * mult), mult, n-1)
}

 gp(1, 2, 10)
 [1]1248   16   32   64  128  256  512 1024

Any pointers?

Thanks,
Andre

__
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 join path with arguments

2008-02-19 Thread Andre Nathan


Hyunchul Kim wrote:
 How to format and join strings ?
 For example, like following short python examples.

 *
 name1 = 'sample-plot'
 filename = '%s.png' % name1

Two options are sprintf() and paste():

 name1 = sample-plot
 sprintf(%s.png, name1)
[1] sample-plot.png
 paste(name1, png, sep = .)
[1] sample-plot.png

HTH,
Andre

__
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] Questions about histograms

2008-02-10 Thread Andre Nathan
Hello

I'm doing some experiments with the various histogram functions and I
have a two questions about the prob option and binning.

First, here's a simple plot of my data using the default hist()
function:

 hist(data[,1], prob = TRUE, xlim = c(0, 35))

  http://go.sneakymustard.com/tmp/hist.jpg

My first question is regarding the resulting plot from hist.scott() and
hist.FD(), from the MASS package. I'm setting prob to TRUE in these
functions, but as it can be seen in the images below, the value for the
first bar of the histogram is well above 1.0. Shouldn't the total area
be 1.0 in the case of prob = TRUE?

 hist.scott(data[,1], prob = TRUE, xlim=c(0, 35))

  http://go.sneakymustard.com/tmp/scott.jpg

 hist.FD(data[,1], prob = TRUE, xlim=c(0, 35))

  http://go.sneakymustard.com/tmp/FD.jpg

Is there anything I can do to fix these plots?

My second question is related to binning. Is there a function or package
that allows one to use logarithmic binning in R, that is, create bins
such that the length of a bin is a multiple of the length of the one
before it?

Pointers to the appropriate docs are welcome, I've been searching for
this and couldn't find any info.

Best regards,
Andre

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