Re: [R] Still confused about classes

2011-04-28 Thread Joshua Wiley
Hi Russ, One tool that might help could be ?methods and ?showMethods For example: ## for S3 methods(class = "Date") ## for S4 showMethods(classes = "Date") regarding getting the actual year, I would use (though there may be better ways): format.Date(as.Date("2010-01-01"), format = "%Y") HTH,

[R] Still confused about classes

2011-04-28 Thread Russ Abbott
Hi, I'm still confused about how to find out what methods are defined for a given class. For example, I know that > today <- Sys.Date() will produce an object of type Date. But I'm not sure what I can do with Date objects or how I can find out. > ?Date refers me to the Date documentation pag

Re: [R] Change the text size of the title in a legend of a R plot.

2011-04-28 Thread Remko Duursma
Hi Victor, looking at the code for legend, it looks like the same 'cex' value is used for the text in the legend as the title. Here is a trick though: draw the legend twice, with different cex values, and omitting title or text: plot(1) legend("topright",c("a","b"),title=" ") legend("topright",

Re: [R] why doesn't ifelse work ?

2011-04-28 Thread Joshua Wiley
Hi Eric, On Thu, Apr 28, 2011 at 6:46 PM, eric wrote: > I have the following lines of code: > > ind <- rollapply(GSPC, 200, mean) > signal <- ifelse(diff(ind, 5) > 0 , 1 , -1) If you had looked at signal here, you would see that it is logical. > signal[is.na(signal)] <- 0 but this is not doing

Re: [R] Change the text size of the title in a legend of a R plot.

2011-04-28 Thread Steven McKinney
> -Original Message- > From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On > Behalf Of Victor Gabillon > Sent: April-28-11 8:22 PM > To: r-help@r-project.org > Subject: [R] Change the text size of the title in a legend of a R plot. > > Hello, > > Is it possible

Re: [R] How to define specially nested functions

2011-04-28 Thread Petr Savicky
On Thu, Apr 28, 2011 at 11:08:23PM -0400, Chee Chen wrote: > Dear All, > I would like to define a function: f(x,y,z) with three arguments x,y,z, such > that: given values for x,y, f(x,y,z) is still a function of z and that I am > still allowed to find the root in terms of z when x,y are given. >

Re: [R] how to generate a normal distribution with mean=1, min=0.2, max=0.8

2011-04-28 Thread Mike Miller
I just realized that I had misread what was wanted -- the code I wrote was for mean=0, sd=1, not for mean=1. So for mean=m, and sd=s, lower limit L and upper limit U, this approach will work: n <- 1000 m <- 1 s <- 1 L <- .2 U <- .8 p_L <- pnorm(L, mean=m, sd=s) p_U <- pnorm(U, mean=m, sd=s)

Re: [R] Problem loading quantreg

2011-04-28 Thread Prof Brian Ripley
Actually, you are trying to *install* it - on a Mac (without telling us) - from source (why? people usually install binary packages there) - asking on the wrong list (R-sig-mac is appropriate) - with an incomplete R installation. Go to the CRAN Mac OS X pages and read what they say about instal

Re: [R] why doesn't ifelse work ?

2011-04-28 Thread Dennis Murphy
Hi: On Thu, Apr 28, 2011 at 7:28 PM, eric wrote: > equire(quantmod) > require(PerformanceAnalytics) > rm(list=ls()) # Could you please not do this in the middle of a code chunk? # Anyone who copies/pastes this into his/her session will lose everything # (s)he had been doing. > getSymbols("^GSPC

Re: [R] How to define specially nested functions

2011-04-28 Thread Phil Spector
Here's one possibility: funmaker = function(x,y,z)function(z)x + y + (x^2 - z) uniroot(funmaker(1,3,z),c(0,10))$root [1] 5 uniroot(funmaker(5,2,z),c(30,40))$root [1] 32 (The third argument to the function doesn't really do anything.) - Phil Spector

Re: [R] Line numbers of scan(0

2011-04-28 Thread David Winsemius
On Apr 28, 2011, at 11:07 PM, Lisa wrote: I am trying to write a function to check unusual values in my datasets and correct them. As some R users suggested, I try to use readline() and scan() in my function. Suppose there are several unusual values in a dataset. I want to change the line

Re: [R] How to define specially nested functions

2011-04-28 Thread Jerome Asselin
On Thu, 2011-04-28 at 23:08 -0400, Chee Chen wrote: > Dear All, > I would like to define a function: f(x,y,z) with three arguments x,y,z, such > that: given values for x,y, f(x,y,z) is still a function of z and that I am > still allowed to find the root in terms of z when x,y are given. > For ex

Re: [R] why doesn't ifelse work ?

2011-04-28 Thread David Winsemius
On Apr 28, 2011, at 10:28 PM, eric wrote: equire(quantmod) require(PerformanceAnalytics) rm(list=ls()) getSymbols("^GSPC", src="yahoo", from="1990-01-01", to=Sys.Date()) GSPC <-na.omit(Ad(GSPC)) ind <- rollapply(GSPC, 200, mean) signal <- ifelse(diff(ind, 5) > 0 , 1 , -1) signal[is.na(signal)]

Re: [R] [R-SIG-Finance] Handling of irregular time series in lineChart

2011-04-28 Thread Brian G. Peterson
chartSeries and its cousins plot each period as one observation. all observations have equal time. It 'takes care of' irregular data by assuming that the rate of information is equal to the number of observations, which is a perfectly correct intuition and useful for many things. If you want ins

Re: [R] Line numbers of scan(0

2011-04-28 Thread Rolf Turner
On 29/04/11 09:40, Lisa wrote: Dear all, Does everyone know how to change the line numbers of scan()? For example, scan(n = 3) 1: 4 2: 6 3: 9 Read 3 items [1] 4 6 9 I just want to change the line numbers 1, 2, and 3 to, say a, b, and c that look like this: scan(n = 3) a: 4 b: 6 c:

[R] Change the text size of the title in a legend of a R plot.

2011-04-28 Thread Victor Gabillon
Hello, Is it possible to change the text size of the title in a legend of a R plot? I tried to directly change the title.cex argument but it seems not to work. Trying : Horizo <- c(1,2,6,10,20) legtext <- paste(Horizo,sep="") legend("topleft", legend=legtext,col=col,text.col=col,lwd=lwd, lty=l

Re: [R] Pause the execution of a function

2011-04-28 Thread Rolf Turner
On 29/04/11 08:56, Lisa wrote: Hi, Rolf, Thank you for your help. I am trying to use readline() and I have a question about the maximum length of prompt string. The R help on readline() says: “The prompt string will be truncated to a maximum allowed length, normally 256 chars (but can be change

Re: [R] Line numbers of scan(0

2011-04-28 Thread Lisa
I am trying to write a function to check unusual values in my datasets and correct them. As some R users suggested, I try to use readline() and scan() in my function. Suppose there are several unusual values in a dataset. I want to change the line numbers in scan() to something like: unusual value

Re: [R] why doesn't ifelse work ?

2011-04-28 Thread eric
from the console ... > table(signal) signal 01 1286 3885 note there is no -1 value. This is consistent with what I see if if plot(signal). When I issue that statement from the console, I see signal vary between 0 and 1.0 but it never goes to - 1 -- View this message in context: http

Re: [R] why doesn't ifelse work ?

2011-04-28 Thread eric
equire(quantmod) require(PerformanceAnalytics) rm(list=ls()) getSymbols("^GSPC", src="yahoo", from="1990-01-01", to=Sys.Date()) GSPC <-na.omit(Ad(GSPC)) ind <- rollapply(GSPC, 200, mean) signal <- ifelse(diff(ind, 5) > 0 , 1 , -1) signal[is.na(signal)] <- 0 -- View this message in context: http:/

Re: [R] gridBase Base Plot Positioning

2011-04-28 Thread Dario Strbenac
Thanks for this clarification. __ 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 cod

Re: [R] Merging two columns of a data frame

2011-04-28 Thread Scott Chamberlain
what about something like: dat <- data.frame(var1 = c("a","b"), var2 = c("c","d")) dat$var3 <- sapply(dat, function(x) paste(dat$var1,dat$var2,sep=""))[,1] Scott On Thursday, April 28, 2011 at 10:22 AM, Abraham Mathew wrote: I've kind of solved the issue. > > dat$Time <- paste(dat[,2], dat[,1]

[R] How to define specially nested functions

2011-04-28 Thread Chee Chen
Dear All, I would like to define a function: f(x,y,z) with three arguments x,y,z, such that: given values for x,y, f(x,y,z) is still a function of z and that I am still allowed to find the root in terms of z when x,y are given. For example: f(x,y,z) = x+y + (x^2-z), given x=1,y=3, f(1,3,z)= 1+

Re: [R] why doesn't ifelse work ?

2011-04-28 Thread Dennis Murphy
Hi: It seems to work for me...here's a reproducible example. set.seed(2053) date <- seq(as.Date('1990-01-01'), by = 'days', length = 5000) range(date) # [1] "1990-01-01" "2003-09-09" date <- sort(sample(date, 2000)) tdata <- data.frame(date = date, GSPC = rpois(2000, 1000)) library(zoo) tdata2 <

Re: [R] why doesn't ifelse work ?

2011-04-28 Thread Andrew Robinson
Hi Eric, tough to say. Please try to provide commented, minimal, self-contained, reproducible code. Cheers Andrew On Thu, Apr 28, 2011 at 06:46:16PM -0700, eric wrote: > I have the following lines of code: > > ind <- rollapply(GSPC, 200, mean) > signal <- ifelse(diff(ind, 5) > 0 , 1 , -1) > s

Re: [R] Yearly aggregates and matrices

2011-04-28 Thread Gabor Grothendieck
On Thu, Apr 28, 2011 at 10:13 PM, Gabor Grothendieck wrote: > On Thu, Apr 28, 2011 at 4:49 PM, mathijsdevaan > wrote: >> Thanks, but it did not really improve the speed. Why is it that when I change >> the layout of the matrix (which does not give the required results), the >> speed increases tr

[R] why doesn't ifelse work ?

2011-04-28 Thread eric
I have the following lines of code: ind <- rollapply(GSPC, 200, mean) signal <- ifelse(diff(ind, 5) > 0 , 1 , -1) signal[is.na(signal)] <- 0 I never get a value of -1 for signal even though I know diff(ind , 5) is less than zero frequently. It looks like when diff(ind , 5) is less than zero, sign

Re: [R] Yearly aggregates and matrices

2011-04-28 Thread Gabor Grothendieck
On Thu, Apr 28, 2011 at 4:49 PM, mathijsdevaan wrote: > Thanks, but it did not really improve the speed. Why is it that when I change > the layout of the matrix (which does not give the required results), the > speed increases tremendously? So: > > library(reshape2) > library(zoo) > z <- read.zoo(

Re: [R] Undefined columns selected

2011-04-28 Thread Andrew Robinson
Jennifer, it looks like some of the columns that you are selecting don't exist. What is the output of str(arc) before you run the code below? Andrew On Thu, Apr 28, 2011 at 04:49:41PM -0700, Jennifer Wessel wrote: > This is part of my program. I am getting an error, that I cannot figure > ou

Re: [R] Problem loading quantreg

2011-04-28 Thread Andrew Robinson
Hi Derek, I infer from the output that you're using a Mac. Generally including that kind of information is useful. Your computer lacks the requisite software to install the package. Make is saying that it can't find 'gfortran'. See this page for some more insight: http://r.research.att.com/

Re: [R] Line numbers of scan(0

2011-04-28 Thread David Winsemius
On Apr 28, 2011, at 5:40 PM, Lisa wrote: Dear all, Does everyone know how to change the line numbers of scan()? For example, scan(n = 3) 1: 4 2: 6 3: 9 Read 3 items [1] 4 6 9 I just want to change the line numbers 1, 2, and 3 to, say a, b, and c that look like this: scan(n = 3)

Re: [R] Problem loading quantreg

2011-04-28 Thread David Winsemius
On Apr 28, 2011, at 6:15 PM, derekverley wrote: Hi all, I'm trying to load the quantreg package but keep running into problems no matter which method I have tried. Does anybody know what this error (below) means in plain language and what I might do to get this installed. I have not h

Re: [R] Generating a best fit line for non linear data

2011-04-28 Thread Andrew Robinson
I think that you probably need to provide the x values to nls. Try, for example, fit <- nls(species ~ a *(1 - exp(-b*samples)),start = list(a = 27, b = .15)) I hope that this helps, Andrew On Thu, Apr 28, 2011 at 01:56:43PM -0700, BornSurvivor wrote: > I have the following data set, and I hav

Re: [R] Generating a best fit line for non linear data

2011-04-28 Thread Jorge Ivan Velez
Hi, Try > d <- data.frame(samples, species) > fit = nls(species ~ a *(1 - exp(-b*samples)), start = list(a = 27, b = .15), data = d) > summary(fit) Formula: species ~ a * (1 - exp(-b * samples)) Parameters: Estimate Std. Error t value Pr(>|t|) a 35.824723.02073 11.860 6.10e-10 *** b 0.0

[R] Undefined columns selected

2011-04-28 Thread Jennifer Wessel
This is part of my program. I am getting an error, that I cannot figure out, any help would very much appreciated, thanks. # subset variables arc <- arc[,c("SNAP", "code", "ncode", "var", "n_total")] Error in `[.data.frame`(arc, , c("SNAP", "code", "ncode", : undefined col

Re: [R] Kolmogorov-Smirnov test

2011-04-28 Thread m.marcinmichal
This test SnowsPenultimateNormalityTest() is great :) Best -- View this message in context: http://r.789695.n4.nabble.com/Kolmogorov-Smirnov-test-tp3479506p3482401.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org ma

Re: [R] fisher exact for > 2x2 table

2011-04-28 Thread viostorm
Thank you all very kindly for your help. -Rob Robert Schutt III, MD, MCS Resident - Department of Internal Medicine University of Virginia, Charlottesville, Virginia -- View this message in context: http://r.789695.n4.nabble.com/fisher-exact-for-2x2-table-tp

Re: [R] Kolmogorov-Smirnov test

2011-04-28 Thread m.marcinmichal
Hi, thanks for response. >> The Kolmogorov-Smirnov test is designed for distributions on continuous >> variable, not discrete like the >> poisson. That is why you are getting >> some of your warnings. I read in "Fitting distributions whith R" Vito Ricci page 19 that: "... Kolmogorov-Smirnov t

[R] Nomograms from rms' fastbw output objects

2011-04-28 Thread Rob James
There is both a technical and a theoretical element to my question... Should I be able to use the outputs which arise from the fastbw function as inputs to nomogram(). I seem to be failing at this, -- I obtain a subscript out of range error. That I can't do this may speak to technical failing

Re: [R] run r scripts (tinn) via command

2011-04-28 Thread camilo_abboud
¿How to run several commands with one script? Functions needed: SOURCE (script) + logical functions(if, while, for) + scan(parameter A) Im not going to put an example, but the thing is: 1) run the main script, which contains another SOURCE-funtion wich points to an other script. source(sour

[R] Line numbers of scan(0

2011-04-28 Thread Lisa
Dear all, Does everyone know how to change the line numbers of scan()? For example, > scan(n = 3) 1: 4 2: 6 3: 9 Read 3 items [1] 4 6 9 I just want to change the line numbers 1, 2, and 3 to, say a, b, and c that look like this: > scan(n = 3) a: 4 b: 6 c: 9 Read 3 items [1] 4 6 9 Any he

Re: [R] Pause the execution of a function

2011-04-28 Thread Lisa
Hi, Rolf, Thank you for your help. I am trying to use readline() and I have a question about the maximum length of prompt string. The R help on readline() says: “The prompt string will be truncated to a maximum allowed length, normally 256 chars (but can be changed in the source code).” I don’t

Re: [R] Yearly aggregates and matrices

2011-04-28 Thread mathijsdevaan
Thanks, but it did not really improve the speed. Why is it that when I change the layout of the matrix (which does not give the required results), the speed increases tremendously? So: library(reshape2) library(zoo) z <- read.zoo(DF, split = 3, index = 2, FUN = identity) # Split on 3 and index on

[R] Generating a best fit line for non linear data

2011-04-28 Thread BornSurvivor
I have the following data set, and I have to find the line of best fit using this equation, y = a*(1 - exp(-b*x)). samples = seq(1,20,by=1) species = c(5,8,9,9,11,11,12,15,17,19,20,20,21,23,23,25,25,27,27,27) plot(samples,species, main = "Accumulation Curve for Tree Species Richness", xlab = "Sam

[R] Problem loading quantreg

2011-04-28 Thread derekverley
Hi all, I'm trying to load the quantreg package but keep running into problems no matter which method I have tried. Does anybody know what this error (below) means in plain language and what I might do to get this installed. I have not had problems downloading/installing/running packages in the

Re: [R] how to generate a normal distribution with mean=1, min=0.2, max=0.8

2011-04-28 Thread Mike Miller
Good point. It would be absurdly inefficient if the upper and lower limits on the interval of interest were, say, 0.2 and 0.201 instead of 0.2 and 0.8. Here's what I think is probably the best general approach: Compute the CDF for the upper and lower limits of the interval and generate unifo

[R] Handling of irregular time series in lineChart

2011-04-28 Thread Robert A'gata
Hi, I realized that when I have irregular series to feed into lineChart, the interval of each point in the chart does not seem to take care of irregular time interval I specified in my input xts time series. But rather, lineChart seems to take each point as equal spaced time series. For example, I

Re: [R] Problem installing package "sp" in R 2.13.0

2011-04-28 Thread Andrew Robinson
Hi Arnaud, the error is telling you that you don't have the "make" command. This might be because you haven't installed the necessary software to compile R packages. I suggest that you check the FAQ for Macintosh to see how to do that. Best wishes Andrew On Thu, Apr 28, 2011 at 01:30:58PM +02

Re: [R] Variance

2011-04-28 Thread Dat Mai
Oh silly me--and I've been staring at that for a good hour. Thank you and I'll keep your advice in mind. On Thu, Apr 28, 2011 at 6:24 PM, Andrew Robinson < a.robin...@ms.unimelb.edu.au> wrote: > A couple of points here > > First, note that q doesn't increment in the code below. So, you're >

[R] using lme4 with three nested random effects

2011-04-28 Thread Benjamin Caldwell
Hi all, I'm trying to fit models for data with three levels of nested random effects: site/transect/plot. For example, modelincrBS<-glmer(l.ru.ba.incr~shigo.av+pre.f.crwn.length+bark.thick.bh+Date+slope.pos.num+dens.T+dbh+leaf.area+can.pos.num+(1|site/transect/plot), data=rws30.UL, family=gaussian

Re: [R] how to generate a normal distribution with mean=1, min=0.2, max=0.8

2011-04-28 Thread Carl Witthoft
That method (creating lots of samples and throwing most of them away) is usually frowned upon :-). Try this: (I haven't, so it may well have syntax errors) % n28<- dnorm(seq(.2,.8,by=.001),mean=1,sd=1) % x <- sample(seq(.2,.8,by=.001), size=500,replace=TRUE, prob=n28) And I guess in retrospe

Re: [R] Variance

2011-04-28 Thread Andrew Robinson
A couple of points here First, note that q doesn't increment in the code below. So, you're getting the same variance each time. Second, note that (t$Rec1==input3 & t$Rec2==input4) evaluates to F?T or 0/1, and it's not clear from your code if that is what you intend. Finally, it's much easi

[R] Variance

2011-04-28 Thread Dat Mai
I'm trying to find the variance of various outputs in a matrix: for(l in 2:vl){ for(o in 1:(l-1)){ # Make sure the inputs are for the matrix "m" input3=rownames(v)[o] input4=colnames(v)[l] r=t[(t$Rec1==input3 & t$Rec2==input4),output] if(length(r)==0){ r=t[(t$Rec1==i

Re: [R] fisher exact for > 2x2 table

2011-04-28 Thread Mike Miller
On Thu, 28 Apr 2011, viostorm wrote: I have read the help page, or at least ?fisher.exact I looked a bit on the Internet I guess it is applicable to > 2x2. I had spoken to a biostatistician here who is quite excellent and was adamant with me I could not do > 2x2. I found this: http://math

Re: [R] DLSODA error

2011-04-28 Thread Thomas Petzoldt
Kristian, your example is rather complex and somewhat time consuming even on fast computers, so it is not easy to track your problem down to its original reason. However, what is clear to me is that this is definitely *not* not a problem of deSolve and most likely even not of optim, it is j

Re: [R] Speed up code with for() loop

2011-04-28 Thread Jeremy Hetzel
Hans, You could parallelize it with the multicore package. The only other thing I can think of is to use calls to .Internal(). But be vigilant, as this might not be good advice. ?.Internal warns that only true R wizards should even consider using the function. First, an example with .Intern

Re: [R] fisher exact for > 2x2 table

2011-04-28 Thread Mike Miller
On Fri, 29 Apr 2011, Thomas Lumley wrote: On Fri, Apr 29, 2011 at 8:01 AM, Mike Miller wrote: On Thu, 28 Apr 2011, viostorm wrote: I'm using fisher.exact on a 4x2 table and it seems to work. Does anyone know exactly what is going on?  I thought fisher.exact is only for 2x2 tables. You

Re: [R] ROCR for combination of markers

2011-04-28 Thread Rasanga Ruwanthi
Thanks Eik. As you said both packages give the same result, except labelling of the x axis. --- On Thu, 28/4/11, Eik Vettorazzi wrote: From: Eik Vettorazzi Subject: Re: [R] ROCR for combination of markers To: "Rasanga Ruwanthi" Cc: "R Help" Date: Thursday, 28 April, 2011, 20:08 Hi Rasanga

Re: [R] subset without removing NAs

2011-04-28 Thread Benjamin Caldwell
Thanks, that worked. *Ben Caldwell* On Thu, Apr 28, 2011 at 2:02 PM, David Winsemius wrote: > > On Apr 28, 2011, at 3:53 PM, Benjamin Caldwell wrote: > > Hi folks, >> >> I'm dealing with a dataset with a lot of NAs, and want to use subset on >> the >> data without removing the NAs from the th

Re: [R] subset without removing NAs

2011-04-28 Thread David Winsemius
On Apr 28, 2011, at 3:53 PM, Benjamin Caldwell wrote: Hi folks, I'm dealing with a dataset with a lot of NAs, and want to use subset on the data without removing the NAs from the the dataframe; e.g. rws50 <- subset(rw.fire.RW,shigo.av<50) This removes instances with NA for the value in ad

Re: [R] fisher exact for > 2x2 table

2011-04-28 Thread David Winsemius
On Apr 28, 2011, at 4:23 PM, viostorm wrote: I have read the help page, or at least ?fisher.exact Then it should have been clear that more than 2x2 tables can be used. I looked a bit on the Internet I guess it is applicable to > 2x2. I had spoken to a biostatistician here who is quite

Re: [R] fisher exact for > 2x2 table

2011-04-28 Thread viostorm
I have read the help page, or at least ?fisher.exact I looked a bit on the Internet I guess it is applicable to > 2x2. I had spoken to a biostatistician here who is quite excellent and was adamant with me I could not do > 2x2. I found this: http://mathworld.wolfram.com/FishersExactTest.html D

Re: [R] Kolmogorov-Smirnov test

2011-04-28 Thread Greg Snow
A couple of things to consider: The Kolmogorov-Smirnov test is designed for distributions on continuous variable, not discrete like the poisson. That is why you are getting some of your warnings. With a sample size over 10,000 you will have power to detect differences that are not practically

Re: [R] Subscript out of Bounds

2011-04-28 Thread Dat Mai
Great! I got it. Thanks a bunch. On Thu, Apr 28, 2011 at 4:02 PM, Duncan Murdoch wrote: > On 28/04/2011 3:49 PM, Dat Mai wrote: > >> I currently have this code: >> >> for(j in 2:n){ >> for(i in 1:(j-1)){ >> >> # Make sure the inputs are for the matrix "m" >> input1=rownames(m)[i] >>

Re: [R] subset without removing NAs

2011-04-28 Thread Marc Schwartz
On Apr 28, 2011, at 3:21 PM, Jannis wrote: > On 04/28/2011 09:53 PM, Benjamin Caldwell wrote: >> rws50<- subset(rw.fire.RW,shigo.av<50) > > quick and dirty would be to replace all NAs with -9 (or similar), use > subset, and set all values ==-9 in the subset back to NA. There may be > mo

Re: [R] Retrieving call sequence leading to a plot / Zooming in maps

2011-04-28 Thread Greg Snow
You could always put the commands into a script or function, then instead of retyping everything just run the script or function. There is the zoomplot function in the TeachingDemos package which does what you are suggesting (but my quick test did not work with your map). You could use that as

Re: [R] subset without removing NAs

2011-04-28 Thread Jannis
On 04/28/2011 09:53 PM, Benjamin Caldwell wrote: rws50<- subset(rw.fire.RW,shigo.av<50) quick and dirty would be to replace all NAs with -9 (or similar), use subset, and set all values ==-9 in the subset back to NA. There may be more elegant solutions, though. Jannis _

Re: [R] Coding design with repeated measurements in the survey package

2011-04-28 Thread Thomas Lumley
On Fri, Apr 29, 2011 at 3:23 AM, ONKELINX, Thierry wrote: > Dear all, > > I'm working on a design with rotating panels. Each site is sampled every X > year. Have a look at the code below the get an idea of the design. In reality > the number of sites will be (much) higher. > > However I'm not su

Re: [R] fisher exact for > 2x2 table

2011-04-28 Thread Thomas Lumley
On Fri, Apr 29, 2011 at 8:01 AM, Mike Miller wrote: > On Thu, 28 Apr 2011, viostorm wrote: > >> I'm using fisher.exact on a 4x2 table and it seems to work. >> >> Does anyone know exactly what is going on?  I thought fisher.exact is only >> for 2x2 tables. > > > You were wrong.  I'm sure there's no

Re: [R] gridBase Base Plot Positioning

2011-04-28 Thread Paul Murrell
Hi On 28/04/2011 3:00 p.m., Dario Strbenac wrote: Hello, I'm trying to follow the documentation of how to use gridBase, and I've reached the minimal code example below as my best effort. Can someone explain how to keep the column of boxplots on the same page as the rectangles (even though I've

Re: [R] Subscript out of Bounds

2011-04-28 Thread Duncan Murdoch
On 28/04/2011 3:49 PM, Dat Mai wrote: I currently have this code: for(j in 2:n){ for(i in 1:(j-1)){ # Make sure the inputs are for the matrix "m" input1=rownames(m)[i] input2=colnames(m)[j] q=t[(t$Rec1==input1& t$Rec2==input2),output] if(length(q)==0){ q=t[

Re: [R] fisher exact for > 2x2 table

2011-04-28 Thread David Winsemius
On Apr 28, 2011, at 3:45 PM, viostorm wrote: I'm using fisher.exact on a 4x2 table and it seems to work. Does anyone know exactly what is going on? I thought fisher.exact is only for 2x2 tables. Have you read the help page? -- David Winsemius, MD West Hartford, CT ___

Re: [R] fisher exact for > 2x2 table

2011-04-28 Thread Mike Miller
On Thu, 28 Apr 2011, viostorm wrote: I'm using fisher.exact on a 4x2 table and it seems to work. Does anyone know exactly what is going on? I thought fisher.exact is only for 2x2 tables. You were wrong. I'm sure there's nothing wrong with the program. You will find that with bigger tabl

[R] subset without removing NAs

2011-04-28 Thread Benjamin Caldwell
Hi folks, I'm dealing with a dataset with a lot of NAs, and want to use subset on the data without removing the NAs from the the dataframe; e.g. rws50 <- subset(rw.fire.RW,shigo.av<50) This removes instances with NA for the value in addition to anything <50. Any suggestions much appreciated. *B

[R] Subscript out of Bounds

2011-04-28 Thread Dat Mai
I currently have this code: for(j in 2:n){ for(i in 1:(j-1)){ # Make sure the inputs are for the matrix "m" input1=rownames(m)[i] input2=colnames(m)[j] q=t[(t$Rec1==input1 & t$Rec2==input2),output] if(length(q)==0){ q=t[(t$Rec1==input2 & t$Rec2==input1),output] }

[R] fisher exact for > 2x2 table

2011-04-28 Thread viostorm
I'm using fisher.exact on a 4x2 table and it seems to work. Does anyone know exactly what is going on? I thought fisher.exact is only for 2x2 tables. Note: I can't use chi-squared because I have a couple of cells with 0 and < 5 observations. -- View this message in context: http://r.789695

Re: [R] Subsetting Data

2011-04-28 Thread David Winsemius
On Apr 28, 2011, at 3:38 PM, David Winsemius wrote: On Apr 28, 2011, at 3:13 PM, Abraham Mathew wrote: I'm using the subset() function in R. dat <- data.frame(one=c(6,7,8,9,10), Number=c(5,15,13,1,13)) subset(dat, Number >= 10) However, I want to find the number of all rows who meet the

Re: [R] Subsetting Data

2011-04-28 Thread David Winsemius
On Apr 28, 2011, at 3:13 PM, Abraham Mathew wrote: I'm using the subset() function in R. dat <- data.frame(one=c(6,7,8,9,10), Number=c(5,15,13,1,13)) subset(dat, Number >= 10) However, I want to find the number of all rows who meet the Number>=10 condition. I've done this in the past with s

Re: [R] Subsetting Data

2011-04-28 Thread Jonathan Daily
Try this: sum(dat$Number >= 10) On Thu, Apr 28, 2011 at 3:13 PM, Abraham Mathew wrote: > I'm using the subset() function in R. > > dat <- data.frame(one=c(6,7,8,9,10), Number=c(5,15,13,1,13)) > > subset(dat, Number >= 10) > > However, I want to find the number of all rows who meet the Number>=10

Re: [R] [BioC] arch=i386

2011-04-28 Thread Dan Tenenbaum
On Wed, Apr 27, 2011 at 4:46 AM, Stat Consult wrote: > Dear ALL > > I want to load "HTSanalyzeR", It 's necessary to load "igraph" package. > This time I see this error: > library(igraph) > >  library(HTSanalyzeR) > Loading required package: GSEABase > Loading required package: Biobase > Error: pa

Re: [R] density plot of simulated exponential distributed data

2011-04-28 Thread Juanjuan Chai
I tried logspline function using a lower bound 0 for my data, it works like a charm. When the I changed the xlim only positive part, the vertical line was also gone. That's exactly what I expected. Thanks. -JJ Greg Snow wrote: You might want to use the logspline package instead of the density

[R] Subsetting Data

2011-04-28 Thread Abraham Mathew
I'm using the subset() function in R. dat <- data.frame(one=c(6,7,8,9,10), Number=c(5,15,13,1,13)) subset(dat, Number >= 10) However, I want to find the number of all rows who meet the Number>=10 condition. I've done this in the past with something like colSums or rowSums or another similar fun

Re: [R] ctree and survival problem

2011-04-28 Thread moleps
Yup, thats the culprit. Thx. //M On 28. apr. 2011, at 18.36, Achim Zeileis wrote: > On Thu, 28 Apr 2011, moleps wrote: > >> sessionInfo yields the following: > > OK, the "Design" package causes the problem here. When you load the Design > package, it provides a new Surv() and related methods

[R] Retrieving call sequence leading to a plot / Zooming in maps

2011-04-28 Thread Francois Rousseu
Hello R users When I want to zoom in on a map or any plot in R, I usually use the locator function to reset the limit of the plot and do something like: library(maptools) library(mapdata) map('worldHires',ylim=c(40,55),xlim=c(-90,-60)) points(-71,47,col="red",pch=16) text(-73,49,"Hello")

Re: [R] how to generate a normal distribution with mean=1, min=0.2, max=0.8

2011-04-28 Thread Mao Jianfeng
Thanks a lot for all your replies. This may be a bad question. But, for me I was improved by asking this question. Thanks, Jian-Feng, 2011/4/28 David Winsemius > > On Apr 28, 2011, at 12:09 PM, Ravi Varadhan wrote: > > Surely you must be joking, Mr. Jianfeng. >> >> > Perhaps not joking and

Re: [R] ROCR for combination of markers

2011-04-28 Thread Eik Vettorazzi
Hi Rasanga, I think there is nothing wrong with that plot (you may compare both curves obtained by ROC from Epi and plot.roc from pROC). As usual, both functions plot (1-specificity) at the x-coordinate against sensitivity on y. Perhaps a bit confusing is the labelling of the latter function, it ha

Re: [R] Using help in Windows version of R with disabled browser [SOLVED]

2011-04-28 Thread Duncan Murdoch
On 28/04/2011 11:00 AM, cpoirier wrote: Dear Ranjan, I'm afraid the command "options(help_type = 'text')" will not work if R is closed and opened again as the 'help_type' argument is set to 'html' by default in Windows (same for me). That's a default, but you can change it when you install R i

Re: [R] Putting x-axis in opposite order

2011-04-28 Thread Jonathan Daily
Actually, it is plotting the points in the decreasing order. See: plot(xx) Are you looking to reverse the x axis? Perhaps you will find an answer in either ?par or ?axis. On Thu, Apr 28, 2011 at 2:09 PM, Bogaso Christofer wrote: > Hi all, please consider this plot: > > > > xx <- seq(4, 0.01, by

Re: [R] Putting x-axis in opposite order

2011-04-28 Thread Breheny, Patrick
Try this: plot(xx, yy, type="l", xlim=rev(range(xx))) ___ Patrick Breheny Assistant Professor Department of Biostatistics Department of Statistics University of Kentucky -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On B

[R] Putting x-axis in opposite order

2011-04-28 Thread Bogaso Christofer
Hi all, please consider this plot: xx <- seq(4, 0.01, by = -0.04) yy <- rnorm(xx) plot(xx, yy, type="l") Here you see my original 'xx' was in decreasing order, however R puts it in the increasing order. I understand that in any plot x and y axis grow is increasing order, however I am wond

[R] Speed up code with for() loop

2011-04-28 Thread hck
Hallo everybody, I'm wondering whether it might be possible to speed up the following code: Error<-rnorm(1000, mean=0, sd=0.05) estimate<-(log(1.1)-Error) DCF_korrigiert<-(1/(exp(1/(exp(0.5*(-estimate)^2/(0.05^2))*sqrt(2*pi/(0.05^2))*(1-pnorm(0,((-estimate)/(0.05^2)),sqrt(1/(0.05^2))-1)

Re: [R] how to generate a normal distribution with mean=1, min=0.2, max=0.8

2011-04-28 Thread David Winsemius
On Apr 28, 2011, at 12:09 PM, Ravi Varadhan wrote: Surely you must be joking, Mr. Jianfeng. Perhaps not joking and perhaps not with correct statistical specification. A truncated Normal could be simulated with: set.seed(567) x <- rnorm(n=5, m=1, sd=1) xtrunc <- x[x>=0.2 & x <=0.8] r

Re: [R] Merging two columns of a data frame

2011-04-28 Thread Abraham Mathew
I've kind of solved the issue. dat$Time <- paste(dat[,2], dat[,1], sep=" ") head(dat) dat[,c(1,2)] <- NA head(dat) > head(dat) Year Month Number Time 1 NA NA 0 Jan 2002 2 NA NA 0 Feb 2002 3 NA NA 0 March 2002 4 NA NA 1 April 2002 5 NA NA 0 May 2002 6 NA NA 0 June 2002 unfortunately, can I delete

Re: [R] Using help in Windows version of R with disabled browser [SOLVED]

2011-04-28 Thread cpoirier
Dear Ranjan, I'm afraid the command "options(help_type = 'text')" will not work if R is closed and opened again as the 'help_type' argument is set to 'html' by default in Windows (same for me). You should better modify the 'C:/Program Files/R/R-X.XX.X/etc/Rprofile.site' file with a text editor, a

[R] How to average outputs

2011-04-28 Thread Dat Mai
Hello, I am trying to create a matrix that generates an output from 2 inputs. The problem I have is that I'm assigning a large set of data to various categories (that are used for the matrix). This technically means that I will have multiple output values for each unique set of inputs--I want to a

[R] Merging two columns of a data frame

2011-04-28 Thread Abraham Mathew
Hi folks, I have a simple question that I just can't solve. I'm trying to merge two columns in my data frame. > sessionInfo() R version 2.13.0 (2011-04-13) Platform: i686-pc-linux-gnu (32-bit) > head(dat) Year Month Number 2002 Jan 0 2002 Feb 0 2002 March0 2002 April

Re: [R] ctree and survival problem

2011-04-28 Thread Achim Zeileis
On Thu, 28 Apr 2011, moleps wrote: sessionInfo yields the following: OK, the "Design" package causes the problem here. When you load the Design package, it provides a new Surv() and related methods. This clashes with the computations of ctree() based on Surv(). So it's better not to load bo

Re: [R] Help ave() function

2011-04-28 Thread David Winsemius
On Apr 28, 2011, at 12:30 PM, петрович wrote: Hello again. Following a great idea from Jim and Dennis, I began to use the function ave() in my big data. I proved to use this command in my data with FUN=max(x,na.rm=T), Try instead: look at the 3rd example of help(ave) and I received a

Re: [R] ctree and survival problem

2011-04-28 Thread moleps
sessionInfo yields the following: > sessionInfo() R version 2.11.1 (2010-05-31) x86_64-apple-darwin9.8.0 locale: [1] en_US.UTF-8/en_US.UTF-8/C/C/en_US.UTF-8/en_US.UTF-8 attached base packages: [1] stats4tcltk splines grid stats graphics grDevices utils datasets metho

[R] Help ave() function

2011-04-28 Thread петрович
Hello again. Following a great idea from Jim and Dennis, I began to use the function ave() in my big data. I proved to use this command in my data with FUN=max(x,na.rm=T), and I received a Warning that translated looks like Warning in max (x, na.rm = T): no arguments to max; returning -Inf Is th

  1   2   >