[R] how to choose dates data?

2013-07-03 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 ver

Re: [R] setClass confusion

2013-07-03 Thread Duncan Murdoch
On 13-07-03 7: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) { + if(is.matrix(object)==FALSE)stop("Input m

[R] setClass confusion

2013-07-03 Thread Erin Hodgess
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) { + if(is.matrix(object)==FALSE)stop("Input must be a matrix") + TRUE + }) Error in setC

Re: [R] converting a list of loglin terms to a model formula

2013-07-03 Thread Henrique Dallazuanna
Try this: as.formula(sprintf(" ~ %s", do.call(paste, c(lapply(mutual(3), paste, collapse = ":"), sep = "+" On Wed, Jul 3, 2013 at 6:55 PM, Michael Friendly wrote: > I'm developing some functions to create symbolic specifications for > loglinear models of different types. > I don't really

Re: [R] modify timestemp

2013-07-03 Thread arun
Hi, May be this helps: dat1# dataset dat1[,2]<-gsub("\\d+$","00",dat1[,2])  dat1 # Date Time #1  01/01/2013 00:09:00 #2  01/02/2013 00:10:00 #3  01/03/2013 00:11:00 #4  01/04/2013 00:12:00 #5  01/05/2013 00:13:00 #6  01/06/2013 00:15:00 #7  01/07/2013 00:16:00 #8  01/08/2013 00:17:00 #

Re: [R] change cell values

2013-07-03 Thread arun
Hi, set.seed(24) mat1=matrix(rnorm(12),3) set.seed(28) mat2=matrix(rnorm(12),3)  indx<- mat1<1 & mat2<1 mat1[indx]<-NA  mat2[indx]<-NA  mat1 # [,1] [,2] [,3]    [,4] #[1,]   NA   NA   NA 0.002311942 #[2,]   NA   NA   NA  NA #[3,]   NA   NA   NA 0.598269113  mat2 # [,1] [,2] [,

Re: [R] String based chemical name identification

2013-07-03 Thread Law, Jason
Might be better off using a web service like ChemSpider to do the matching for you . The idea that you can identify the synonyms by name is probably optimistic unless they are exact matches. Here's some python code that seems to make it pretty eas

[R] converting a list of loglin terms to a model formula

2013-07-03 Thread Michael Friendly
I'm developing some functions to create symbolic specifications for loglinear models of different types. I don't really know how to 'compute' with model formulas, so I've done this in the notation for stats::loglin(), which is a list of high-order terms in the model. What I'd like is a function

Re: [R] change cell values

2013-07-03 Thread David Winsemius
On Jul 3, 2013, at 2:27 PM, JiangZhengyu wrote: > > > > Dear R experts, > > I have two matrices (mat1 & mat2) with the same dimension & the cells (row > and column) are corresponding to each other. > > I want to change cell values to NA given values of the corresponding cells in > mat1 an

[R] modify timestemp

2013-07-03 Thread Ye Lin
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 00:15:06 01/07/2013 00:16:19 01/08/2013 00:17:32 01/09/2013 00:18

Re: [R] change cell values

2013-07-03 Thread JiangZhengyu
Hi Rui, Yes, I see. You are right. Thanks for your help. Zhengyu > Date: Wed, 3 Jul 2013 22:38:37 +0100 > From: ruipbarra...@sapo.pt > To: zhyjiang2...@hotmail.com > CC: r-help@r-project.org > Subject: Re: [R] change cell values > > Hello, > > It's not working because you are changing mat1

Re: [R] change cell values

2013-07-03 Thread Rui Barradas
Hello, It's not working because you are changing mat1 before the second condition is evaluated, and so mat1 is full of NA values. Try the following. tmp <- mat1 # Make a copy tmp[mat1 < 1 & mat2 < 1] <- NA # And change that copy mat2[mat1 < 1 & mat2 < 1] <- NA mat1 <- tmp rm(tmp) Hope th

[R] change cell values

2013-07-03 Thread JiangZhengyu
Dear R experts, I have two matrices (mat1 & mat2) with the same dimension & the cells (row and column) are corresponding to each other. I want to change cell values to NA given values of the corresponding cells in mat1 and mat2 are both <1. E.g. both mat1[2,3] and mat2[2,3] are <1, I wil

[R] qtlnet mcmc.qtlnet sample genetic architeture and QTL network

2013-07-03 Thread schaefe9
Im working with the "qtlnet" package and want to sample the genetic architecture and QTL network. I aiming to do this with the function qtlnet:::mcmc.qtlnet. So far so good. However I cant do it with my own cross dataset. data(Pscdbp) works fine, but not my own. I mean it is from class "cross". How

[R] nls.profile

2013-07-03 Thread Thomas de Marchin
Hello Daniel, I have the same problem than you : i use nls.profile to compute confidence intervals of estimated parameters but it fails and stop... I tried to increase alphamax value as Douglas suggested that it should work but it's not... Did you find a method to tell nls.profile to ignore e

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

2013-07-03 Thread Marc Heerdink
Hi all, I am currently attempting to compile a summary of a series of five psychological experiments, and I am trying to do this using the metafor package. However, I am quite unsure which of the scenarios described in the metafor help pages applies to these data, because it is a repeated mea

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

2013-07-03 Thread arun
Hi, Try this: 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)) #Used a shorter vector x1<- c(1.05,2.85,3.40,4.25,0.25) y1<- c(0.25,0.10,0.90,0.25,1.05) res<-do.call(rbind,lapply(seq_along(x1),function

[R] String based chemical name identification

2013-07-03 Thread Zsurzsa Laszlo
The problem is the following: I have two big databases one look like this: 2-Methyl-4-trimethylsilyloxyoct-5-yne Benzoic acid, methyl ester Benzoic acid, 2-methyl-, methyl ester Acetic acid, phenylmethyl ester 2,7-Dimethyl-4-trimethylsilyloxyoct-7-en-5-yne etc. The second one looks li

[R] The R Journal, Volume 5, Issue 1

2013-07-03 Thread Hadley Wickham
Dear all, The latest issue of The R Journal is now available at http://journal.r-project.org/archive/2013-1/ Many thanks to all contributors. Hadley -- Editor-in-chief, The R Journal ___ r-annou...@r-project.org mailing list https://stat.ethz.ch/mail

[R] Academic study of R users and developers

2013-07-03 Thread aserebrenik
Dear all, A group of researchers from Eindhoven Univ of Technology (The Netherlands) and UC Davis (USA) is conducting a study of support activities in R. In this study, our goal is to understand how R user support activities have been evolving over time, in the presence of different information ex

Re: [R] Splitting a string expression into components

2013-07-03 Thread Bert Gunter
Alternatively, perhaps strsplit() with an appropriate regex argument. See ?strsplit ?regexp e.g. strsplit ("z<=5",split = "[<>=]+") [[1]] [1] "z" "5" This of course will only work if you know what the characters are that define "left" and "right", how complex the expressions might be, etc. -- i

Re: [R] Splitting a string expression into components

2013-07-03 Thread William Dunlap
If your syntax is like R's syntax then parse() can help. R> p <- parse(text="z = 1 + 2") R> p[[1]] # the first (& only) expression in "z = 1 + 2" z = 1 + 2 R> as.list(p[[1]]) # the 'function' called (`=`) and its 'arguments' [[1]] `=` [[2]] z [[3]] 1 + 2 R> as.list(p[

[R] Splitting a string expression into components

2013-07-03 Thread Dan Murphy
I have a vector of strings that contain mathematical expressions. E.g., x <- c("5 <= 7", "z = 1+2") and I would like to decompose each expression into its left- and right-hand-side components etc., output something like "5" "<=" "7" "z" "=" "1" "+" "2" Is there something built into the R language

Re: [R] promise already under evaluation

2013-07-03 Thread Sam Steingold
> * Sam Steingold [2013-07-03 11:33:47 -0400]: > > Hi, I asked this question on SO but got no answers: > http://stackoverflow.com/questions/17310825/r-promise-already-under-evaluation Backlin explained on SO that the errors are to be expected: "..." is a formal argument which was not supplied and

[R] promise already under evaluation

2013-07-03 Thread Sam Steingold
Hi, I asked this question on SO but got no answers: http://stackoverflow.com/questions/17310825/r-promise-already-under-evaluation I understand that you are probably sick and tired of answering the same question again, but I am still getting the error discussed in several other questions: >>> p

Re: [R] One-parameter fitting

2013-07-03 Thread Birdada Simret
Thank you all ;) On Wed, Jul 3, 2013 at 4:28 PM, S Ellison wrote: > > Now I have question: what about y=b fitting? is there any model to > > force or impose the ax to be zero > > Rui Barradas has answered correctly for a simple lm case. > > You can also do > lm(y~1) to obtain an estimated

Re: [R] One-parameter fitting

2013-07-03 Thread S Ellison
> Now I have question: what about y=b fitting? is there any model to > force or impose the ax to be zero Rui Barradas has answered correctly for a simple lm case. You can also do lm(y~1) to obtain an estimated mean. That formulation happens to be quite useful if you are interested in a pu

Re: [R] merge dataframes

2013-07-03 Thread Rui Barradas
Hello, Or use ?all.equal. all.equal(dat2[52, 1], dat1[5, 1]) # TRUE Hope this helps, Rui Barradas Em 03-07-2013 15:18, David Carlson escreveu: In addition to reading Frequently Asked Questions Section 7.31, you should always run your own code before posting. Yours does not work. Spend some

Re: [R] merge dataframes

2013-07-03 Thread David Carlson
In addition to reading Frequently Asked Questions Section 7.31, you should always run your own code before posting. Yours does not work. Spend some time reading one or more of the R tutorials and learn about vectorization. It will save you time and typing. There are many to choose from at http://c

Re: [R] One-parameter fitting

2013-07-03 Thread Rui Barradas
Hello, Try ?mean abline(h = mean(y), col = "blue") Hope this helps, Rui Barradas Em 03-07-2013 15:07, Birdada Simret escreveu: Greetings to every body. we know that for linear regression: two-parameter fitting in R: (for a and b as slope and intercept) [a] for y=ax+b type models we use:

[R] One-parameter fitting

2013-07-03 Thread Birdada Simret
Greetings to every body. we know that for linear regression: two-parameter fitting in R: (for a and b as slope and intercept) [a] for y=ax+b type models we use: lm(y~x) [b] for y=axtype models we use: lm(y~0+x) => forced to pass through origin Now I have question: what about y=b fitting

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

2013-07-03 Thread Prof J C Nash (U30A)
If preytype is an independent variable, then models based on it should be OK. If preytype comes into the parameters you are trying to estimate, then the easiest way is often to generate all the possible combinations (integers --> fairly modest number of these) and run all the least squares mini

Re: [R] merge dataframes

2013-07-03 Thread jim holtman
FAQ 7.31 On Wed, Jul 3, 2013 at 7:55 AM, André de Boer wrote: > Hello, > > I have two dataframes: > dat1<-data.frame(x=c(1.0,1.2,3.2,4.0,5.1),y=c(23,17,12,27,8)) > dat2<-data.frame(x=seq(0,6,by=0.1),y=rep(0,60))) > > I want to replace the corresponding rows of dat2 with the ones of dat1. > I tr

[R] merge dataframes

2013-07-03 Thread André de Boer
Hello, I have two dataframes: dat1<-data.frame(x=c(1.0,1.2,3.2,4.0,5.1),y=c(23,17,12,27,8)) dat2<-data.frame(x=seq(0,6,by=0.1),y=rep(0,60))) I want to replace the corresponding rows of dat2 with the ones of dat1. I tried: for(i in 1:nrow(dat1)) { dat2[dat2$x==dat1[i,1],2]<-dat1[i,2] } But I d

[R] nlrq with normal copula

2013-07-03 Thread tong
Dear all, I want to run a nomal copula based quantile regression with XLS data. I've worked out how to load xls data in r. the regression fumula is simply: y= a+bx+e and the quantile curve is I use: > excel.fi

Re: [R] spped up a function

2013-07-03 Thread Jim Holtman
first thing to do when trying to speed up a function is to see where it is spending its time. take a subset of the data and use Rprof to profile the code. my guess is that a lot of time is taken up in the use of dataframes. see if you can use matrices instead. Sent from my iPad On Jul 2, 20

[R] Package PLM

2013-07-03 Thread Eliano Marques
Hi Giovanni and Yves, My is Eliano Marques, i'm a master degree econometrician from ISEG in Portugal. I was trying to use your R package with a specific output i cannot get the same results that i'm getting in Stata. Could you please let me know if the below is correct or if i'm missing anything

[R] MuMIn package: plotting averaged model estimates with CI

2013-07-03 Thread Katarzyna Kulma
Hiya, I'm fairly new to MuMIn (and plotting predicted values in R, for that matter) and I have quite a basic question: I want to plot model-averaged estimates with their 95% CI's for the supported interaction (Infection x ecs). I used the following data: > head(summ12b) ld sum12 Infection

Re: [R] Multinomial model and p-values

2013-07-03 Thread peter dalgaard
On Jul 2, 2013, at 21:21 , Luciano La Sala wrote: > Hello everyone, > > I have a dataset which consists of "Pathology scores" (Absent, Mild, Severe) > as outcome variable, and two main effects: Age (two factors: twenty / thirty > days old) and Treatment Group (four factors: infected without ATB

Re: [R] nth root of matrix

2013-07-03 Thread arun
 sign(a)*abs(a)^(1/3) #  [,1] #[1,] -1.00 #[2,] -1.259921 #[3,] -1.442250 A.K. - Original Message - From: Sachinthaka Abeywardana To: "r-help@r-project.org" Cc: Sent: Tuesday, July 2, 2013 11:11 PM Subject: [R] nth root of matrix Hi all, I want to do the following: a=

Re: [R] Recoding variables based on reference values in data frame

2013-07-03 Thread arun
Hi, May be this helps: Kgeno<- read.table(text=" SNP_ID SNP1 SNP2 SNP3 SNP4 Maj_Allele C G  C  A Min_Allele T A T G  ID1 CC    GG    CT    AA ID2 CC    GG    CC AA ID3 CC    GG nc  AA ID4  _  _  _  _ ID5 CC    GG    CC    AA ID6 CC    GG    CC  AA ID7 CC    GG    CT    AA ID8 _ _ _ _  ID9 CT   

Re: [R] matching similar character strings

2013-07-03 Thread arun
Dear Mario, Not sure if this is what you wanted: F1_ex<- read.table(text="    Nome.azienda;Indirizzo 17;Alterego;Via Edmondo De Amicis, 18 18;Alterego;Via Edmondo De Amicis, 65 ",sep=";",header=TRUE,stringsAsFactors=FALSE) F2_ex<- read.table(text="    CODICE;STRADA;AREADICIRCOLAZIONE;NUMBER1;BARRA