Re: [R] conditional probability

2010-11-08 Thread Michael Bedward
Hello Jumlong, For Normal distribution see the help page for pnorm. For dealing with unknown (empirical) distributions, look at ecdf. Hope this helps Michael On 8 November 2010 16:29, Jumlong Vongprasert jumlong.u...@gmail.com wrote: Dear all          I have problem with calculate

[R] How to eliminate this for loop ?

2010-11-08 Thread PLucas
Hi, I would like to create a list recursively and eliminate my for loop : a-c() a[1] - 1; # initial value for(i in 2:N) { a[i]-a[i-1]*b - c[i-1] # b is a value, c is another vector } Is it possible ? Thanks -- View this message in context:

Re: [R] How to eliminate this for loop ?

2010-11-08 Thread Nick Sabbe
Whenever you use a recursion (that cannot be expressed otherwise), you always need a (for) loop. Apply and the like do not allow to use the intermediary results (i.e. a[i-1] to calculate a[i]). So: no, it cannot be avoided in your case, I guess. Nick Sabbe -- ping: nick.sa...@ugent.be link:

Re: [R] About 5.1 Arrays

2010-11-08 Thread Stephen Liu
Hi Joshua, .You can think of a 3d array kind of like a journal (I don't know if this is helpful, but I kind of like the analogy so...). Each page holds a two dimensional table, so I could tell you to look at row 4, column 3 on page 16. Nevertheless, at any given point, it is just a

Re: [R] unknown dimensions for loglm

2010-11-08 Thread P Ehlers
Jason Hwa wrote: Dear R-help community, I am working with multidimensional contingency tables and I am having trouble getting loglm to run on all dimensions without typing out each dimension. I have generated random data and provided output for the results I want below: d1.c1 - rnorm(20,

[R] how to remove border while saving R plots ?

2010-11-08 Thread vikrant
I am saving R graph as a jpeg image and the border is plotted defaultly when you open the image.How can I avoid the border? small R code is as follows :- volume- seq(100,10,-10) jpeg(filename = mygraph.jpg,width=366,height=284,units=px) {

[R] [R-pkgs] RGtk2 2.20.x

2010-11-08 Thread Michael Lawrence
This is to announce the release of the RGtk2 2.20.x series. RGtk2 is an interface between R and the GTK+ GUI toolkit and friends. The new release updates the bindings to support up to GTK+ 2.20 (and remains backwards compatible to 2.8). Previously, the interface supported only up to GTK+ 2.12,

[R] Create Matrix of 2 Dim from two vectors

2010-11-08 Thread abotaha
Hello, I have two data. x-c(1, 2, 3) y-c(4,5,6) How do i create matrix of 3 by 3 from this two, such that (1,4) (1,5) (1,6) (2,4) (2,5) (2,6) (3,4) (3,5) (3,6) I tried some thing like this: xy - as.data.frame(c(0,0,0), dim=c(3,3)) for(i in 1:3) for(j in 1:3)

Re: [R] Create Matrix of 2 Dim from two vectors

2010-11-08 Thread Vaiva P
Try x1-matrix(1,3,1)%x%x y1-y%x%matrix(1,3,1) Z-cbind(x1,y1) And later you need to move towards list and matrix On Mon, Nov 8, 2010 at 11:15 AM, abotaha yaseen0...@gmail.com wrote: Hello, I have two data. x-c(1, 2, 3) y-c(4,5,6) How do i create matrix of 3 by 3 from this two, such

Re: [R] How to eliminate this for loop ?

2010-11-08 Thread Dennis Murphy
Hi: ?Recall HTH, Dennis On Mon, Nov 8, 2010 at 1:25 AM, PLucas plucasplucasplu...@yopmail.comwrote: Hi, I would like to create a list recursively and eliminate my for loop : a-c() a[1] - 1; # initial value for(i in 2:N) { a[i]-a[i-1]*b - c[i-1] # b is a value, c is another vector

Re: [R] Create Matrix of 2 Dim from two vectors

2010-11-08 Thread Ivan Calandra
Hi, First, create a MATRIX of the correct size: xy - matrix(nrow=3, ncol=3) Then, in your for loop, you need to index each cell correctly, like this: xy[i,j] Finally, if you want to assign 1,4 to each cell, you need to paste x[i] and y[j] together, like this: xy[i,j]-paste(x[i],y[j], sep=,)

Re: [R] Create Matrix of 2 Dim from two vectors

2010-11-08 Thread Dennis Murphy
Hi: If you want the literal character strings, this works: x-c(1, 2, 3) y-c(4,5,6) outer(x, y, function(x, y) paste('(', x, ',', y, ')', sep = '') ) [,1][,2][,3] [1,] (1,4) (1,5) (1,6) [2,] (2,4) (2,5) (2,6) [3,] (3,4) (3,5) (3,6) However, I have the sense you want to use the

[R] nonparametric multiple comparisons

2010-11-08 Thread ellen pape
Hello everyone, I apologize if this question is out of the scope of this forum I have a small dataset with a dependent continuous variable which I want to compare amongst 3 levels of a factor, which I analyzed using a Kruskall-Wallis test. I am wondering which posthoc multiple comparison I

[R] Computing ergodic mean with CODA

2010-11-08 Thread Raquel Rangel de Meireles Guimarães
Hi all, I would like to compute ergodic mean using MCMC output from WinBUGS. I tried using CODA package, but it seems that it is not implemented yet. Could anyone help me to compute this? Kind regards, Raquel -- Raquel Rangel de Meireles Guimarães Doutoranda em Demografia

[R] Rserve alternative?

2010-11-08 Thread Ralf B
The Rserve documentation at http://rosuda.org/Rserve/doc.shtml#start states that even when making multiple connections to the Rserve, Windows won't separate workspaces physically and share environments, which will obviously cause problems and should therefore not be used. Are there any

Re: [R] Create Matrix of 2 Dim from two vectors

2010-11-08 Thread abotaha
Thanks a lot guys...all of your solution are useful, and good. once again thanks. -- View this message in context: http://r.789695.n4.nabble.com/Create-Matrix-of-2-Dim-from-two-vectors-tp3031718p3031797.html Sent from the R help mailing list archive at Nabble.com.

[R] finding the last day of the month

2010-11-08 Thread Benjamin Williams
Dear R Help, I am trying to get fields showing the last day of each month for a monthly closing project. In order to find the last day of the previous month, I subtract the number of days from the current month. For all months my code works; however, for October, my code doesn't work...it

Re: [R] finding the last day of the month

2010-11-08 Thread Ben Bolker
Benjamin Williams ben at bwmcct.com writes: I am trying to get fields showing the last day of each month for a monthly closing project. In order to find the last day of the previous month, I subtract the number of days from the current month. For all months my code works; however, for

Re: [R] Using changing names in loop in R

2010-11-08 Thread Tuatara
Josh, thanks so much for your detailed reply. This is exactly what I was looking for. -- View this message in context: http://r.789695.n4.nabble.com/Using-changing-names-in-loop-in-R-tp3030132p3031899.html Sent from the R help mailing list archive at Nabble.com.

[R] Visualization of histograms

2010-11-08 Thread Etienne Stockhausen
Dear r-user, I've wrote a small function to visualize the creation of a histogram. Therefore I create a vector with random values and let them plot in histograms. I better give a small example in R-Code: i=0 funVec=rnorm(1000) temp=hist(funVec,plot=FALSE)

Re: [R] finding the last day of the month

2010-11-08 Thread Gabor Grothendieck
On Mon, Nov 8, 2010 at 7:06 AM, Benjamin Williams b...@bwmcct.com wrote: Dear R Help, I am trying to get fields showing the last day of each month for a monthly closing project.  In order to find the last day of the previous month, I subtract the number of days from the current month. For all

Re: [R] help to sum up data frame

2010-11-08 Thread jim holtman
Nice thing about R is there is more than one way of doing something: x name ip Bsent Breceived 1 a 1 0.00 0.00 2 a 2 1.43 19.83 3 a 1 0.00 0.00 4 a 2 1.00 1.00 5 b 1 0.00 2.00 6 b 3 0.00 2.00 7 b 2 2.00 0.00 8 b

Re: [R] Rserve causes Perl error

2010-11-08 Thread jim holtman
Could be both. Do you have perl installed and is it on a path that R can find. On Mon, Nov 8, 2010 at 1:32 AM, Ralf B ralf.bie...@gmail.com wrote: Hi all, I tried to run Rserve: I installed it from CRAN using install.packages(Rserve) and tried to run it from the command line using: R

Re: [R] Rserve alternative?

2010-11-08 Thread Erich Neuwirth
You might want to look at statconnWS (available from rcom.univie.ac.at). Warning: This project is not open source. On 11/8/2010 12:40 PM, Ralf B wrote: The Rserve documentation at http://rosuda.org/Rserve/doc.shtml#start states that even when making multiple connections to the Rserve,

Re: [R] irregular grid

2010-11-08 Thread Ben Bolker
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 10-11-08 08:05 AM, wolfgang.pola...@gmail.com wrote: Thanks, what if a I want to add to the plot a second column of observations, like a type h line from the x,y plane? Wolfgang see segments3d. rgl is somewhat more

Re: [R] Rserve alternative?

2010-11-08 Thread Ajay Ohri
Alternatives to Windows platform are Linux. Try Ubuntu download from http://www.ubuntu.com/getubuntu/downloadmirrors if you are a Linux newbie to use Rserve Also see Rapache at http://rapache.net/ for using Apache Web Server and R together. The third R interface on web is Rweb see

[R] Visualization of histograms

2010-11-08 Thread Etienne Stockhausen
Dear r-user, I've wrote a small function to visualize the creation of a histogram. Therefore I create a vector with random values and let them plot in histograms. I better give a small example in R-Code: i=0 funVec=rnorm(1000) temp=hist(funVec,plot=FALSE)

Re: [R] Visualization of histograms

2010-11-08 Thread Ted Harding
On 08-Nov-10 12:56:26, Etienne Stockhausen wrote: Dear r-user, I've wrote a small function to visualize the creation of a histogram. Therefore I create a vector with random values and let them plot in histograms. I better give a small example in R-Code: i=0 funVec=rnorm(1000)

Re: [R] how to remove border while saving R plots ?

2010-11-08 Thread David Winsemius
On Nov 8, 2010, at 5:13 AM, vikrant wrote: I am saving R graph as a jpeg image and the border is plotted defaultly when you open the image.How can I avoid the border? small R code is as follows :- volume- seq(100,10,-10) jpeg(filename =

[R] Working with semantic data triplets

2010-11-08 Thread Leonard Mada
Dear R Help List, I have the following data set: id date factor eg. 1, date11, f1 1, date12, f2 1, date13, f3 [...] 2, date21, fi 2, date22, fj […] f1 – fn are various levels of a factor variable. Each ID may contain 1 to many entries. These represent basically semantic data (triplets). I

Re: [R] Computing ergodic mean with CODA

2010-11-08 Thread Giovanni Petris
Hola Raquel, As Ben already told you, ergodic means are pretty easy to compute from scratch. If you are lazy, or you want something more, like estimated standard errors, you can check out the functions ergMean and mcmcMean in package dlm. Best, Giovanni Petris On Sun, 2010-11-07 at 14:34 -0200,

Re: [R] conditional probability

2010-11-08 Thread Giovanni Petris
If you want a conditional distribution of x11 given x1,..x10, you need to make some assumptions about the joint distribution. It seems from the original post that items 1. and 2. refer to the marginal distribution of each observation. In general, it would help to specify the question a little

Re: [R] How to eliminate this for loop ?

2010-11-08 Thread David Winsemius
On Nov 8, 2010, at 4:30 AM, Nick Sabbe wrote: Whenever you use a recursion (that cannot be expressed otherwise), you always need a (for) loop. Not necessarily true ... assuming a is of length n: a[2:n] - a[1:(n-1))]*b + cc[1:(n-1)] # might work if b and n were numeric vectors of length 1

Re: [R] RMark error: only 0's may be mixed with negative subscripts

2010-11-08 Thread Jeff Laake
Umesh- You should contact the package maintainer or a SIG with a question about a package. RMark isn't posted on CRAN so it is unlikely most folks will even know about it. There is a support forum for MARK and RMark on the phidot site where you got them. I'll look at your data and problem

[R] try (nls stops unexpectedly because of chol2inv error

2010-11-08 Thread Monte Shaffer
Hi, I am running simulations that does multiple comparisons to control. For each simulation, I need to model 7 nls functions. I loop over 7 to do the nls using try if try fails, I break out of that loop, and go to next simulation. I get warnings on nls failures, but the simulation continues

Re: [R] help! kennard-stone algorithm in soil.spec packages does not work for my dataset!!!

2010-11-08 Thread bbslover
http://r.789695.n4.nabble.com/file/n3032045/rsv1.txt rsv1.txt I am very grateful to David's suggestion, here , I upload my dataset rsv1.txt, also the question, ks-ken.sto(rsv1,per=TRUE,per.n=0.3,va=FALSE,sav=FALSE) it does not work, all results are NULL, i do not known why it is ? hope,

[R] Maria Teresa Torres Muñoz/Gestion de Intangi bles/LineaDirecta está ausente de la oficina.

2010-11-08 Thread Maria Teresa Torres Muñoz
Estaré ausente de la oficina desde el 08/11/2010 y no volveré hasta el 16/11/2010. Responderé a su mensaje cuando regrese, si es urgente enviar mail a INNOVACION Visítenos en: www.lineadirecta.com Este mensaje y los documentos que, en su caso, lleve anexos, pueden contener información

[R] Add text to a stacked barplot

2010-11-08 Thread Ashraf Yassen
Hi All, I need some help in putting text in a stacked barplot. The barplot is filled with 5 levels and now I would like to put text to each level in the stacked barplot. However, it seems that the code that I am using is not placing the text at the correct hight (centered at each fill) in the

Re: [R] Add text to a stacked barplot

2010-11-08 Thread RICHARD M. HEIBERGER
Please post some data (fake data is fine) for stuffa. The example doesn't execute as is. Rich On Mon, Nov 8, 2010 at 10:27 AM, Ashraf Yassen ashraf.yas...@gmail.comwrote: Hi All, I need some help in putting text in a stacked barplot. The barplot is filled with 5 levels and now I would

[R] Sample size calculation for differences between two very small proportions (Fisher's exact test or others)?

2010-11-08 Thread Giulio Di Giovanni
Hi, I'm try to compute the minimum sample size needed to have at least an 80% of power, with alpha=0.05. The problem is that empirical proportions are really small: 0.00154 in one case and 0.00234. These are the estimated failure proportion of two medical treatments. Thomas and Conlon (1992)

[R] Add values of rlm coefficients to xyplot

2010-11-08 Thread PtitBleu
Hello, I have a simple xyplot with rlm lines. I would like to add the a and b coefficients (y=ax+b) of the rlm calculation in each panel. I know I can do it 'outside' the xyplot command but I would like to do all at the same time. I found some posts with the same question, but no answer. Is

[R] Error: could not find function extract in package raster

2010-11-08 Thread Monica Pisica
Hi, I would like to use the function extract from package raster and i get the following error: m01e - extract(marsh01, p) Error: could not find function extract marsh01 is a raster object and p is an intersectExtent object that is not null. The package is installed and loaded, i use a

Re: [R] Error: could not find function extract in package raster

2010-11-08 Thread Joshua Wiley
Hi Monica, Evidently, there is not an extract function in your search path (base R, loaded packages, etc.). Given that you are talking about a function from a package (rather than base R), it would probably help us more if you mentioned what version of raster you have installed. You can get this

Re: [R] Sample size calculation for differences between two very small proportions (Fisher's exact test or others)?

2010-11-08 Thread Mitchell Maltenfort
Not with R, but look for G*Power3, a free tool for power calc, includes FIsher's test. http://www.psycho.uni-duesseldorf.de/abteilungen/aap/gpower3 On Mon, Nov 8, 2010 at 10:52 AM, Giulio Di Giovanni perimessagg...@hotmail.com wrote: Hi, I'm try to compute the minimum sample size needed to

[R] How to plot a normal distribution curve and a shaded tail with alpha?

2010-11-08 Thread Wu Gong
I want to create a graph to express the idea of the area under a pdf curve, like http://r.789695.n4.nabble.com/file/n3032194/w7295e04.jpg Thank you for any help. - A R learner. -- View this message in context:

Re: [R] varclus in Hmisc vs SAS PROC VARCLUS

2010-11-08 Thread Darin A. England
My impression is that varclus from the Hmisc library is very convenient to use when you want to get an idea of the correlation among predictor variables in a regression setting, but if you want to perform cluster analysis in general, you may be better off using a different function in R, such as

Re: [R] Sample size calculation for differences between two very small proportions (Fisher's exact test or others)?

2010-11-08 Thread David Winsemius
On Nov 8, 2010, at 11:16 AM, Mitchell Maltenfort wrote: Not with R, Really? require(sos) findFn(power exact test) found 54 matches; retrieving 3 pages 2 3 These look on point: http://finzi.psych.upenn.edu/R/library/statmod/html/power.html

Re: [R] How to plot a normal distribution curve and a shaded tail with alpha?

2010-11-08 Thread David Winsemius
On Nov 8, 2010, at 11:18 AM, Wu Gong wrote: I want to create a graph to express the idea of the area under a pdf curve, like http://r.789695.n4.nabble.com/file/n3032194/w7295e04.jpg I think you could have titled this request: Yet Another Request to Do My Searching For Me:

[R] Centre of gravity of a mountain

2010-11-08 Thread Ab Hu
Hi all, I have a matrix of a mountain of form 21x21 and values in them are height (Z). Using the persp function I can view this mountain in 3D. Now, I am trying to find a measure to find the centre of gravity (maybe centroid?) of this mountain. Any idea what would be the best way to go? -- View

Re: [R] Sample size calculation for differences between two very small proportions (Fisher's exact test or others)?

2010-11-08 Thread Marc Schwartz
Hi, I don't have access to the article, but must presume that they are doing something radically different if you are only getting a total sample size of 20,000. Or is that 20,000 per arm? Using the G*Power app that Mitchell references below (which I have used previously, since they have a

Re: [R] Centre of gravity of a mountain

2010-11-08 Thread Peter Langfelder
Weighted mean of x and y coordinates (sorry for the pun :)), that is something like n = 21 y = matrix( c(1:n), n, n) x = matrix( c(1:n), n, n, byrow = TRUE) # These are the Center of mass coordinates: xCenter = sum(x * Z)/sum(Z); yCenter = sum(y * Z)/sum(Z); If you also need the z coordinate,

Re: [R] Error: could not find function extract in package raster

2010-11-08 Thread Monica Pisica
Hi Joshua, OK, my session info is this: R version 2.11.0 (2010-04-22) x86_64-pc-mingw32 locale: [1] LC_COLLATE=English_United States.1252 [2] LC_CTYPE=English_United States.1252 [3] LC_MONETARY=English_United States.1252 [4] LC_NUMERIC=C [5]

Re: [R] How to eliminate this for loop ?

2010-11-08 Thread Bert Gunter
1. The for loop is probably as or more efficient than recursion, especially for large n (comments/corrections on this claim from cogniscenti are welcome); 2. One can **Always** express a for loop recursively -- that is the nature of computer languages (comments/corrections again welcome). 3.

Re: [R] Sample size calculation for differences between two very small proportions (Fisher's exact test or others)?

2010-11-08 Thread Giulio Di Giovanni
Yep, it is 20.000 per arm, sorry. The reference it's about an application of the method, and I cannot download the paper with the main algorithm, so I don't know exactly how they did. Thanks everybody for the rich and interesting suggestions. Through free web software (PS, others) I

[R] Several lattice plots on one page

2010-11-08 Thread Marcus Drescher
Dear all, I am trying (!!!) to generate pdfs that have 8 plots on one page: df = data.frame( day = c(1,2,3,4), var1 = c(1,2,3,4), var2 = c(100,200,300,4000), var3 = c(10,20,300,4), var4 = c(10,2,3,4000), var5 = c(10,20,30,40),

Re: [R] Error: could not find function extract in package raster

2010-11-08 Thread Prof Brian Ripley
Users of R 2.11.1 (let alone 2.11.0) x64 Windows were asked to update in August, and we switched off the last remnants of support when 2.12.0 was released. Please do as the posting guide asked you to do before posting: update to R 2.12.0 (or 2.12.0 patched), and update all your packages.

Re: [R] How to plot a normal distribution curve and a shaded tail with alpha?

2010-11-08 Thread Greg Snow
Look at power.examp in the TeachingDemos package. If that plot is not good enough, you can steal the code and modify to your specifications. -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare greg.s...@imail.org 801.408.8111 -Original Message- From:

[R] Difference scores

2010-11-08 Thread statscurious
Hi all, I have a couple of questions that are general statistics questions rather than being R-specific. I'm interested in figuring out how to compute something like standard error for difference scores (in particular, differences scores of reaction times). Does anyone know if there is a

[R] How to rbind list of vectors with unequal vector lengths?

2010-11-08 Thread johannes rara
Hi, How to rbind these vectors from a list?: l - list(a = c(1, 2), b = c(1, 2, 3)) l $a [1] 1 2 $b [1] 1 2 3 do.call(rbind, l) [,1] [,2] [,3] a121 b123 Warning message: In function (..., deparse.level = 1) : number of columns of result is not a multiple of

Re: [R] How to rbind list of vectors with unequal vector lengths?

2010-11-08 Thread Henrique Dallazuanna
Try this: t(sapply(l, '[', 1:max(sapply(l, length On Mon, Nov 8, 2010 at 5:05 PM, johannes rara johannesr...@gmail.comwrote: Hi, How to rbind these vectors from a list?: l - list(a = c(1, 2), b = c(1, 2, 3)) l $a [1] 1 2 $b [1] 1 2 3 do.call(rbind, l) [,1] [,2] [,3] a

Re: [R] How to rbind list of vectors with unequal vector lengths?

2010-11-08 Thread Erik Iverson
What class of object / structure do you exactly want in the end? A matrix, a data.frame, a vector? johannes rara wrote: Hi, How to rbind these vectors from a list?: l - list(a = c(1, 2), b = c(1, 2, 3)) l $a [1] 1 2 $b [1] 1 2 3 do.call(rbind, l) [,1] [,2] [,3] a121 b

Re: [R] How to rbind list of vectors with unequal vector lengths?

2010-11-08 Thread johannes rara
Thanks, data.frame or matrix. -J 2010/11/8 Erik Iverson er...@ccbr.umn.edu: What class of object / structure do you exactly want in the end?  A matrix, a data.frame, a vector? johannes rara wrote: Hi, How to rbind these vectors from a list?: l - list(a = c(1, 2), b = c(1, 2, 3)) l

Re: [R] How to rbind list of vectors with unequal vector lengths?

2010-11-08 Thread Erik Iverson
So what do you want the matrix to look like, since the number of columns will be different between the two rows? johannes rara wrote: Thanks, data.frame or matrix. -J 2010/11/8 Erik Iverson er...@ccbr.umn.edu: What class of object / structure do you exactly want in the end? A matrix, a

Re: [R] Several lattice plots on one page

2010-11-08 Thread Dennis Murphy
Hi: Is this what you had in mind? library(reshape2) df - df[, -10] # last variable is superfluous dm - melt(df, id = 'day') head(dm) day variable value 1 1 var1 1 2 2 var1 2 3 3 var1 3 4 4 var1 4 5 1 var2 100 6 2 var2 200

Re: [R] How to rbind list of vectors with unequal vector lengths?

2010-11-08 Thread johannes rara
This is the ideal result (data.frame): result names X1 X2 X3 1 a 1 2 NA 2 b 1 2 3 2010/11/8 Erik Iverson er...@ccbr.umn.edu: So what do you want the matrix to look like, since the number of columns will be different between the two rows? johannes rara wrote: Thanks,

Re: [R] Sample size calculation for differences between two very small proportions (Fisher's exact test or others)?

2010-11-08 Thread David Winsemius
On Nov 8, 2010, at 1:00 PM, Giulio Di Giovanni wrote: Yep, it is 20.000 per arm, sorry. The reference it's about an application of the method, and I cannot download the paper with the main algorithm, so I don't know exactly how they did. Thanks everybody for the rich and interesting

Re: [R] How to rbind list of vectors with unequal vector lengths?

2010-11-08 Thread Erik Iverson
Then one solution is to use rbind.fill from the plyr package. johannes rara wrote: This is the ideal result (data.frame): result names X1 X2 X3 1 a 1 2 NA 2 b 1 2 3 2010/11/8 Erik Iverson er...@ccbr.umn.edu: So what do you want the matrix to look like, since the number of

Re: [R] How to rbind list of vectors with unequal vector lengths?

2010-11-08 Thread johannes rara
I have tried it, but it does not seem to work with vectors, only data.frames do.call(rbind.fill, l) NULL -J 2010/11/8 Erik Iverson er...@ccbr.umn.edu: Then one solution is to use rbind.fill from the plyr package. johannes rara wrote: This is the ideal result (data.frame): result  

[R] lookup in R - possible to avoid loops?

2010-11-08 Thread Dimitri Liakhovitski
Hello! Hope there is a nifty way to speed up my code by avoiding loops. My task is simple - analogous to the vlookup formula in Excel. Here is how I programmed it: # My example data frame: set.seed(1245) my.df-data.frame(names=rep(letters[1:3],3),value=round(rnorm(9,mean=20,sd=5),0))

Re: [R] lookup in R - possible to avoid loops?

2010-11-08 Thread Henrique Dallazuanna
Try this: merge(my.df, my.lookup) On Mon, Nov 8, 2010 at 5:43 PM, Dimitri Liakhovitski dimitri.liakhovit...@gmail.com wrote: Hello! Hope there is a nifty way to speed up my code by avoiding loops. My task is simple - analogous to the vlookup formula in Excel. Here is how I programmed it:

Re: [R] lookup in R - possible to avoid loops?

2010-11-08 Thread Phil Spector
Dimitri - While merge is most likely the fastest way to solve your problem, I just want to point out that you can use a named vector as a lookup table. For your example: categories = my.lookup$category names(categories) = my.lookup$names creates the lookup table, and my.df$category =

[R] A more efficient way to roll values in an irregular time series dataset?

2010-11-08 Thread Richard Vlasimsky
Does anyone recommend a more efficient way to roll values in a time series dataset? I merged a bunch of different time series datasets (10's of thousands of them) whose observation dates and sampling interval differ. Some time series observations are reported at the beginning of the month,

Re: [R] How to eliminate this for loop ?

2010-11-08 Thread Greg Snow
If you are willing to shift the c vector by 1 and have 1 (the initial value) as the start of c, then you can just do: cumsum( cc * b^( (n-1):0 ) ) / b^( (n-1):0 ) to compare: cc - c(1, rnorm(999) ) b - 0.5 n - length(cc) a1 - numeric(100) a1[1] - 1 system.time(for(i in 2:n ) { a1[i]

Re: [R] A more efficient way to roll values in an irregular time series dataset?

2010-11-08 Thread Dennis Murphy
Hi: Look into the zoo package and its rollapply() function. The package is designed to handle irregular and multiple series. HTH, Dennis On Mon, Nov 8, 2010 at 12:16 PM, Richard Vlasimsky richard.vlasim...@imidex.com wrote: Does anyone recommend a more efficient way to roll values in a time

Re: [R] A more efficient way to roll values in an irregular time series dataset?

2010-11-08 Thread Gabor Grothendieck
On Mon, Nov 8, 2010 at 3:16 PM, Richard Vlasimsky richard.vlasim...@imidex.com wrote: Does anyone recommend a more efficient way to roll values in a time series dataset? I merged a bunch of different time series datasets (10's of thousands of them) whose observation dates and sampling

Re: [R] How to plot a normal distribution curve and a shaded tail with alpha?

2010-11-08 Thread James Long
Here's an example of a PDF with the tails shaded: http://stackoverflow.com/q/3494593/37751 -JD On Mon, Nov 8, 2010 at 10:18 AM, Wu Gong w...@mtmail.mtsu.edu wrote: I want to create a graph to express the idea of the area under a pdf curve, like

Re: [R] How to plot a normal distribution curve and a shaded tail with alpha?

2010-11-08 Thread Joshua Wiley
I wrote this a bit ago, its far from perfect, but might give you ideas/serve your purpose. HTH, Josh plot.dist - function(alpha, from = -5, to = 5, n = 1000, filename = NULL, alternative = c(two.tailed, greater, lesser), distribution = c(normal, t, F, chisq, binomial), colour = black, fill =

[R] Random Sample

2010-11-08 Thread Xiaoxi Gao
Hello R users, Here is my question about generating random sample. How to set the random seed to recreate the same random numbers? For example, 10 random numbers is generated from N(0,1), then runif(10) is used.What if I want to get the same 10 random numbers when I run runif(10) again? Is it

Re: [R] lookup in R - possible to avoid loops?

2010-11-08 Thread Dimitri Liakhovitski
Thanks a lot - extremely heplful! While I'll definitely try to use merge in the future, in my situation I run into problems with memory (files are too large). However, Phil's suggestion is perfect for me - sped me up considerably! Thank you, again! Dimitri On Mon, Nov 8, 2010 at 2:51 PM, Phil

Re: [R] Random Sample

2010-11-08 Thread Jonathan P Daily
Use set.seed() -- Jonathan P. Daily Technician - USGS Leetown Science Center 11649 Leetown Road Kearneysville WV, 25430 (304) 724-4480 Is the room still a room when its empty? Does the room, the thing itself have purpose? Or do we, what's the word... imbue it.

Re: [R] Random Sample

2010-11-08 Thread Erik Iverson
?set.seed is what you're looking for Xiaoxi Gao wrote: Hello R users, Here is my question about generating random sample. How to set the random seed to recreate the same random numbers? For example, 10 random numbers is generated from N(0,1), then runif(10) is used.What if I want to get the

Re: [R] Random Sample

2010-11-08 Thread Jorge Ivan Velez
Hi Xiaoxi, Take a look at the following: set.seed(123) rnorm(10) [1] -0.56047565 -0.23017749 1.55870831 0.07050839 0.12928774 1.71506499 [7] 0.46091621 -1.26506123 -0.68685285 -0.44566197 rnorm(10) [1] 1.2240818 0.3598138 0.4007715 0.1106827 -0.5558411 1.7869131 0.4978505 [8]

[R] Help with getting ?match to not sort

2010-11-08 Thread Tal Galili
Hello all, I think I am missing something about the sorting parameter in the match command/ Here is an example: a1 - data.frame(name = c(D, B, C, A, A, C)) a2 - data.frame(name = c(A, B, C, D), num = 1:4) a1 a2 merge(a1, a2, sort = F, by.x = T) The result is: name num 1D 4 2B

Re: [R] How to plot a normal distribution curve and a shaded tail with alpha?

2010-11-08 Thread RICHARD M. HEIBERGER
You can use the normal.and.t.dist() function in the HH package, available from CRAN with install.packages(HH) This works on all platforms. There is menu access to the function through Rcmdr if you install install.packages(RcmdrPlugin.HH) If you are on Windows, you can additionally control that

[R] How to represent factor levels ordiellipses using different colors?

2010-11-08 Thread trinadh kumar potina
Dear Jari Oksanen, I am Trinadh Kumar, a student of Biotechnology from Texas Tech University. I have a question for you regarding constrained ordination graphs. I had previously plotted constrained ordination graphs using distance based redundancy analysis for species data on patients. The

Re: [R] Help with getting ?match to not sort

2010-11-08 Thread jim holtman
Missing: a closer reading of the help page -- Value A data frame. The rows are by default lexicographically sorted on the common columns, but for sort = FALSE are in an unspecified order. So sort = FALSE says unspecified. If you want the original order, then add a column to the dataframe with

[R] sapply

2010-11-08 Thread Dr. Alireza Zolfaghari
y=sapply(1:nrow(x), function(i) sapply(1:ncol(x), function(j) getrc(i, j))) Arvin Zolfaghari, Ph.D. Aon Benfield | Aon Benfield Analytics 55 Bishopsgate, London, EC2N 3BD, UK t: +44 20 7522 8241 | f: +44 20 7522 3846| M: +44 78 8940 6637 e: arvin.zolfagh...@aonbenfield.com | w:

Re: [R] Help with getting ?match to not sort

2010-11-08 Thread Phil Spector
Ted - If you want to retain the exact order of the rows of one of the merged matrices, I think you have to merge them by hand: cbind(a1,num=a2[match(a1$name,a2$name),'num']) name num 1D 4 2B 2 3C 3 4A 1 5A 1 6C 3

Re: [R] try (nls stops unexpectedly because of chol2inv error

2010-11-08 Thread Mike Marchywka
Date: Mon, 8 Nov 2010 06:18:49 -0800 From: monte.shaf...@gmail.com To: r-help@r-project.org Subject: [R] try (nls stops unexpectedly because of chol2inv error Hi, I am running simulations that does multiple comparisons to control. For each

[R] : unusual combinations of categorical data

2010-11-08 Thread Alan Chalk
Regarding unusual combinations of factors in categorical data. Are there any R packages that can be used to identify the outliers i.e. unusual combinations in categorical datasets ? Thanks. Notice of

Re: [R] : unusual combinations of categorical data

2010-11-08 Thread Joshua Wiley
Hi, On Mon, Nov 8, 2010 at 2:25 PM, Alan Chalk alan.ch...@gcc.rsagroup.com wrote: Regarding unusual combinations of factors in categorical data. where all variables are categorical? Are there any R packages that can be used to identify the outliers i.e. unusual combinations in categorical

[R] how do i plot this hist?

2010-11-08 Thread casperyc
Hi all, I have the following data in abc.dat === 50 0 1 0 0 55 114 0 1 60 786 0 3 6522 324 2 3 7058 1035 1 7 7530 2568 034 80 9 293615 162 8527 216946 365

Re: [R] Random Sample

2010-11-08 Thread Giovanni Petris
Here is an example of what I think the original poster wanted to achieve. rnorm(10) [1] -1.2165869 -0.4698460 -0.4209811 -1.4856052 0.3765774 -1.3822470 [7] 0.2818458 0.5500957 -1.1474455 -1.2221257 x - .Random.seed runif(10) [1] 0.5610780 0.5911841 0.5868183 0.3833801 0.7397059

Re: [R] Help with getting ?match to not sort

2010-11-08 Thread Peter Alspach
Tena koe Tal sort: logical. Should the results be sorted on the 'by' columns? Thus it is clear what sort=TRUE does, sort=FALSE does not do this. That doesn't mean it leaves the result in the same order as x (your a1), although many people (including me at first) assume it does. It is easy

Re: [R] how do i plot this hist?

2010-11-08 Thread jim holtman
try this: x - read.table('clipboard') x V1 V2 V3 V4 V5 1 50 01 0 0 2 55 1 14 0 1 3 60 7 86 0 3 4 65 22 324 2 3 5 70 58 1035 1 7 6 75 30 2568 0 34 7 80 9 2936 15 162 8 85 27 2169 46 365 9 90 80 1439 212 432 10 95 236 1670

Re: [R] how do i plot this hist?

2010-11-08 Thread jim holtman
Typing too fast; last line should be: barplot(t(x.m[, 2:5]), names.arg = x.m[,1], las=2) On Mon, Nov 8, 2010 at 5:42 PM, casperyc caspe...@hotmail.co.uk wrote: Hi all, I have the following data in abc.dat ===  50     0     1     0     0  55     1    14     0     1  

Re: [R] How to eliminate this for loop ?

2010-11-08 Thread Erich Neuwirth
Reduce(function(x1,x2)b*x1-x2,c,init=1,accum=TRUE) might be what you are looking for. This is not fully tested, so you should test it before you want to use it. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do

[R] How to detect if a vector is FP constant?

2010-11-08 Thread Hadley Wickham
Hi all, What's the equivalent to length(unique(x)) == 1 if want to ignore small floating point differences? Should I look at diff(range(x)) or sd(x) or something else? What cut off should I use? If it helps to be explicit, I'm interested in detecting when a vector is constant for the purpose

Re: [R] How to detect if a vector is FP constant?

2010-11-08 Thread Albyn Jones
how about all.equal(x,rep(mean(x),length(x))) or all.equal(x,rep(mean(x),length(x), tolerance=...) albyn On Mon, Nov 08, 2010 at 06:45:00PM -0600, Hadley Wickham wrote: Hi all, What's the equivalent to length(unique(x)) == 1 if want to ignore small floating point

[R] cannot find system Renviron Fatal error: unable to open the base package

2010-11-08 Thread jelas
hi people I need to make an application with Java and R. I installed the library rJava using the command R - install.packages (rJava), and i configured my $ R_HOME = / Library / Frameworks / R.framework / Resources. My SO is OSX. When I run an exemple in eclipse, it gives me the following

  1   2   >