[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 re

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

[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

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", yla

[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 ++

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

Re: [R] Axis label spanning multiple plots

2009-06-01 Thread Andre Nathan
On Mon, 2009-06-01 at 22:24 +0200, baptiste auguie wrote: > you can use title() with the sub argument, > > title(sub="x label", outer=T) # you might want to play around with > line argument Can title() span two plots? I'm trying to use a single title for two plots, something like +

Re: [R] Axis label spanning multiple plots

2009-06-01 Thread Andre Nathan
; > layout(matrix(c(3,1,3,2), 2, 2, byrow = TRUE), width=c(1,5)) > > layout.show(3) > > plot(1:10) > > plot(1:10) > > plot.new() # necessary to draw something here > > text(0.5,0.5,"y label",srt=90) > > > > > HTH, > > > baptiste >

Re: [R] Axis label spanning multiple plots

2009-06-01 Thread Andre Nathan
On Mon, 2009-06-01 at 20:46 -0300, Andre Nathan wrote: > the x and y coordinates seem to always be relative the the axes of the > first call to plot(). Oops, no they aren't :) It was a mistake in the coordinates. They work exactly the way I wanted.

[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

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 sam

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

[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 =

[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 li

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

[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 o

[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 corre

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

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://s

[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 w

[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.j

Re: [R] Questions about histograms

2008-02-10 Thread Andre Nathan
7251 > Fax (if absolutely necessary): +61 7 3826 7304 > Mobile: +61 4 8819 4402 > Home Phone: +61 7 3286 7700 > mailto:[EMAIL PROTECTED] > http://www.cmis.csiro.au/bill.venables/ > > -Original Message- > From: [EMA

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

[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 idio

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 g

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 mailin

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 gui

[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 25

[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

Re: [R] "Raw" histogram plots

2008-02-26 Thread Andre Nathan
tment 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 b

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 ta

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

[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 l