[R] how to choose dates data?

2013-07-04 Thread Gallon Li
i have converted my data into date format like below: day=as.Date(originaldate,%m/%d/%Y) day[1:5] [1] 2008-04-12 2011-07-02 2011-09-02 2008-04-12 2008-04-12 I wish to select only those observations from 2007 to 2009, how can I select from this list? [[alternative HTML version

[R] bootstrapping respecting subject level information

2013-07-04 Thread Sol Lago
Hi there, This is the first time I use this forum, and I want to say from the start I am not a skilled programmer. So please let me know if the question or code were unclear! I am trying to bootstrap an interaction (that is my test statistic) using the package boot. My problem is that for

Re: [R] Subsetting multiple rows of a data frame at once

2013-07-04 Thread arun
Hi, Possibly, FAQ 7.31 Using the same example: set.seed(24) df- data.frame(x=sample(seq(0.25,4.25,by=.05),1e5,replace=TRUE),y= sample(seq(0.10,1.05,by=.05),1e5,replace=TRUE),z=rnorm(1e5)) dfOld- df  df[,1:2]- lapply(df[,1:2],function(x) sprintf(%.2f,x)) x1- c(1.05,2.85,3.40,4.25,0.25) y1-

Re: [R] Subsetting multiple rows of a data frame at once

2013-07-04 Thread arun
Hi, carbon.fit = expand.grid(list(x=seq(0, 5, 0.01), y=seq(0, 5, 0.01)))  dim(carbon.fit) #[1] 251001  2  xtNew-sprintf(%.2f,xt)  ytNew- sprintf(%.2f,yt)  carbon.fit[]- lapply(carbon.fit,function(x) sprintf(%.2f,x)) res-do.call(rbind,lapply(seq_along(xtNew),function(i)

[R] cluster analysis

2013-07-04 Thread Ekele Alih
I want to do Agglomerative Hierarchical clustering using complete linkage method in R using the function agnes or hclust. 1. Can i do a cluster analysis of h=(n+p+1)/2 out of n observation?  note that p=nomber of variables(dependent and independent) 2. Can i plot the dendrogram and get the

Re: [R] how to choose dates data?

2013-07-04 Thread Dante.py
I have a method which is not so smart --use grep to match the pattern. for example: dates - c(02/27/92, 02/27/92, 01/14/92, 02/28/92, 02/01/91) day - as.Date(dates, %m/%d/%y) day: [1] 1992-02-27 1992-02-27 1992-01-14 1992-02-28 1991-02-01 If I want to search for 1991, I can use: grep(1991-*, day)

Re: [R] modify timestemp

2013-07-04 Thread Enrico Schumann
On Wed, 03 Jul 2013, Ye Lin ye...@lbl.gov writes: Hey All, I want to standardize my timestamp which is formatted as hh:mm:ss My data looks like this: Date Time 01/01/2013 00:09:01 01/02/2013 00:10:14 01/03/2013 00:11:27 01/04/2013 00:12:40 01/05/2013 00:13:53 01/06/2013

Re: [R] how to choose dates data?

2013-07-04 Thread Prof Brian Ripley
On 04/07/2013 08:04, Dante.py wrote: I have a method which is not so smart --use grep to match the pattern. for example: dates - c(02/27/92, 02/27/92, 01/14/92, 02/28/92, 02/01/91) day - as.Date(dates, %m/%d/%y) day: [1] 1992-02-27 1992-02-27 1992-01-14 1992-02-28 1991-02-01 If I want to search

[R] Binomial Regression and nnet

2013-07-04 Thread Lorenzo Isella
Dear All, I am playing with different models/packages (random forest, logistic regression, gbm etc...) for a problem of binomial regression (i.e. the outcome is 0/1, dead or alive etc...). I have used in the past the multinom function from the nnet library which uses the neural networks for

Re: [R] how to choose dates data?

2013-07-04 Thread Dante.py
They are really good methods. Thank you very much. Could I ask one more question. Is there obvious difference between these two methods? 2013/7/4 Prof Brian Ripley rip...@stats.ox.ac.uk On 04/07/2013 08:04, Dante.py wrote: I have a method which is not so smart --use grep to match the

Re: [R] Non-linear modelling with several variables including a categorical variable

2013-07-04 Thread Robbie Weterings
Thanks for the advise Prof Nash, but I'm not sure if I understood it right. I managed to make a new model based on what I think you meant. What I did is; I created 3 variables (cat1, cat2, cat3) one for each category with either the value 1 or 0 and added these to the model so they work as

Re: [R] how to choose dates data?

2013-07-04 Thread Prof Brian Ripley
On 04/07/2013 11:36, Dante.py wrote: They are really good methods. Thank you very much. Could I ask one more question. Is there obvious difference between these two methods? Yes. It is obvious that the type of x differs. 2013/7/4 Prof Brian Ripley rip...@stats.ox.ac.uk

[R] Help

2013-07-04 Thread Aboagye-sarfo, Patrick
I am trying to download packages and the message I get is as follows utils:::menuInstallPkgs() --- Please select a CRAN mirror for use in this session --- Warning: unable to access index for repository http://cran.ms.unimelb.edu.au/bin/windows/contrib/3.0 Warning: unable to access index for

Re: [R] Help

2013-07-04 Thread S Ellison
I am trying to download packages and the message I get is as follows Warning: unable to access index for repository http://cran.ms.unimelb.edu.au/bin/windows/contrib/3.0 Your internet connection is probably either not working or (more likely) blocked by firewall or site access policies.

[R] polr?

2013-07-04 Thread Dániel Kehl
Dear R users, I have a dataset with two ordered variables, tr_x1 and tr_y1. A crosstable of them can bee seen below. tr_x1 tr_y1 -101 -1 629 100 629 0 1396 4353 1443 1 668 126 655 It is clear that if tr_x1 is 0, it has an effect on tr_y1. A chi-square statistic

[R] list construction with automatic names

2013-07-04 Thread Alex van der Spek
I often find myself (wanting t)o constructing lists or data.frames like so: #Find files in subdirs ii - 0 for (ix in id) { ii - ii + 1 if (ii == 1) { fl - list(basename(ix) = list.files(ix)) } else { fl - c(fl, list(basename(ix) =

Re: [R] polr?

2013-07-04 Thread Prof Brian Ripley
On 04/07/2013 12:59, Dániel Kehl wrote: Dear R users, I have a dataset with two ordered variables, tr_x1 and tr_y1. A crosstable of them can bee seen below. tr_x1 tr_y1 -101 -1 629 100 629 0 1396 4353 1443 1 668 126 655 It is clear that if tr_x1 is 0, it

Re: [R] list construction with automatic names

2013-07-04 Thread S Ellison
I often find myself (wanting t)o constructing lists or data.frames Apologies; previous post should have said Read R inforno on 'Growing Objects' and should have added the URL: http://www.burns-stat.com/pages/Tutor/R_inferno.pdf S Ellison

Re: [R] list construction with automatic names

2013-07-04 Thread S Ellison
I often find myself (wanting t)o constructing lists or data.frames: Try something like fl-list() for (ix in id) { fl[[basename(ix)]] - list.files(ix) } But read R Inferno on inrementing objects first. It isn't efficient in memory terms (unless that's improved in recent versions of R)

Re: [R] polr?

2013-07-04 Thread Dániel Kehl
Dear Prof Ripley, could you be just a little more specific? Thanks a lot daniel Feladó: Prof Brian Ripley [rip...@stats.ox.ac.uk] Küldve: 2013. július 4. 14:14 To: Dániel Kehl Cc: r-help Tárgy: Re: [R] polr? On 04/07/2013 12:59, Dániel Kehl wrote: Dear

Re: [R] list construction with automatic names

2013-07-04 Thread Alex van der Spek
I often find myself (wanting t)o constructing lists or data.frames Apologies; previous post should have said Read R inforno on 'Growing Objects' and should have added the URL: http://www.burns-stat.com/pages/Tutor/R_inferno.pdf S Ellison

Re: [R] polr?

2013-07-04 Thread peter dalgaard
On Jul 4, 2013, at 14:38 , Dániel Kehl wrote: Dear Prof Ripley, could you be just a little more specific? He'll likely find that difficult. It's sort of like if you had data like this 25 75 75 25 25 75 and did a trend test. The trend test _assumes_ that the effect is increasing, and

[R] ggplot2

2013-07-04 Thread AlexPiche
Hello Folks, I have a database of 2000+ days with 35 observations each. I am trying to modeling a time series by day, but it seems a problem that I dont have the time of the observation. I achieve something interesting by using the barplot function, but I`d rather working with ggplot2, since I

Re: [R] how to choose dates data?

2013-07-04 Thread arun
Hi, You could try: day-as.Date(c(2008-04-12,2011-07-02,2011-09-02,2008-04-12,2008-04-12))  indx-gsub(-.*,,day)  day[indx=2007 indx=2009] #[1] 2008-04-12 2008-04-12 2008-04-12 #or library(xts) xt1- xts(seq_along(day),day) index(xt1[2007/2009]) #[1] 2008-04-12 2008-04-12 2008-04-12 #or

Re: [R] ggplot2

2013-07-04 Thread John Kane
I think we need to see some of the original data. See ?dput for how to supply data in a email. We probably don't need all the data, I'd suggest perhaps 100 rows or so. Try dput(head(yourdata, 100)) BTW what is last? John Kane Kingston ON Canada -Original Message- From:

Re: [R] ggplot2

2013-07-04 Thread AlexPiche
Heres the function last last function (x, ...) { UseMethod(last) } environment: namespace:xts I can share 100 rows if you want, but I don`t you will find it useful, since I want to perform my time-series on a single row. Here`s one: dezdiff.dt[nrow(dezdiff.dt),] datetime

Re: [R] ggplot2

2013-07-04 Thread John Kane
Thanks Alex but the idea is to use dput() for the data so that readers can simply copy and paste it into R and have a working dataset. I have a very small data.frame called dd. Var1 Var2 1 A1 2 B1 3 C1 4 A2 5 B2 6 C2 7 A3 8 B3 9

Re: [R] how to choose dates data?

2013-07-04 Thread David Carlson
Also yrs - as.Date(c(2007-01-01, 2009-12-31)) day[day=yrs[1] day=yrs[2]] [1] 2008-04-12 2008-04-12 2008-04-12 Should be fast if there are many days to process since it converts the search criteria, not the data. - David L Carlson Associate Professor of

[R] R and MatLab implementations of the same model differs

2013-07-04 Thread Jannetta Steyn
Hi folks I have implemented a model of a neuron using Hodgkin Huxley equations in both R and MatLab. My preference is to work with R but R is not giving me the correct results. I also can't use ode45 as it just seems to go into an indefinite loop. However, the MatLab implementation work fine with

Re: [R] R and MatLab implementations of the same model differs

2013-07-04 Thread Berend Hasselman
On 04-07-2013, at 17:15, Jannetta Steyn janne...@henning.org wrote: Hi folks I have implemented a model of a neuron using Hodgkin Huxley equations in both R and MatLab. My preference is to work with R but R is not giving me the correct results. I also can't use ode45 as it just seems to go

Re: [R] R and MatLab implementations of the same model differs

2013-07-04 Thread Ben Bolker
Berend Hasselman bhh at xs4all.nl writes: On 04-07-2013, at 17:15, Jannetta Steyn jannetta at henning.org wrote: Hi folks I have implemented a model of a neuron using Hodgkin Huxley equations in both R and MatLab. My preference is to work with R but R is not giving me the

Re: [R] R and MatLab implementations of the same model differs

2013-07-04 Thread Jannetta Steyn
Hi Ben and others I don't quite know how to explain the doesn't work in more detail without any visual aid. When you run the two scripts it is easy to see the difference. MatLab produces a line on x= -55. This is what I expect - a more or less straight line. R on the other hand the result drops

[R] iterative methods

2013-07-04 Thread catalin roibu
Dear R users, Please help me with some documentation for newbie about R programming, algorithms, create iterative C++ function (like for, while, if , etc). Thank you very much! -- --- Catalin-Constantin ROIBU Lecturer PhD, Forestry engineer Forestry Faculty of Suceava Str. Universitatii no.

Re: [R] R and MatLab implementations of the same model differs

2013-07-04 Thread Berend Hasselman
On 04-07-2013, at 18:42, Jannetta Steyn janne...@henning.org wrote: Hi Ben and others I don't quite know how to explain the doesn't work in more detail without any visual aid. You said that R got into an indefinite loop, whatever that maybe. When you run the two scripts it is easy to see

Re: [R] R and MatLab implementations of the same model differs

2013-07-04 Thread peter dalgaard
On Jul 4, 2013, at 19:11 , Berend Hasselman wrote: On 04-07-2013, at 18:42, Jannetta Steyn janne...@henning.org wrote: Hi Ben and others I don't quite know how to explain the doesn't work in more detail without any visual aid. You said that R got into an indefinite loop, whatever

[R] help on selecting values of an object

2013-07-04 Thread Andras Farkas
Dear List, please provide some input on the following: we have a -c(0,1,2,3) b -c(4,5,6,7) d -cbind(a,b) k -c(0,0,2,2,3,3,2) k in this case consists of some values of d[,1] in a random sequence. What I am trying to do is to create an object f that would have the values of d[,2] in it based on

Re: [R] R and MatLab implementations of the same model differs

2013-07-04 Thread Berend Hasselman
On 04-07-2013, at 19:56, peter dalgaard pda...@gmail.com wrote: On Jul 4, 2013, at 19:11 , Berend Hasselman wrote: On 04-07-2013, at 18:42, Jannetta Steyn janne...@henning.org wrote: Hi Ben and others I don't quite know how to explain the doesn't work in more detail without any

Re: [R] help on selecting values of an object

2013-07-04 Thread David Carlson
I think this is what you are looking for f - d[match(k, d[,1]), 2] f [1] 4 4 6 6 7 7 6 - David L Carlson Associate Professor of Anthropology Texas AM University College Station, TX 77840-4352 -Original Message- From: r-help-boun...@r-project.org

Re: [R] help on selecting values of an object

2013-07-04 Thread arun
Hi, You could use: d1- data.frame(a,b) k1-data.frame(a=k) library(plyr) join(k1,d1,by=a)[,2] #[1] 4 4 6 6 7 7 6 A.K. - Original Message - From: Andras Farkas motyoc...@yahoo.com To: r-help@r-project.org Cc: Sent: Thursday, July 4, 2013 2:09 PM Subject: [R] help on selecting values of

Re: [R] Meta-analysis on a repeated measures design with multiple trials per subject using metafor

2013-07-04 Thread Viechtbauer Wolfgang (STAT)
Dear Marc, Let me see if I understand the type of data you have. You say that you have 5 experiments. And within each experiment, you have n subjects and for each subject, you have data in the form described in your post. Now for each subject, you want to calculate some kind of measure that

Re: [R] R and MatLab implementations of the same model differs

2013-07-04 Thread peter dalgaard
On Jul 4, 2013, at 20:14 , Berend Hasselman wrote: On 04-07-2013, at 19:56, peter dalgaard pda...@gmail.com wrote: On Jul 4, 2013, at 19:11 , Berend Hasselman wrote: On 04-07-2013, at 18:42, Jannetta Steyn janne...@henning.org wrote: Hi Ben and others I don't quite know how to

[R] coxph doesn't converge when including factor variables

2013-07-04 Thread E Joffe
Hello, I have a dataset of 371 observations. When I run coxph with numeric variables it works fine. However, when I try to add factor variables it returns Ran out of iterations and the model did not converge There is something very strange with the factors - some of them should actually be

[R] Lattice barchart with error bars

2013-07-04 Thread Shaun Jackman
Hi, I'd like to draw a lattice barchart of means with error bars to show the standard deviation. I have the barchart, how do I add the error bars? require(datasets) require(lattice) x - aggregate(weight ~ Diet, ChickWeight, function(x) c(mean=mean(x), sd=sd(x))) barchart(weight[,'mean'] ~ Diet,

Re: [R] Help

2013-07-04 Thread Rolf Turner
Please (for crying out loud!) use a meaningful subject line!!! This list is called r-help!!! Using a subject line of Help is completely vacuous. cheers, Rolf Turner On 04/07/13 20:33, Aboagye-sarfo, Patrick wrote: I am trying to download packages and the message I get is as

Re: [R] Help

2013-07-04 Thread Joshua Wiley
Well, it implies either 2help or help^2, right? In this case, it seems oddly appropriate, as really needing help getting packages is sort of greater in a need hierarchy than coding help, as the latter is largely useless without the former. At one point, I seem to recall discussion of whether

Re: [R] Lattice barchart with error bars

2013-07-04 Thread Bert Gunter
Shaun: I understand that this type of plot is standard in many disciplines, but it really is awful (google on 'Dynamite plots' for some more erudite perspectives). Have you considered bwplot() for your unaggregated data instead? (No need to reply. It's July 4, and I'm just waving a little flag

Re: [R] R and MatLab implementations of the same model differs

2013-07-04 Thread Jannetta Steyn
Hi All Thanks for all the comments. I have looked at everything you have pointed out and this is the situation at the moment: I don't think so. In the R script you have init = c(v_axon_AB=-55,mNa_axon_AB=1,hNa_axon_AB=0,mK_axon_AB=1) That is not the same as in your Matlab script. To make

Re: [R] setClass confusion

2013-07-04 Thread David Winsemius
On Jul 3, 2013, at 4:54 PM, Erin Hodgess wrote: Dear R People: I am experimenting with S4 classes and methods but am having trouble with setting up a class. Here is an example: buzz - setClass(buzz,slots=c(x=matrix), + validity - function(object) { +

Re: [R] bootstrapping respecting subject level information

2013-07-04 Thread David Winsemius
On Jul 3, 2013, at 7:19 PM, Sol Lago wrote: Hi there, This is the first time I use this forum, and I want to say from the start I am not a skilled programmer. So please let me know if the question or code were unclear! I am trying to bootstrap an interaction (that is my test

Re: [R] R and MatLab implementations of the same model differs

2013-07-04 Thread peter dalgaard
On Jul 5, 2013, at 00:41 , Jannetta Steyn wrote: Hi All Thanks for all the comments. I have looked at everything you have pointed out and this is the situation at the moment: I don't think so. In the R script you have init = c(v_axon_AB=-55,mNa_axon_AB=1,hNa_axon_AB=0,mK_axon_AB=1)

Re: [R] Subsetting multiple rows of a data frame at once

2013-07-04 Thread William Dunlap
xt- c(1.05, 2.85, 3.40, 4.25, 0.25, 3.05, 3.70, 0.20, 0.30, 0.70, 1.05, 1.20, 1.40, 1.90, 2.70, 3.25, 3.55, 4.60, 2.05, 2.15, 3.70, 4.85, 4.90, 1.60, 2.45, 3.20, 3.90, 4.45) yt- c(0.25, 0.10, 0.90, 0.25, 1.05, 1.70, 2.05, 2.90, 2.35, 2.60, 2.55, 2.15, 2.75, 2.05, 2.70, 2.25, 2.55,

Re: [R] bootstrapping respecting subject level information

2013-07-04 Thread Andrew Robinson
I'd like to preface this answer by suggesting that if you have multiple measurements within subjects then you should possibly be thinking about using mixed-effects models. Here you have a balanced design and seem to be thinking about a constrained bootstrap, but I don't know whether the resulting

Re: [R] bootstrapping respecting subject level information

2013-07-04 Thread Andrew Robinson
I think that in the case of a 2*2 balanced, replicated design such as this one, interpreting the interaction should be safe. Cheers Andrew On Fri, Jul 5, 2013 at 9:38 AM, David Winsemius dwinsem...@comcast.net wrote: On Jul 3, 2013, at 7:19 PM, Sol Lago wrote: Hi there, This is the first

Re: [R] bootstrapping respecting subject level information

2013-07-04 Thread Joshua Wiley
Hi, It is not the easiest to follow code, but when I was working at UCLA, I wrote a page demonstrating a multilevel bootstrap, where I use a two stage sampler, (re)sampling at each level. In your case, could be first draw subjects, then draw observations within subjects. A strata only option

Re: [R] bootstrapping respecting subject level information

2013-07-04 Thread Andrew Robinson
Josh's comment prompted me to check mty go-to reference. Davison and Hinckley (1997 Section 3.8) recommend sampling the Subjects, but not within the Subjects. Cheers Andrew On Thu, Jul 04, 2013 at 05:53:58PM -0700, Joshua Wiley wrote: Hi, It is not the easiest to follow code, but when I was

Re: [R] Non-linear modelling with several variables including a categorical variable

2013-07-04 Thread Robbie Weterings
Dear Prof. Nash, I tried to run nls with the nlxb function and as you mention it is fairly slower in terms of running the code. However, if I would have used this function earlier I would have saved a lot of time trying to find the start values. The output looks a little bit sloppy but I think it

[R] g2 test...

2013-07-04 Thread Fernando Marmolejo Ramos
dear R users is it appropriate to use a Log likelihood ratio (G-test) test of independence when dealing with repeated categorical responses (e.g. 2 by 2 table) instead of the McNemar test? thanks fer [[alternative HTML version deleted]] __

[R] Substituting Greek symbols in some tick labels

2013-07-04 Thread Eric Archer - NOAA Federal
I have a character vector that I'm using to label ticks in a dotchart. Some of the elements in the vector have an asterisk (*) where a Greek Delta needs to be placed when the plot is generated. Here's a simple example: x - 1:4 x.lab - c(a*a, bbb, c*c, ddd) dotchart(x, labels = x.lab) The first