Re: [R] Corrected - R 3.0.2 How to Split-Apply-Combine using various Columns

2014-01-25 Thread Jeff Newmiller
But still wrong... needs to be calculated in two steps because the cars are seen in multiple frames. --- Jeff NewmillerThe . . Go Live... DCN:Basics: ##.#. ##.#. Live G

Re: [R] Corrected - R 3.0.2 How to Split-Apply-Combine using various Columns

2014-01-25 Thread jim holtman
FYI, increased it to 3M rows of data and it took 0.3 seconds to summarize it: > system.time({ + # summarize the slot & Class + result <- DF[ + , list(Total = .N # count of entries + , mVel = mean(velocity) # average velocity + ) + , keyby = 'slot,Class' + ] + }) us

Re: [R] Corrected - R 3.0.2 How to Split-Apply-Combine using various Columns

2014-01-25 Thread jim holtman
Here is another way of doing it using the data.table package. Tried using new new 'dplyr' package, but it had problems. > # create some test data > N <- 3 # rows of data > set.seed(1) > DF <- data.frame(vehicle = sample(1:5, N, TRUE) + , frame = sample(22:9322, N, TRUE) +

[R] Packaging - Function with dots as argument

2014-01-25 Thread Eva Prieto Castro
Hi everybody, I am writing the .Rd files of my pckage, and I have a doubt in relation with the Rd file of a function that has dots as unique argument. I mean the following: g <- function(a,b) a + b f <- function( ... ) g(...) Imagine I have the Rd file of "f" function. The "usage" is as follo

Re: [R] R dataframe question

2014-01-25 Thread arun
Hi, dat1 <- read.table(text="X1 1,1 1,2 1,3 2,1 2,2 2,3 3,1 3,2 3,3",sep="",header=TRUE)  dat2 <- setNames(as.data.frame(matrix(dat1[,1],3,3)),paste0("X",1:3)) str(dat2) #'data.frame':    3 obs. of  3 variables: # $ X1: Factor w/ 3 levels "1,1","1,2","1,3": 1 2 3 # $ X2: Factor w/ 3 levels "2,1",

[R] Regression of complex-valued functions

2014-01-25 Thread Andrea Graziani
Hi, I tried to use nls() to fit a complex-valued (non linear) function that looks like this: y = A + B / (1 + C * (i*x*D)^E) where x is the real-valued independent variable, A,B,C,D,E are real-valued parameters and i is the imaginary unit. I had the followin error (my translation into englis

[R] Not sure if I have the requirement right.

2014-01-25 Thread F. Keshavarz
Hi I submited the rankhospital project. All parts were correct except part 2. I checked the outcome and it looks correct. I am afraid I am misunderstanding the requirement. Please let me know why the outcome is not correct. *THE OUTCOMEMy test* > source("rankhospital.R") > d<-rankhospital("WA","

Re: [R] R dataframe question

2014-01-25 Thread arun
Hi, The question is not clear. set.seed(45)  spe <- data.frame(Col1=sample(c(1:10,letters[1:2]),400,replace=TRUE))  mat1 <- matrix(spe[,1],nrow=20,ncol=20) #If you want to replace the non-numeric values with NAs,  mat2 <- matrix(as.numeric(as.character(spe[,1])),nrow=20,ncol=20) A.K. Hell

Re: [R] keep track of variables created in each chapter of a knitr book

2014-01-25 Thread William Dunlap
You could also use a new environment for each chapter e1 <- new.env() with(e1, A <- c(1,2,3)) # or, if you prefer, e1$A <- c(1,2,3) However, you may want to also reload packages at the start of each chapter (I think this makes it more reader-friendly), so perhaps you should restart R for each

Re: [R] Corrected - R 3.0.2 How to Split-Apply-Combine using various Columns

2014-01-25 Thread Jeff Newmiller
Sorry, messed up the second ddply example: dta3 <- ddply( dta2, c("slot","classf"), function(DF){data.frame( Total=nrow(DF), MeanVelocity= mean( DF$TimeMeanVelocity ) ) } ) --- Jeff NewmillerThe .

Re: [R] Corrected - R 3.0.2 How to Split-Apply-Combine using various Columns

2014-01-25 Thread Jeff Newmiller
While you seem to be making some progress in communicating your problem, the format is still HTML (so it is a mess) and the subject and approach of the question are still a poor fit for this list. We are not here to DO your work for you, yet you seem to have an overly long list of "needs" that s

Re: [R] Corrected - R 3.0.2 How to Split-Apply-Combine using various Columns

2014-01-25 Thread Bert Gunter
Just curious -- why do you continue to post in HTML when you have been asked not to? Cheers, Bert Bert Gunter Genentech Nonclinical Biostatistics (650) 467-7374 "Data is not information. Information is not knowledge. And knowledge is certainly not wisdom." H. Gilbert Welch On Sat, Jan 25, 20

[R] Corrected - R 3.0.2 How to Split-Apply-Combine using various Columns

2014-01-25 Thread umair durrani
Hello everyone,Here is the version using dput. I am sorry for the junk I posted before. I have a large vehicle trajectory data of which following is a small part: structure(list(vehicle = c(1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L,2L, 2L), frame = c(221L, 222L, 223L, 224L, 115L, 116L, 117L, 118L, 11

Re: [R] Regression on presence/absence matrix

2014-01-25 Thread Ben Bolker
[I don't know whether you cc'd this to r-help or not, I'm cc'ing this back] Without more context it's hard to say very much, and you might be better off on the r-sig-ecol...@r-project.org list , or on CrossValidated (http://stats.stackexchange.com), rather than the general r-help list (this i

Re: [R] keep track of variables created in each chapter of a knitr book

2014-01-25 Thread Rainer Schuermann
You could initialize one list per chapter, > x1 <- list( "Chapter One" ) and then crate your variables as list members > x1$A <- c( 1, 2, 3 ) > x1$B <- "bla" > x1$tv.data <- data.frame( m = sample( LETTERS, 5 ), n = round( runif( 5 ), 2 ) ) > x1 [[1]] [1] "Chapter O

Re: [R] RSA and lmer

2014-01-25 Thread Ben Bolker
Pablo Ignacio Escribano Pinto gmail.com> writes: > > Hi all! > I am currently working on a paper where I conduct a > surface analysis based on subordinate and supervisor responses. > So far I have been using the RSA package and it works great. > However, because several subordinates share a com

Re: [R] Regression on presence/absence matrix

2014-01-25 Thread Ben Bolker
Daniel Patón Domínguez gmail.com> writes: > > > The library of packages that installs with R includes the stats > > package, in the stats package is the glm function for fitting > > generalized linear models. Using glm with a binomial family will fit > > a logistic regression which can be used

[R] gam(mgcv) predicting across random effect and understanding narrow CI

2014-01-25 Thread Anna Hargreaves
Hi everyone, I am new to additive modelling and am surprised by the results of a model I'm working on. I wanted to check with more experienced users to make sure I'm not misunderstanding something basic. *Data:* I have 10 replicated runs from an evolutionary simulation model, measuring the evolv

[R] R 3.0.2 How to Split-Apply-Combine using various Columns

2014-01-25 Thread umair durrani
I am sorry for the previous mail, it happened due to the tables I copied into mail. Here is the text version:Hello everyone, I have a large vehicle trajectory data of which following is a small part: vehicle frame globalx class velocity lane1 221 6451260 223.37 51

Re: [R] testing if xts date exists ?

2014-01-25 Thread arun
!length(SPY["2009-01-18"]) #[1] TRUE   !length(SPY["2009-01-16"]) #[1] FALSE #or  !nrow(SPY["2009-01-16"]) A.K. On Saturday, January 25, 2014 10:27 AM, ce wrote: Dear all How to test if xts date exists ? is.null doesn't work.  SPY["2009-01-18"] doesn't exist but I can't catch it in my scri

[R] testing if xts date exists ?

2014-01-25 Thread ce
Dear all How to test if xts date exists ? is.null doesn't work. SPY["2009-01-18"] doesn't exist but I can't catch it in my script. library(quantmod) getSymbols("SPY") > SPY["2009-01-16"] SPY.Open SPY.High SPY.Low SPY.Close SPY.Volume SPY.Adjusted 2009-01-1685.8685.99 83.

Re: [R] Safe prediction does not work for bivariate polynomial terms?

2014-01-25 Thread John Fox
Dear Brian and Xing, Sandy Weisberg and I coincidentally encountered this issue yesterday, and I intended to send a message about it to the r-help list. We thought initially that the functions we were working on were bugged, but eventually discovered that polym() wasn't saving basis information

Re: [R] How to read this data correctly

2014-01-25 Thread jim holtman
Try XLConnect. It seems to read the data in just fine. Did have to create a named region, otherwise it would just read in the area that had data. > require(XLConnect) > wb <- loadWorkbook("C:\\Users\\Owner\\Downloads\\Book1 (1).xlsx") > x <- readWorksheet(wb, 1, header = FALSE) # without region

Re: [R] add median/mean line to stri-plot in lattice

2014-01-25 Thread Duncan Mackay
Hi Luigi If you create a numeric variable of 1:5 to correspond as the x's - Normal, Borderline, . You could then plot the points as an xyplot -xyplot gives you more flexibility to do things. then add the lines as segments in a panel function Use scales for the labels as scales = list(x = l

Re: [R] Regression on presence/absence matrix

2014-01-25 Thread Daniel Patón Domínguez
> The library of packages that installs with R includes the stats > package, in the stats package is the glm function for fitting > generalized linear models. Using glm with a binomial family will fit > a logistic regression which can be used as you describe. > > If you really feel the need to us

[R] definite matrix

2014-01-25 Thread IZHAK shabsogh
kindly help and guide me how i can correct this code, my target is to find x1,x2,x3 but when the matrix is positive definite i do get the solution correctly as you can see from the code but when the matrix is indefinite we dont get the solution  . i want know how i can correct this problem if th