[R] time difference

2010-04-21 Thread Carol Gao
Hi, Does anyone know how to take a time difference when the format of the time is as 13:22:23.586? I am trying to take the difference of time between stock transactions and need to keep the three decimal places for seconds. I have tried *diff(strptime(x, "%H:%M:%S.000))*, but apperantly that doesn

Re: [R] long output in R

2010-04-21 Thread Tal Galili
Not answering your question, But if you where to ask this regarding plots, the answer would be to use: par(ask = T) Best, Tal Contact Details:--- Contact me: tal.gal...@gmail.com | 972-52-7275845 Read me: www.talgalili.com (He

[R] Community help: creating Syntax-Highlighter-brush for R and WordPress.com

2010-04-21 Thread Tal Galili
Hello dear R community, *Background:* Since I see more and more R users who blog about R opening their blogs in WordPress.com, I contacted one of their workers asking if they could add Syntax highlight support for R. He replied to me saying that if there was a "Brush" for R, according to the forma

Re: [R] how to select the first observation only?

2010-04-21 Thread David Winsemius
On Apr 21, 2010, at 10:17 PM, gallon li wrote: Dear r-helpers, I have a very simple question. Suppose my data is like id=c(rep(1,2),rep(2,2)) b=c(2,3,4,5) m=cbind(id,b) m id b [1,] 1 2 [2,] 1 3 [3,] 2 4 [4,] 2 5 I wish to select the first observation for each id. That is, I want to

Re: [R] the bar width of barchart plot in lattice package

2010-04-21 Thread David Winsemius
On Apr 21, 2010, at 9:51 PM, zhenjiang xu wrote: I tried that. It seems the bar width is already maximized, although there is a lot of space between groups of bars. Thank you anyway. I apologize. It was reproducible code. I missed the "values" assignment. There is also a box.width argument

Re: [R] Maximum Likelihood Estimation in R

2010-04-21 Thread Thomas Stewart
Henrik- A coding solutions may be ... + (1/(2*stdev*stdev))*sum( ( y-(rev/12)- c(0,y[-n]) *exp(-lap/12) )^2 ) where n is the number of observations in y. Personally, I would use lm. Your model can be written as a linear function. Let x=c(0,y[-n]). Then run lm(y~x). The parameter estimat

Re: [R] how to select the first observation only?

2010-04-21 Thread William Dunlap
> -Original Message- > From: r-help-boun...@r-project.org > [mailto:r-help-boun...@r-project.org] On Behalf Of gallon li > Sent: Wednesday, April 21, 2010 7:18 PM > To: r-help > Subject: [R] how to select the first observation only? > > Dear r-helpers, > > I have a very simple question.

Re: [R] how to select the first observation only?

2010-04-21 Thread Daniel Malter
Gallon, your question looks very homeworky. People on this list are not likely to help you unless you can demonstrate own effort (even if it failed), and the list is not for homework questions in case it is one. Where exactly are you stuck? Daniel - cuncta stricte discussu

Re: [R] Huge data sets and RAM problems

2010-04-21 Thread kMan
You set records to NULL perhaps (delete, shift up). Perhaps your system is susceptible to butterflies on the other side of the world. Your code may have 'worked' on a small section of data, but the data used did not include all of the cases needed to fully test your code. So... test your code! sc

Re: [R] how to select the first observation only?

2010-04-21 Thread Thomas Stewart
Try the duplicated() function. As in m[!duplicated(id), ] -tgs On Wed, Apr 21, 2010 at 10:17 PM, gallon li wrote: > Dear r-helpers, > > I have a very simple question. Suppose my data is like > > id=c(rep(1,2),rep(2,2)) > b=c(2,3,4,5) > m=cbind(id,b) > > > m > id b > [1,] 1 2 > [2,] 1 3

[R] how to reorder of groups and specify ylim for each row in lattice barchart

2010-04-21 Thread zhenjiang xu
R experts, Is there anyway to reorder inside each group? In the following example, the bar of year 1932 is always plotted before the bar of year 1931, may I change the order inside each groups of bars? library(lattice) barchart(yield ~ variety | site,data=barley, groups = year, layout = c(1,6),au

Re: [R] Count matches of a sequence in a vector?

2010-04-21 Thread Christos Argyropoulos
Actually the memory foot print can be reduced by re-writting the function so that it makes use of the kronecker, rather than the outer function. Note that you do not get 2D map as before ... > countinstance2<-function(v,p) { + sapply(p,function(x,y) sum(kronecker(x,y,"==")),v) + } > v<-sample(

[R] how to select the first observation only?

2010-04-21 Thread gallon li
Dear r-helpers, I have a very simple question. Suppose my data is like id=c(rep(1,2),rep(2,2)) b=c(2,3,4,5) m=cbind(id,b) > m id b [1,] 1 2 [2,] 1 3 [3,] 2 4 [4,] 2 5 I wish to select the first observation for each id. That is, I want to quickly select two rows: id b 1 2 2 4 only. how

Re: [R] Results from clogit out of range?

2010-04-21 Thread Charles C. Berry
On Wed, 21 Apr 2010, Frank E Harrell Jr wrote: Thomas Lumley wrote: On Tue, 20 Apr 2010, Noah Silverman wrote: > I just read the help page for predict.coxph. > > It indicates that the risk score is just exp(lp) > > What I'm trying to find, and have seen with some other implementations >

Re: [R] the bar width of barchart plot in lattice package

2010-04-21 Thread zhenjiang xu
I tried that. It seems the bar width is already maximized, although there is a lot of space between groups of bars. Thank you anyway. On Tue, Apr 20, 2010 at 10:16 AM, David Winsemius wrote: > > On Apr 20, 2010, at 9:46 AM, zhenjiang xu wrote: > > Dear R users, >> >> I am trying to use the follo

Re: [R] ggplot and scale_x_date

2010-04-21 Thread hadley wickham
Hi Liam, Unfortunately this currently isn't supported. It's on my to do list: http://github.com/hadley/ggplot2/issues/issue/94 Hadley On Tue, Apr 20, 2010 at 7:59 PM, Liam Blanckenberg wrote: > Hi all, > > I have a question about setting arbitrary breaks/labels when using GGPLOT > and date/tim

[R] r-help

2010-04-21 Thread Daudi Jjingo
Hello, The *predict.mvr* function from the *pls* package has the syntax predict(mvr object, newdata, ncomp = array of integers, type = c("response", "scores"),...) When type is *scores*, predicted score values are returned for the components given in *ncomp*. What exactly do the score v

[R] predict error code

2010-04-21 Thread Brittany Hall
Hello,   I am trying to calculate predicted values derived from one dataset into a hypothetical dataset. I tried this line of code:   graphdata$fmgpredvalues <- predict(Acs250.3.4, graphdata)   and received the following error message:   ERROR: ZXend[1], drop = FALSE] %*%lmeFit$beta   I have made

[R] optimisation, pseudo maximum likehood and family exponential in R

2010-04-21 Thread Eric
Hello, By fixing log_vraisemblance, gradient and hessian function linked to a family density like exp(theta.xi), I'm looking for some efficients estimators by PML. So I've seen optim,nlminb, et maxLik procedure. But I 'm not sure that the heteroscedacity of my estimators are considered. Does an

Re: [R] Maximum Likelihood Estimation in R

2010-04-21 Thread Henkep
Thank you Thomas. (a) an embarrassing mistake by me. Of course it should be squared. Thank you for pointing that out. (b) Do you possibly have any suggestions on how to solve this issue? I presume that there is no reason in trying to create a lagged "vector" manually? Best Regards Henrik --

Re: [R] How to stamp my graphs with date and time

2010-04-21 Thread Jun Shen
David, Duncan, Thanks. I didn't realize the functions in "graphic" also work in "lattice". I thought they didn't work with each other. Jun On Wed, Apr 21, 2010 at 6:51 PM, Duncan Murdoch wrote: > On 21/04/2010 5:41 PM, Jun Shen wrote: > >> Dear all, >> >> How do stamp my graphs with date and t

[R] Jonckheere-Terpstra test using coin package?

2010-04-21 Thread Dale Steele
Is it possible to implement the Jonckheere-Terpstra test for ordered alternatives using the coin package: Conditional Inference Procedures in a Permutation Test Framework? I found jonckheere.test{clinfun}, but it uses a normal approximation when ties are present in the data. To make this concrete

Re: [R] User inputs

2010-04-21 Thread Don MacQueen
At 4:24 PM -0800 4/20/10, chrisli1223 wrote: Hi everyone, I have been searching for answers for the following questions but I don't have much success. The following questions may actually be quite simple. Any help would be greatly appreciated. (1) I have written a script which requires user inp

Re: [R] Help: formatting the result of 'cut' function

2010-04-21 Thread JCFaria
Dears Gabor and Jim, Many thanks for the answers: both work fine! Best, -- ///\\\///\\\///\\\///\\\///\\\///\\\///\\\///\\\ Jose Claudio Faria Estatistica - prof. Titular UESC/DCET/Brasil joseclaudio.fa...@gmail.com ///\\\///\\\///\\\///\\\///\\\///\\\///\\\///\\\ -- View this message in con

Re: [R] Creating artificial environmental landscape with spatial autocorrelation

2010-04-21 Thread Don MacQueen
See the RandomFields package. -Don At 4:56 PM -0700 4/21/10, Laura S. wrote: Dear all: Does anyone have any suggestions on how to make a spatially explicit landscape with spatial autocorrelation in R? In other words, a landscape where all cells have a spatial reference, and the environment

[R] Creating artificial environmental landscape with spatial autocorrelation

2010-04-21 Thread Laura S.
Dear all: Does anyone have any suggestions on how to make a spatially explicit landscape with spatial autocorrelation in R? In other words, a landscape where all cells have a spatial reference, and the environment values that are closer in space are more similar (positive spatial autocorrelatio

Re: [R] problem of R CMD check

2010-04-21 Thread Duncan Murdoch
On 21/04/2010 7:29 PM, rusers.sh wrote: Hi all, Today, i just installed the newest R version 2.10.1 and other necessary tools for building R package under windows,e.g. Rtools, perl. All are the newest version. After the correct configuration under windows, i use it to re-check my old packag

Re: [R] Sparseby Problems

2010-04-21 Thread Dennis Murphy
Hi: I'm a big fan of the reshape package, but this time I think that the doBy and plyr packages may better suit your needs. Since you mentioned wanting to get the min/mean/max of several variables simultaneously, I took out line54 and added some vectors of Gaussian(0, 1) random numbers for testing

Re: [R] How to stamp my graphs with date and time

2010-04-21 Thread Duncan Murdoch
On 21/04/2010 5:41 PM, Jun Shen wrote: Dear all, How do stamp my graphs with date and time somewhere like left corner of the graph (not the plotting area). I know date() and Sys.time(), but where to? Thanks. Use mtext() to put text onto a plot. For example, plot(1) mtext(Sys.time(), side=1, l

[R] problem of R CMD check

2010-04-21 Thread rusers.sh
Hi all, Today, i just installed the newest R version 2.10.1 and other necessary tools for building R package under windows,e.g. Rtools, perl. All are the newest version. After the correct configuration under windows, i use it to re-check my old package. I found the following prolem when check

Re: [R] Count matches of a sequence in a vector?

2010-04-21 Thread Christos Argyropoulos
It may be possible to give a solution without a single for loop. set.seed(1) v<-sample(1:10,size=1e6,replace=TRUE) p<-2:4 countinstance<-function(v,p) { res<-outer(v,p,FUN="=="); apply(res,2,sum) } > system.time(replicate(50,countinstance(v,p)))/50 user system elapsed 0.2146 0.

Re: [R] How to stamp my graphs with date and time

2010-04-21 Thread David Winsemius
On Apr 21, 2010, at 6:58 PM, David Winsemius wrote: Sarkar offers a worked example of taking user input regarding location for locating a grid viewport outside the plot area. http://lmdvr.r-forge.r-project.org/figures/figures.html See Figure 12.1 state <- data.frame(state.x77, state.region

Re: [R] How to stamp my graphs with date and time

2010-04-21 Thread David Winsemius
Sarkar offers a worked example of taking user input regarding location for locating a grid viewport outside the plot area. http://lmdvr.r-forge.r-project.org/figures/figures.html See Figure 12.1 state <- data.frame(state.x77, state.region) trellis.vpname("xlab", prefix = "plot1") trellis.vpna

Re: [R] ?rpart

2010-04-21 Thread Changbin Du
Yes, outcome is there. On Wed, Apr 21, 2010 at 3:47 PM, Steve Lianoglou < mailinglist.honey...@gmail.com> wrote: > Hi, > > On Wed, Apr 21, 2010 at 5:20 PM, Changbin Du wrote: > > HI, Dear R community, > > > > Last friday, I used the codes, it works, but today, it does not run? > > > > > >> fit.

Re: [R] Adding error bars to xyplot()

2010-04-21 Thread David Winsemius
On Apr 21, 2010, at 6:24 PM, Jon Zadra wrote: Hi, I want to add error bars to a plot generated with xyplot. I've tried both errbar() and plotCI(), but in both cases the points are not in the same place. It's as if the two functions are using a different frame of reference for the plott

Re: [R] ?rpart

2010-04-21 Thread Steve Lianoglou
Hi, On Wed, Apr 21, 2010 at 5:20 PM, Changbin Du wrote: > HI, Dear R community, > > Last friday, I used the codes, it works, but today, it does not run? > > >> fit.dimer <- rpart(outcome ~., method="class", data=p.df) > Error in `[.data.frame`(frame, predictors) : undefined columns selected > > >

Re: [R] Maximum Likelihood Estimation in R

2010-04-21 Thread Abhishek Pratap
Hey Henrik I dont do MLE myself but this recent blog might be helpful. http://www.johnmyleswhite.com/notebook/2010/04/21/doing-maximum-likelihood-estimation-by-hand-in-r/ -A On Wed, Apr 21, 2010 at 10:02 AM, Thomas Stewart wrote: > Two possible problems: > > (a) If you're working with a normal

Re: [R] How to stamp my graphs with date and time

2010-04-21 Thread Jun Shen
Thanks, David. mtext is for "graphics". Is there an equivalent function for "lattice"? Jun On Wed, Apr 21, 2010 at 4:44 PM, David Winsemius wrote: > > On Apr 21, 2010, at 5:41 PM, Jun Shen wrote: > > Dear all, >> >> How do stamp my graphs with date and time somewhere like left corner of >> the

[R] Adding error bars to xyplot()

2010-04-21 Thread Jon Zadra
Hi, I want to add error bars to a plot generated with xyplot. I've tried both errbar() and plotCI(), but in both cases the points are not in the same place. It's as if the two functions are using a different frame of reference for the plotting area. for example: means <- c(92.5, 92.25, 90.

[R] R courses ***May-June 2010*** R Programming Essentials and Advanced Techniques by XLSolutions in USA Cities

2010-04-21 Thread s...@xlsolutions-corp.com
Now available online is our May-June 2010 R Programming Essentials and Advanced courses schedule in San Francisco, Seattle, New York City and other USA cities http://www.xlsolutions-corp.com/Rcourses May - June 2010 *** R/S: Programming Essentials *** R Fundamentals and Programming Techniques **

[R] long output in R

2010-04-21 Thread Mingfeng Lin
Hello all: Is there a way to set up R such that, when you have a very long output from a command, it will pause when it has displayed one-screen of information and ask me to press a button to continue displaying? I happen to have one such command and the information I need is at the top of the out

Re: [R] How to stamp my graphs with date and time

2010-04-21 Thread David Winsemius
On Apr 21, 2010, at 5:41 PM, Jun Shen wrote: Dear all, How do stamp my graphs with date and time somewhere like left corner of the graph (not the plotting area). I know date() and Sys.time(), but where to? Thanks. ?mtext Jun [[alternative HTML version deleted]]

Re: [R] Count matches of a sequence in a vector?

2010-04-21 Thread David Winsemius
On Apr 21, 2010, at 5:19 PM, William Dunlap wrote: -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Jeff Brown Sent: Wednesday, April 21, 2010 8:08 AM To: r-help@r-project.org Subject: Re: [R] Count matches of a sequence in a vecto

[R] How to stamp my graphs with date and time

2010-04-21 Thread Jun Shen
Dear all, How do stamp my graphs with date and time somewhere like left corner of the graph (not the plotting area). I know date() and Sys.time(), but where to? Thanks. Jun [[alternative HTML version deleted]] __ R-help@r-project.org mailing l

Re: [R] ?rpart

2010-04-21 Thread Gabor Grothendieck
The Machine Learning Task view lists alternative packages you could try. On Wed, Apr 21, 2010 at 5:20 PM, Changbin Du wrote: > HI, Dear R community, > > Last friday, I used the codes, it works, but today, it does not run? > > >> fit.dimer <- rpart(outcome ~., method="class", data=p.df) > Error in

[R] ?rpart

2010-04-21 Thread Changbin Du
HI, Dear R community, Last friday, I used the codes, it works, but today, it does not run? > fit.dimer <- rpart(outcome ~., method="class", data=p.df) Error in `[.data.frame`(frame, predictors) : undefined columns selected DOEs anyone have comments or suggestions? Thanks in advance! -- S

Re: [R] Count matches of a sequence in a vector?

2010-04-21 Thread William Dunlap
> -Original Message- > From: r-help-boun...@r-project.org > [mailto:r-help-boun...@r-project.org] On Behalf Of Jeff Brown > Sent: Wednesday, April 21, 2010 8:08 AM > To: r-help@r-project.org > Subject: Re: [R] Count matches of a sequence in a vector? > > > This sort of calculation can't

Re: [R] Count matches of a sequence in a vector?

2010-04-21 Thread David Winsemius
On Apr 21, 2010, at 11:07 AM, Jeff Brown wrote: At April 21, 2010 10:16:10 AM EDT mieke posted to Nabble: Hey there, I need to count the matches of a sequence seq=c(2,3,4) in a long vector v=c(4,2,5,8,9,2,3,5,6,1,7,2,3,4,5,). With sum(v %in% seq) I only get the sum of sum(v %in% 2),

[R] problem on semiparametric single index estimator

2010-04-21 Thread Deniz Ozabaci
Dear R-Help, I am Deniz. I am currently trying to replicate a semiparametric sample selection paper and I am working on Klein and Spady estimator. I am using the npindex() and npindexbw() functions. The problem is, I need results for single bandwidth and when I set bandwidth computation to "FALSE

Re: [R] Sparseby Problems

2010-04-21 Thread William Dunlap
sparseby's FUN argument needs to be a function that accepts a data.frame. mean() has a data.frame method that returns a vector of column means but most of the other summary functions (e.g., median, min, max, quantile) do not work on data.frames. You can use aggregate() instead of by() or sparseby

Re: [R] Count matches of a sequence in a vector?

2010-04-21 Thread Gabor Grothendieck
rollapply in the zoo package could be used: library(zoo) ix <- rollapply(zoo(v), 3, function(x) all(x == 2:4)) which returns a logical vector or if you want the indexes use this: which(ix) On Wed, Apr 21, 2010 at 10:16 AM, mieke wrote: > > Hey there, > > I need to count the matches o

[R] question on rpart

2010-04-21 Thread josh franta
Hello, I have attempted to email the author of this package without success, just wondering if anybody else has experienced this. I am having an using rpart on 4000 rows of data with 13 attributes. I can run the same test on 300 rows of the same data with no issue. When I run on 4000 rows, Rgui.e

[R] Sparseby Problems

2010-04-21 Thread Ben Stewart
I've got a problem with the sparseby command (reshape library), and I have reached the peak of my R knowledge (it isn't really that high). I have a small data frame of 23 rows and 15 columns, here is a subset, the first four columns are factors and the rest are numeric (only one, line54 is provide

[R] Problem when reading tables containing Unicode characters in Windows

2010-04-21 Thread Hilmar Berger
Hi all, I have a problem when trying to read text tables containing Unicode chars in R 2.10.1 (WinXP, English locale). An example file is attached. The following command is supposed to read the table, but the data is only read incompletely: read.table("example_unicode.txt", sep="\t", dec=".", h

Re: [R] Count matches of a sequence in a vector?

2010-04-21 Thread Jeff Brown
This sort of calculation can't be vectorized; you'll have to iterate through the sequence, e.g. with a "for" loop. I don't know if a routine has already been written. -- View this message in context: http://n4.nabble.com/Count-matches-of-a-sequence-in-a-vector-tp2019018p2019108.html Sent from t

[R] Count matches of a sequence in a vector?

2010-04-21 Thread mieke
Hey there, I need to count the matches of a sequence seq=c(2,3,4) in a long vector v=c(4,2,5,8,9,2,3,5,6,1,7,2,3,4,5,). With sum(v %in% seq) I only get the sum of sum(v %in% 2), sum(v %in% 3) and sum(v %in% 4), but that's not what I need :( Who can help me? Thanks a lot! -- View this messag

[R] Maximum Likelihood in R

2010-04-21 Thread Henkep
Dear R-Help, my name is Henrik and I am currently trying to solve a Maximum Likelihood optimization problem in R. Below you can find the output from R, when I use the "BFGS" method: The problem is that the parameters that I get are very unreasonable, I would expect the absolute value of each p

[R] Degrees of Freedom Not Allocated to Residuals in Reduced Model

2010-04-21 Thread wesman2k1
I am trying to test for fixed factor main effects in an unbalanced mixed effects model but when I fit the reduced model for "mic" factor effects, the extra degrees of freedom are being allocated to a nested term rather than the residuals. The model has inc, mic and spp are independent variab

Re: [R] Results from clogit out of range?

2010-04-21 Thread Frank E Harrell Jr
Thomas Lumley wrote: On Tue, 20 Apr 2010, Noah Silverman wrote: I just read the help page for predict.coxph. It indicates that the risk score is just exp(lp) What I'm trying to find, and have seen with some other implementations is the "conditional probability within group". Neither the lp o

Re: [R] Table to List Transformation Scenario

2010-04-21 Thread Gabor Grothendieck
Assuming the date as id is the first column followed by 23 values, try the read.reps function found here: http://www.mail-archive.com/r-help@r-project.org/msg92123.html like this: DF <- read.csv("myfile", as.is = TRUE) read.reps(DF, 23) On Wed, Apr 21, 2010 at 2:24 PM, Idgarad wrote: > I have

Re: [R] overlaying a levelplot on a map plot

2010-04-21 Thread Peter Ehlers
Try using contour() instead of levelplot. See the examples in help('contour') for how to add contour lines to an existing plot. -Peter Ehlers On 2010-04-21 13:08, David Winsemius wrote: On Apr 21, 2010, at 2:27 PM, Simon Goodman wrote: I've generated a levelplot showing the density distrib

Re: [R] Can I compare two clusters without using their distance-matrix (dist()) ?

2010-04-21 Thread Tal Galili
Wonderful Christian, thank you for the (*very*) helpful reply! Best, Tal Contact Details:--- Contact me: tal.gal...@gmail.com | 972-52-7275845 Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) | www.r-statis

Re: [R] A question about plot.mcmc

2010-04-21 Thread Tengfei Yin
Hi David, Thank you so much, that's just what I want!! Best Tengfei On Wed, Apr 21, 2010 at 2:24 PM, David Winsemius wrote: > > On Apr 21, 2010, at 3:21 PM, Tengfei Yin wrote: > > Hi >> >> I have mone quick question I am not quite familiar with, for generic >> function plot, why some methods

Re: [R] A question about plot.mcmc

2010-04-21 Thread David Winsemius
On Apr 21, 2010, at 3:21 PM, Tengfei Yin wrote: Hi I have mone quick question I am not quite familiar with, for generic function plot, why some methods are marked by '*', I think plot(as.mcmc()) may dispatch the right method, I try to use get to view the function, but it seems that get() o

Re: [R] Assigning week numbers

2010-04-21 Thread David Winsemius
On Apr 21, 2010, at 1:15 PM, David Winsemius wrote: On Apr 21, 2010, at 12:50 PM, Michael Hosack wrote: I provided a minimized version of my dataframe at the bottom of this message containing the results of David's code in variable ('wkoffset') and Jeff Hallman's code in ('WEEK'). Jeff

Re: [R] A question about plot.mcmc

2010-04-21 Thread Tengfei Yin
Hi I have mone quick question I am not quite familiar with, for generic function plot, why some methods are marked by '*', I think plot(as.mcmc()) may dispatch the right method, I try to use get to view the function, but it seems that get() only works for the one with no "*", e.g. get('plot.ecdf')

Re: [R] overlaying a levelplot on a map plot

2010-04-21 Thread David Winsemius
On Apr 21, 2010, at 2:27 PM, Simon Goodman wrote: I've generated a levelplot showing the density distribution of a species derived from survey transects, with lon, lat co-ordinates. I'd like to overlay this on a map of the study region specified by: map('worldHires', xlim = range(mlon), y

[R] Assigning week numbers

2010-04-21 Thread Michael Hosack
Gustaf, That is correct. Schedule3 does contain all of the Saturdays between April 30 and Nov. 01 for a given year. Mike R experts, > > How could I extract the week number from a date vector (in Date class) > such that week numbering (week 1...2...) begins (May 01) and ends > (October 31

[R] Assigning Week Numbers

2010-04-21 Thread Michael Hosack
David, there is still a problem. The data in variable 'wkoffset' should be equivalent to the data in 'WEEK'. May 07 should begin wkoffset=2 and the preceeding days should all be assigned wkoffset=1. I did make sure to adjust the year within day.of.week(). Could you please explain what you me

Re: [R] How to obtain the coefficients from a summary of aov ?

2010-04-21 Thread Peter Ehlers
Slight addition below; On 2010-04-21 10:51, David Winsemius wrote: On Apr 21, 2010, at 12:36 PM, David Winsemius wrote: On Apr 21, 2010, at 12:09 PM, Andrea Bernasconi DG wrote: Thank you David, but how to get the value of 0.015939 present in s.npk.aov, and not given by s.npk.aov$coef["bl

Re: [R] Table to List Transformation Scenario

2010-04-21 Thread Phil Spector
I'm guessing that you are using the words "table" and "list" to mean "data frame". If that's the case, something like this might get you started: dfnew = reshape(Test1,varying=list(paste('Hour',1:23,sep='')), timevar='Hour',idvar='Date',direction='long') dfnew = dfnew[order(dfne

Re: [R] A question about plot.mcmc

2010-04-21 Thread Uwe Ligges
On 21.04.2010 20:31, Xiao D wrote: Dear List members, I am using R to generate MCMC time series plots. This is the code I use; however, everytime an error message will come out saying could not find function "plot.mcmc." I have coda package and Lattice package installed. Does anyone know what m

[R] A question about plot.mcmc

2010-04-21 Thread Xiao D
Dear List members, I am using R to generate MCMC time series plots. This is the code I use; however, everytime an error message will come out saying could not find function "plot.mcmc." I have coda package and Lattice package installed. Does anyone know what may get wrong here? Thanks so much for y

Re: [R] Count matches of a sequence in a vector?

2010-04-21 Thread Jeff Brown
Phil's algorithm is a good one, unless you're worried about optimizing for speed. It makes N * M comparisons, where N is the length of the first vector and M is the length of the second. Explicitly iterating through the longer vector, you could reduce the number of comparisons to M. As is often

[R] overlaying a levelplot on a map plot

2010-04-21 Thread Simon Goodman
I've generated a levelplot showing the density distribution of a species derived from survey transects, with lon, lat co-ordinates. I'd like to overlay this on a map of the study region specified by: map('worldHires', xlim = range(mlon), ylim = range(mlat)), where mlon, mlat specifies the study

[R] Degrees of Freedom Not Allocated to Residuals in Reduced Model

2010-04-21 Thread wesman2k1
##I am trying to test for fixed factor main effects in an unbalanced mixed effects model but when I fit the reduced model for "mic" factor effects, the extra degrees of freedom are being allocated to a nested term rather than the residuals. The model has inc, mic and spp are independent varia

[R] Table to List Transformation Scenario

2010-04-21 Thread Idgarad
I have a series of tables, one for each environment indicating a date (row) and a sample at each hour of the day (0 to 23) Test1 Table: Date,Hour1,Hour2,...Hour23 1/1/10,123,123,...,123 I would like to model this as a time series but how can I translate the table into a list such that I can get:

Re: [R] Question regarding R plot

2010-04-21 Thread Uwe Ligges
> optimize(function(x) -scores(x), interval=c(0.5, 0)) $minimum [1] 0.1830174 $objective [1] -11.67820 So the maximum is at x=0.183 with a score of 11.7, numerically. Uwe Ligges On 17.04.2010 16:30, Akito Y. Kawahara wrote: Hi, I am new to R, and have a quick question regarding an R script

Re: [R] Fishy error with NAMESPACE when checking package

2010-04-21 Thread Uwe Ligges
You forgot to rebuild or reinstall ? Uwe Ligges On 18.04.2010 00:25, BXC (Bendix Carstensen) wrote: I am updating the Epi package. I added functions named pc.points and pc.matpoints. Erroneously I wrote pc.plot and pc.matplot in the NAMESPACE file and of course got an error from Rcmd check

Re: [R] Writing methods for existing generic function

2010-04-21 Thread Uwe Ligges
On 19.04.2010 13:51, Viechtbauer Wolfgang (STAT) wrote: Dear All, Suppose I want to write a method for the generic function confint(): args(confint) function (object, parm, level = 0.95, ...) So, it looks like the second really??? > and third argument have been predefined in the generi

[R] Cross-checking a custom function for separability indices

2010-04-21 Thread Nikos Alexandris
Hi list! I have prepared a custom function (below) in order to calculate separability indices (Divergence, Bhattacharyya, Jeffries-Matusita, Transformed divergene) between two samples of (spectral land cover) classes. I need help to cross-compare results to verify that it works as expected (si

[R] (no subject)

2010-04-21 Thread Benjamin Stewart
I've got a problem with the sparseby command (reshape library), and I have reached the peak of my R knowledge (it isn't really that high).   I have a small data frame of 23 rows and 15 columns, here is a subset, the first four columns are factors and the rest are numeric (only one, line54 is pro

Re: [R] Can I compare two clusters without using their distance-matrix (dist()) ?

2010-04-21 Thread Christian Hennig
Dear Tal, I took the definition of the Hubert gamma- and Dunn-index from the Gordon book. They are actually not about comparing two clusters, at least not in that reference, and they require dissimilarities. The adjusted Rand index and Meila's VI, as implemented in cluster.stats, compare two

Re: [R] Assigning week numbers

2010-04-21 Thread David Winsemius
On Apr 21, 2010, at 12:50 PM, Michael Hosack wrote: I provided a minimized version of my dataframe at the bottom of this message containing the results of David's code in variable ('wkoffset') and Jeff Hallman's code in ('WEEK'). Jeff's code produced the correct results (thank you Jeff)

Re: [R] 3D surface plot with wireframe or persp?

2010-04-21 Thread Uwe Ligges
You cannot specify a dfunction for z, but need to compute the values in the matrix yourself as in: persp(data_for_time, data_for_s, outer(data_for_time, data_for_s, plot_R_i_3d)) Uwe Ligges On 20.04.2010 17:35, Jin wrote: Hello Dear, I have a function, like z=f(x,y), and try a surfac

Re: [R] Can I compare two clusters without using their distance-matrix (dist()) ?

2010-04-21 Thread Tal Galili
Thanks for the fast reply Uwe. My hope in posting this was to find if anyone had already done work (in R) in this direction. So far I wasn't able to find any such relevant code, so I turned to the mailing list. Regarding new implementations - thanks for offering! - I have already came around one

Re: [R] Unexpected warning from matplot

2010-04-21 Thread Uwe Ligges
On 21.04.2010 16:36, Mario Valle wrote: n <- 63 a <- 1:n x <- a-1 y <- outer(x,a) matplot(x,y,type='l') Warning message: In matplot(x, y, type = "l") : default 'pch' is smaller than number of columns and hence recycled Why is it complaining if I specifically ask for type="l", so no pch involve

Re: [R] How to obtain the coefficients from a summary of aov ?

2010-04-21 Thread David Winsemius
On Apr 21, 2010, at 12:36 PM, David Winsemius wrote: On Apr 21, 2010, at 12:09 PM, Andrea Bernasconi DG wrote: Thank you David, but how to get the value of 0.015939 present in s.npk.aov, and not given by s.npk.aov$coef["block","Pr(>F)"] ? ??? That's not a coefficient. It's a p-value.

Re: [R] Can I compare two clusters without using their distance-matrix (dist()) ?

2010-04-21 Thread Uwe Ligges
On 21.04.2010 18:15, Tal Galili wrote: Hello all, I would like to compare the similarity of two cluster solutions using a validation criteria (such as Hubert's gamma coefficient, the Dunn index the corrected rand index and so on) I see (from here:http://www.statmethods.net/advstats/cluster.html

[R] Assigning week numbers

2010-04-21 Thread Michael Hosack
I provided a minimized version of my dataframe at the bottom of this message containing the results of David's code in variable ('wkoffset') and Jeff Hallman's code in ('WEEK'). Jeff's code produced the correct results (thank you Jeff) though I have been unable to understand it. David, as you

Re: [R] R crashing oddly

2010-04-21 Thread Uwe Ligges
On 21.04.2010 18:19, Michael Steven Rooney wrote: The R version is 2.9.2. Please try with R-2.11.0 RC (release candidate) to be released tomorrow as well as a recent version of nlme. If its still fails, please send code (and data, if you do not generate them in the code) that reproduces t

Re: [R] How to obtain the coefficients from a summary of aov ?

2010-04-21 Thread David Winsemius
On Apr 21, 2010, at 12:09 PM, Andrea Bernasconi DG wrote: Thank you David, but how to get the value of 0.015939 present in s.npk.aov, and not given by s.npk.aov$coef["block","Pr(>F)"] ? ??? That's not a coefficient. It's a p-value. On the other, the procedure to extract coefficients from

[R] R crashing oddly

2010-04-21 Thread Michael Steven Rooney
The R version is 2.9.2. nlme version is 3.1-93 The OS is Windows XP. This is for my work computer but I get the same behavior at home using Vista. -- Forwarded message -- From: Sarah Goslee Date: Wed, Apr 21, 2010 at 11:50 AM Subject: Re: [R] R crashing oddly To: Michael Steven Roo

Re: [R] Help: formatting the result of 'cut' function

2010-04-21 Thread Gabor Grothendieck
gsubfn is like gsub except instead of a replacement string it uses a replacement function whose input is the string matched by the regular expression and whose output replaces the match. The replacement function can optionally be specified as a formula as we do here. If there is no left hand sid

Re: [R] Help: formatting the result of 'cut' function

2010-04-21 Thread jim holtman
Try this: > set.seed(1) > x <- c(rnorm(1e3, mean=10, sd=1), 50, 100) > > start <- 0 > end <- 110 > h <-10 > > c1 <- cut(x, br=seq(start, end, h), right=TRUE) > levels(c1) [1] "(0,10]""(10,20]" "(20,30]" "(30,40]" "(40,50]" "(50,60]" "(60,70]" "(70,80]" [9] "(80,90]" "(90,10

[R] Can I compare two clusters without using their distance-matrix (dist()) ?

2010-04-21 Thread Tal Galili
Hello all, I would like to compare the similarity of two cluster solutions using a validation criteria (such as Hubert's gamma coefficient, the Dunn index the corrected rand index and so on) I see (from here:http://www.statmethods.net/advstats/cluster.html) that the function cluster.stats() in th

[R] vegan: grafical problem in ordiplot/ordisurf

2010-04-21 Thread Kim Vanselow
Dear vegan-helpers, I calculated an NMDS with metaMDS and then displayed the results with ordiplot. The NMDS consist of 4 axes. I want to plot two diagrams: 1st vs. 2nd and 3rd vs. 4th axis. I used the ordiplot-command choices = c(1,2) and c(3,4), respectively. 1st vs. 2nd does not make any prob

Re: [R] How to obtain the coefficients from a summary of aov ?

2010-04-21 Thread Andrea Bernasconi DG
Thank you David, but how to get the value of 0.015939 present in s.npk.aov, and not given by s.npk.aov$coef["block","Pr(>F)"] ? On the other, the procedure to extract coefficients from a summary of lm or aov should be the same. Andrea On 21 Apr, 2010, at 3:20 PM, David Winsemius wrote: > >

Re: [R] dataframe

2010-04-21 Thread jim holtman
Here is one way of doing it: > x <- read.table(textConnection("CFISCAFIRMS YEAR VARVALUE + 20345 nike2005EC01 34 + 20345 nike2006 EC01 45 + 56779

Re: [R] Results from clogit out of range?

2010-04-21 Thread Thomas Lumley
On Tue, 20 Apr 2010, Noah Silverman wrote: I just read the help page for predict.coxph. It indicates that the risk score is just exp(lp) What I'm trying to find, and have seen with some other implementations is the "conditional probability within group". Neither the lp or the risk options see

  1   2   >