[R] glm package - Negative binomial regression model - Error

2018-02-25 Thread Paula Couto
HI there I am running this model in negative binomial regression, using glm. I had no problems with running the model with a set of data, but now that i'm trying to run if for new one. I always have this same error when running the regression: > > #Run Regression > x=cbind(factor2ind(d$year)

[R] Precision in R

2018-02-25 Thread Iuri Gavronski
Hi, Why sum() on a 10-item vector produces a different value than its counterpart on a 2-item vector? I understand the problems related to the arithmetic precision in storing decimal numbers in binary format, but shouldn't the errors be equal regardless of the method used? See my example: > opti

Re: [R] reshaping column items into rows per unique ID

2018-02-25 Thread Jim Lemon
Hi Allaisone, If you want a data frame as the output you will have to put up with a few NA values unless each Customer has the same number of diet types: a1df<-read.table(text="CustomerIDDietType 1 a 1c 1b 2

Re: [R] include

2018-02-25 Thread Val
Thank you all for your help and sorry for that. On Sun, Feb 25, 2018 at 12:18 PM, Jeff Newmiller wrote: > Jim has been exceedingly patient (and may well continue to be so), but > this smells like "failure to launch". At what point will you start showing > your (failed) attempts at solving your o

Re: [R] reshaping column items into rows per unique ID

2018-02-25 Thread peter dalgaard
It depends quite strongly on what you want to do with the result, but I wonder if what is really needed might be a list of diettypes per person, i.e. continuing from Eric's code > On 25 Feb 2018, at 18:56 , Eric Berger wrote: > > Hi Allaisone, > I took a slightly different approach but you mig

Re: [R] include

2018-02-25 Thread Jeff Newmiller
Jim has been exceedingly patient (and may well continue to be so), but this smells like "failure to launch". At what point will you start showing your (failed) attempts at solving your own problems so we can help you work on your specific weaknesses and become self-sufficient? -- Sent from my p

Re: [R] reshaping column items into rows per unique ID

2018-02-25 Thread Eric Berger
Hi Allaisone, I took a slightly different approach but you might find this either as or more useful than your approach, or at least a start on the path to a solution you need. df1 <- data.frame(CustId=c(1,1,1,2,3,3,4,4,4),DietType=c("a","c","b","f","a","j","c","c","f"), strin

Re: [R] reshaping column items into rows per unique ID

2018-02-25 Thread Bert Gunter
I believe you need to spend time with an R tutorial or two: a data frame (presumably the "table" data structure you describe) can *not* contain "blanks" -- all columns must be the same length, which means NA's are filled in as needed. Also, 8e^5 * 7e^4 = 5.6e^10, which almost certainly will not fi

Re: [R] How to Save the residuals of an LM object greater or less than a certin value to an R object?

2018-02-25 Thread Alberto Garre
Hi Peter, the "residuals()" function returns the residuals of a model fitted using the "lm" function. For instances, using the example included in the help of lm: ctl <- c(4.17,5.58,5.18,6.11,4.50,4.61,5.17,4.53,5.33,5.14) trt <- c(4.81,4.17,4.41,3.59,5.87,3.83,6.03,4.89,4.32,4.69) group <- gl(2

Re: [R] include

2018-02-25 Thread Val
HI Jim and all, I want to put one more condition. Include col2 and col3 if they are not in col1. Here is the data mydat <- read.table(textConnection("Col1 Col2 col3 K2 X1 NA Z1 K1 K2 Z2 NA NA Z3 X1 NA Z4 Y1 W1"),header = TRUE,stringsAsFactors=FALSE) The desired out put would be Col1 Col2 co