[R] apply(ing) to sum subset of a vector

2006-03-27 Thread Fred J.
Dear R users I am trying to sum selective elements of a vector but my solution is not cutting it. Example: g - 1:5; from - 1:3; to - 3:5; from to 1 3 2 4 3 5 so I expect 3 sums from g 1+2+3 that is 1 to 3 of g 2+3+4 that is 2 to 4 of g 3+4+5 that is 3

[R] seq(2,5,-2) not an error but NULL

2006-03-27 Thread Christian Hoffmann
Hi, This may belong more to r-develop, but general discussion may be useful (for the how many-th time ?) seq(2,5,-2) seq(5,2,2) both result in Error in seq.default(2, 5, -2) : wrong sign in 'by' argument But often, if not always, mathematicians and programmers want a behaviour e.g. in for

Re: [R] apply(ing) to sum subset of a vector

2006-03-27 Thread jim holtman
create a matrix and then use apply: g - 1:5; from - 1:3; to - 3:5; index - cbind(from,to) apply(index, 1, function(x) sum(g[x[1]:x[2]])) [1] 6 9 12 On 3/27/06, Fred J. [EMAIL PROTECTED] wrote: Dear R users I am trying to sum selective elements of a vector but my solution is

Re: [R] load huge image

2006-03-27 Thread Henrik Bengtsson
On 3/27/06, Martin Maechler [EMAIL PROTECTED] wrote: Gottfried == Gottfried Gruber [EMAIL PROTECTED] on Sun, 26 Mar 2006 10:27:35 +0200 writes: Gottfried hello, i have run around 65000 regressions and Gottfried stored them in a list. then i stored the session Gottfried with

[R] Missing Argument in optim()

2006-03-27 Thread voodooochild
Hello everybody, i already searched the archieves, but i still don't know what is wrong in my implementation, mybe anybody coud give me some advice ll1-function(rho,theta,beta1,beta2,beta3,beta4,t,Szenariosw5,Testfaellew5,X1,X2) { n-length(t) t-cumsum(t) tn-t[length(t)]

[R] How to create a directoy with R

2006-03-27 Thread pau carre
Hello, I am trying to create directories with R. I would like R to create directories because it is platform independent. I tried using file() and searching in R Data Import/Export but I did not succeed. I think it must be some function since exists the unlink to remove directories (and files).

Re: [R] Missing Argument in optim()

2006-03-27 Thread Prof Brian Ripley
On Mon, 27 Mar 2006, [EMAIL PROTECTED] wrote: Hello everybody, i already searched the archieves, but i still don't know what is wrong in my implementation, mybe anybody coud give me some advice ll1-function(rho,theta,beta1,beta2,beta3,beta4,t,Szenariosw5,Testfaellew5,X1,X2) {

Re: [R] Clustering question \ dist(datmat)

2006-03-27 Thread Sean Davis
On 3/27/06 12:19 AM, kumar zaman [EMAIL PROTECTED] wrote: Dear Gabor and all ; I know this will work; but i already have a distance matrix calculated using my distance measure Dij = 0.5 * ( 1 - cos(theta_i - theta_j)), if i do hclust(as.dist(df)) then i am taking distance another

Re: [R] How to create a directoy with R

2006-03-27 Thread David Whiting
?dir.create On Mon, 2006-03-27 at 13:07 +0200, pau carre wrote: Hello, I am trying to create directories with R. I would like R to create directories because it is platform independent. I tried using file() and searching in R Data Import/Export but I did not succeed. I think it must be some

[R] A plotting question - how to get error bars?

2006-03-27 Thread toby
Dear R list, Can anyone help with a plotting question? I'm trying to display some data on a plot and I've almost got the format I need (see code below), but 2 things I can't get: 1. How to get Jan,Feb,Mar on the x=axis instead of 1:3? 2. How to get Ts on the end of my error bars like you have in

Re: [R] How to create a directoy with R

2006-03-27 Thread Sarah Goslee
I think you need to use system(mkdir) or whatever is appropriate for your OS. Making directories is a function of the OS, not of R. If you need to make a truly cross-platform solution, you might need to check within your code what OS is being used, and call the appropriate system statement. (I

Re: [R] seq(2,5,-2) not an error but NULL

2006-03-27 Thread Duncan Murdoch
On 3/27/2006 4:41 AM, Christian Hoffmann wrote: Hi, This may belong more to r-develop, but general discussion may be useful (for the how many-th time ?) seq(2,5,-2) seq(5,2,2) both result in Error in seq.default(2, 5, -2) : wrong sign in 'by' argument But often, if not always,

Re: [R] seq(2,5,-2) not an error but NULL

2006-03-27 Thread Liaw, Andy
You should be able to do it yourself; e.g., my.seq - function(...) if((to - from) * by 0) NULL else seq(...) and use that instead when you want that behavior. Andy From: Christian Hoffmann Hi, This may belong more to r-develop, but general discussion may be useful (for the how

Re: [R] seq(2,5,-2) not an error but NULL

2006-03-27 Thread Prof Brian Ripley
On Mon, 27 Mar 2006, Christian Hoffmann wrote: Hi, This may belong more to r-develop, but general discussion may be useful (for the how many-th time ?) The place for general discussion of changes to R is the R-devel list. There is almost no scope to change things like this, as there is so

Re: [R] How to create a directoy with R

2006-03-27 Thread Prof Brian Ripley
On Mon, 27 Mar 2006, pau carre wrote: Hello, I am trying to create directories with R. I would like R to create directories because it is platform independent. I tried using file() and searching in R Data Import/Export but I did not succeed. I think it must be some function since exists the

Re: [R] How to create a directoy with R

2006-03-27 Thread Liaw, Andy
help.search(directory) would have given you: R.home(base)Return the R Home Directory files(base) File and Directory Manipulation getwd(base) Get or Set Working Directory list.files(base)List the Files in a Directory/Folder unlink(base)

[R] glmmML

2006-03-27 Thread Szentirmai Istvan
Dear R Users, I'm looking for a similar function as step() or drop1() for glmmML models, but couldn't yet find any. I would appreciate if anyone could help me find such a function. Thanks, Istvan __ R-help@stat.math.ethz.ch mailing list

Re: [R] apply(ing) to sum subset of a vector

2006-03-27 Thread Jacques VESLOT
apply(cbind(from,to), 1, function(x) sum(g[x[1]:x[2]])) Fred J. a écrit : Dear R users I am trying to sum selective elements of a vector but my solution is not cutting it. Example: g - 1:5; from - 1:3; to - 3:5; from to 1 3 2 4 3 5 so I expect 3 sums from

Re: [R] Plotting with date

2006-03-27 Thread pierre clauss
thanks a lot ! it runs well now Pierre Clauss Gabor Grothendieck [EMAIL PROTECTED] a écrit : Make sure your x axis variable really is of class Date: class(x) plot(Sys.Date() + 0:99, 1:100) See ?str ?class ?as.Date, ?axis.Date and the help desk article in R News 4/1 on dates for more info.

Re: [R] A plotting question - how to get error bars?

2006-03-27 Thread Sean Davis
On 3/27/06 6:55 AM, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Dear R list, Can anyone help with a plotting question? I'm trying to display some data on a plot and I've almost got the format I need (see code below), but 2 things I can't get: 1. How to get Jan,Feb,Mar on the x=axis

[R] step() for glmmML

2006-03-27 Thread Szentirmai Istvan
Dear R Users, I'm looking for a similar function as step() or drop1() for glmmML models, but couldn't yet find any. I would appreciate if anyone could help me find such a function. Thanks, Istvan - Original Message - From: [EMAIL PROTECTED] To: r-help@stat.math.ethz.ch Sent: Monday,

Re: [R] How to create a directoy with R

2006-03-27 Thread Philippe Grosjean
See ?dir.create, and take care at the 'recursive' argument in case you have to create several subdir levels at once. Best, Philippe Grosjean Sarah Goslee wrote: I think you need to use system(mkdir) or whatever is appropriate for your OS. Making directories is a function of the OS, not of R.

Re: [R] seq(2,5,-2) not an error but NULL

2006-03-27 Thread Robin Hankin
Hi. seq() is a complex beast indeed. 'by' being the wrong sign is a special case of the behaviour seen in the following code snippets, the first of which is correctly rejected by seq(), the second of which should arguably return a three element complex vector. seq(from=1,to=3,by=1+1i) Error

Re: [R] seq(2,5,-2) not an error but NULL

2006-03-27 Thread Duncan Murdoch
On 3/27/2006 8:28 AM, Robin Hankin wrote: Hi. seq() is a complex beast indeed. 'by' being the wrong sign is a special case of the behaviour seen in the following code snippets, the first of which is correctly rejected by seq(), the second of which should arguably return a three element

Re: [R] seq(2,5,-2) not an error but NULL

2006-03-27 Thread Robin Hankin
Hi Duncan et al I don't think seq() could reasonably be expected to handle to and by arguments with complex values. Trying to divide the (to-from) difference by (by) to find how many steps to take would usually result in enough rounding error that the result wouldn't be real-

Re: [R] Date in dataframe manipulation

2006-03-27 Thread Dan Chan
Thank you Marc and Don's help, especially Marc's. Output- subset(FireDataAppling, select = c(STARTDATE, County, TOTAL, CAUSE)) Worked! STARTDATE IS a factor and I used the following command to get the -mm-dd format of the date Output$Date- as.POSIXct(Output$STARTDATE) Thank you! Daniel

Re: [R] glmmML

2006-03-27 Thread Prof Brian Ripley
yOn Mon, 27 Mar 2006, Szentirmai Istvan wrote: Dear R Users, I'm looking for a similar function as step() or drop1() for glmmML models, but couldn't yet find any. I would appreciate if anyone could help me find such a function. If you read the help for those functions, you will see that

[R] Differential Equations

2006-03-27 Thread Dominik Heinzmann
Dear R-community My ODE problems looks as follows: (1) dA/dt = u*A - v*B (2) dB/dt = v*B - u*A where u is a constant, and v=k*t (k=constant, t=time) Does anybody knows a good function/procedure of solving? Should one involve the equation (3) dv/dt = k? Thanks for your support. -- Dominik

Re: [R] A plotting question - how to get error bars?

2006-03-27 Thread Gabor Grothendieck
See plotCI in package gplots. For dates you can make use of the builtin vector month.abb plot(1:3, 11:13, xaxt = n) axis(1, 1:3, month.abb[1:3]) or use Date class: xvals - seq(as.Date(2006-01-01), length = 3, by = month) plot(xvals, 1:3) or with specific control over x axis: xvals -

[R] Graded Response Model Simulation (SAS code conversion)

2006-03-27 Thread Me
I have used R a lot in the past, but never for simulation. I have a code in SAS for the Graded Response Model (GRM), also known as Samejima's model. This code simulates an ordinal response, provided item characteristics (A=item discrimination, BB(G) are thresholds between various categorical

Re: [R] comparing AIC values of models with transformed, untransformed, and weighted variables

2006-03-27 Thread Prof Brian Ripley
Two comments: 1) The log-likelihood and hence AIC for a model for log X are not comparable with those of a model for X. You need to make an additive adjustment when you transform: it is quite easy to work out what from the definitions. 2) The AIC given by glm() for weighted models was wrong

Re: [R] Differential Equations

2006-03-27 Thread Peter Dalgaard
Dominik Heinzmann [EMAIL PROTECTED] writes: Dear R-community My ODE problems looks as follows: (1) dA/dt = u*A - v*B (2) dB/dt = v*B - u*A where u is a constant, and v=k*t (k=constant, t=time) Does anybody knows a good function/procedure of solving? Should one involve the equation

[R] useR! 2006 program online

2006-03-27 Thread Achim Zeileis
Dear useRs, we are happy to inform you that the program for the 2nd R user conference useR! 2006 is now available online from the conference Web page at http://www.R-project.org/useR-2006/program.html We would like to thank the useR community for submitting so many interesting abstracts about

Re: [R] X11, fonts, R-2.0.1, R-2.2.1 and R-devel

2006-03-27 Thread Prof Brian Ripley
The issue here is that you are using a UTF-8 locale (you sent this message in UTF-8), and you need appropriately encoded X11 fonts. R-2.0.1 did not support UTF-8, and so you got incorrect output for non-ASCII characters. It *is* an X11 installation/fontpath problem. On Thu, 23 Mar 2006,

[R] Arrays of functions or results of functions.

2006-03-27 Thread Gary Mallard
The general problem I am trying to solve is to determine if a series of subsets of data can be described with a single regression slope. This involves fitting the data to each subset, calculating a joint slope followed by F tests to show that the variances are equal the final slope is valid.

[R] Glm poisson

2006-03-27 Thread Guenther, Cameron
Hello, I am using the glm model with a poisson distribution. The model runs just fine but when I try to get the null deviance for the model of the null degrees of freedom I get the following errors: null.deviance(pAmeir_1) Error: couldn't find function null.deviance df.null(pAmeir_1) Error:

Re: [R] Differential Equations

2006-03-27 Thread Ravi Varadhan
Dominik, Adding (1) and (2) yields, A(t) + B(t) = constant = A(0) + B(0) = c So, plug in B = c - A in (1) and solve for A. This should be an easy solution. Hope this is helpful, Ravi. -Original Message- From: [EMAIL PROTECTED] [mailto:r-help- [EMAIL PROTECTED] On Behalf Of Peter

Re: [R] Arrays of functions or results of functions.

2006-03-27 Thread Gabor Grothendieck
Is your question how to run a regression with separate slopes and then with one slope and then to complare them? If that is it here is an example: # test data - ind is factor which defines the groups set.seed(1) y1 - 10 + 20 * seq(100) + rnorm(100) y2 - -200 + 35 * seq(100) + rnorm(100) yy -

Re: [R] Glm poisson

2006-03-27 Thread Francisco J. Zagmutt
Why are you trying to extract the values by calling a function with the name of the value? glm objects are stored as a list i.e. str(pAmeir_1) Hence, you can extract what you need by selecting the values on the list i.e. pAmeir_1$df.null pAmeir_1$null.deviance Cheers Francisco From:

Re: [R] Arrays of functions or results of functions.

2006-03-27 Thread Berton Gunter
If I understand you correctly, I would say that this is a standard analysis of covariance problem that you are approaching incorrectly. You should not be testing for equal variances, IMO. Instead, 1. Combine all your data into 3 columnsS x, y, and group= subset. 2. Model.1: y ~ x 3. Model.2: y ~

[R] reading in multi-dimensional data from .csv

2006-03-27 Thread Werner Wernersen
Hi, I would like to read in multi-dimensional data from a text file, i.e. tables with more than 2 dimensions. I have looked for a function which I can abuse for that but haven't found anything. I would appreciate it a lot if somebody gave me a hint if such functions already exist somewhere.

Re: [R] reading in multi-dimensional data from .csv

2006-03-27 Thread jim holtman
How is the data organized? You could 'linearize' the data (e.g., column order) and supply the dimensions of the data that you would apply after the data was read in. If you had three dimensions and you separated each 2D page with a blank line, you again could reconstruct the data. If you have

[R] graphing and scrolling

2006-03-27 Thread Fred J.
Dear R users graphing with plot(x) seams to work for a small length(x), when length(x) is too large it seams to clutter the display, a solution would be to display subsets of x at a time, yet a better way which I hope R supports is to place a sliding bar on the display window to control

[R] DSC 2007

2006-03-27 Thread Paul Murrell
Hi Following on from the Distributed Statistical Computing conferences in Vienna (1999, 2001, 2003) and the Directions in Statistical Computing conference in Seattle last year ... DSC 2007, a conference on systems and environments for statistical computing, will take place in Auckland, New

Re: [R] graphing and scrolling

2006-03-27 Thread Gregory Snow
Does the following (or some simple modification of it) do what you want?: library(tkrplot) y - rnorm(1, 10, 2) + 5*sin( (1:1)/1000 ) tt - tktoplevel() left - tclVar(1) oldleft - tclVar(1) right - tclVar(100) f1 - function(){ lleft - as.numeric(tclvalue(left)) rright -

[R] why does lmer not give p valuses for quasibinomial family?

2006-03-27 Thread Szentirmai Istvan
Dear All, I'm running a binomial model using the lmer() function, and I get p values for the parameter estimates only with family=binomial, but not with quasibinomial? Why is that so? I wanted to use quasibinomial family, because my data were overdispersed. Thanks, Istvan

[R] products and polynomials in formulae

2006-03-27 Thread stephenc
Hi I can do this: formula = as.factor(outcome) ~ . in glm and other model building functions. I think there is a way to get the product of the determinants (that is d1 * d2, d1 * d3, etc) and also another way to get all the polynomials (that is like poly(d1,2) would produce for a single

[R] error message

2006-03-27 Thread stephenc
Hi Does anyone know what this means: glm.model = glm(formula = as.factor(nextDay) ~ ., family=binomial, data=spi[1:1000,]) pred - predict(glm.model, spi[1001:1250,-9], type=response) Warning message: prediction from a rank-deficient fit may be misleading in: predict.lm(object, newdata,

[R] Help understanding behavior of apply vs sapply

2006-03-27 Thread Seth Falcon
Hi, I was surprised that apply and sapply don't return the same results in the example below. Can someone tell me what I'm missing? zls - function(x) character(0) m - matrix(0, nrow=2, ncol=2) apply(m, 1, zls) character(0) sapply(m, zls) [[1]] character(0) [[2]] character(0) [[3]]

[R] fixed effects

2006-03-27 Thread ivo welch
dear R wizards: X is factor with 20,000*20=800,000 observations of 20,000 factors. I.e., each factor has 20 observations. y is 800,000 normally distributed data points. I want to see how much R^2 the X factors can provide. Easy, right? lm ( y ~ X) and aov( y ~ X) Error: cannot allocate

Re: [R] Help understanding behavior of apply vs sapply

2006-03-27 Thread Liaw, Andy
I'll give it a shot: apply() is only a wrapper around a for loop through the requested dimension(s). In this case it would run zls() once for each row in m; i.e., twice. The `Value' section of apply() explains what it does if the function being applied returns vector of length 0. sapply() is

Re: [R] fixed effects

2006-03-27 Thread Liaw, Andy
I guess you meant X has 20,000 levels (and 40 observations each)? In that case lm() will attempt to create a design matrix that's 8e5 by 2e4, and that's unlikely to fit in the RAM. It is very easy to compute by hand. I'm using a smaller data size first to check the result against summary(lm()),

Re: [R] fixed effects

2006-03-27 Thread Liaw, Andy
Hmm... didn't read the whole post before I hit `send'... I think you basically will have to fit the model `by hand', which is not that hard, given the simple structure of the model(s). The formulae for the quantities of interests are quite straightforward and easy to code in R (similar to the

Re: [R] fixed effects

2006-03-27 Thread Spencer Graves
Have you tried the following: lme(y~1, random=~1|X, data=DF) where DF = a data.frame with columns y and X. The authoritative reference on library(nlme) is Pinheiro and Bates (2000) Mixed-Effects Models in S and S-Plus (Springer). I've learned a lot from Bates

[R] Having trouble with tsdiag function on a time series

2006-03-27 Thread Rafael Algara
Hello, I'm getting the following error message when I try to run 'tsdiag' on what seems to be a valid time series: tsdiag(small) returns: [Error in tsdiag(small) : no applicable method for tsdiag] where small is a little test series where I have isolated this problem (the original has

Re: [R] Default lag.max in ACF

2006-03-27 Thread Prof Brian Ripley
The default is taken from S-PLUS, so the reference is the S-PLUS manual. It is pretty similar to the recommendation of Brockwell Davis. On Mon, 27 Mar 2006, Spencer Graves wrote: I don't know why the default lag.max is 10*log10(N/m) for m series. The acf help page includes the

Re: [R] Having trouble with tsdiag function on a time series

2006-03-27 Thread Prof Brian Ripley
tsdiag is for diagnostic plots from time-series fits, not time series. On Tue, 28 Mar 2006, Rafael Algara wrote: Hello, I'm getting the following error message when I try to run 'tsdiag' on what seems to be a valid time series: tsdiag(small) returns: [Error in tsdiag(small) : no

Re: [R] fixed effects

2006-03-27 Thread Prof Brian Ripley
There is a very similar example worked through in section 7.2 of `S Programming'. On Mon, 27 Mar 2006, Liaw, Andy wrote: Hmm... didn't read the whole post before I hit `send'... I think you basically will have to fit the model `by hand', which is not that hard, given the simple structure of