Re: [R] Extracting part of a factor

2016-03-04 Thread Ista Zahn
I guess this thread has gone on long enough, but I haven't seen anyone yet suggest what to me seems like the obvious thing if you want to do this with mutate, namely testdata <- mutate(testdata, place = as.factor(substr(subject, 1, 3))) Best, Ista On Fri, Mar 4, 2016 at 10:45 PM, Boris Steipe

Re: [R] Extracting part of a factor

2016-03-04 Thread Boris Steipe
You mean this? test$place <- factor(test$place) You can create a new column in a data frame by assigning something to it. E.g. test$pollywog <- 1:6 ... creates that column in "test". But factor(test$place) was empty, because no such column previously existed, like: R >

Re: [R] Extracting part of a factor

2016-03-04 Thread Boris Steipe
LOL you still need to assign it though: test <- mutate(test, place = factor(substr(test$subject,1,3))) str(test) 'data.frame': 6 obs. of 7 variables: $ subject: Factor w/ 6 levels "001-002","002-003",..: 1 2 3 4 5 6 $ group : Factor w/ 2 levels "boys","girls": 1 1 1 2 2 2 $ wk1: int

Re: [R] Extracting part of a factor

2016-03-04 Thread KMNanus
Here’s where I’m stumped - when I call mutate(test, place = substr(test$subject, 1,3)) to create a place variable, I get this, with place as a character variable. subject group wk1 wk2 wk3 wk4 place (fctr) (fctr) (int) (int) (int) (int) (chr) 1 001-002 boys 2 3 4

Re: [R] Extracting part of a factor

2016-03-04 Thread KMNanus
Here’s the dataset I’m working with, called test - subject group wk1 wk2 wk3 wk4 place 001-002 boys2 3 4 5 002-003 boys7 6 5 4 003-004 boys9 4 6 1 004-005 girls 5 7 8 9

Re: [R-es] Representar datos longitudinales mediante splines

2016-03-04 Thread Carlos Ortega
Hola, Claro, es que con "lowes()" para la cantidad tan pequeña de datos que tienes para cada clase, no tiene mucho sentido la interpolación local que realiza "lowess" teniendo en cuenta los puntos próximos. Fíjate que si no diferencias entre las clases de cada punto, sí que "lowess()" interpola:

Re: [R] Extracting part of a factor

2016-03-04 Thread Jeff Newmiller
This is not a problem with factor or as.factor, this is a problem with your use of the dplyr package or with bugs in that package. Please make a reproducible example, making sure to use the dput function to create the code that initializes the data so we can run your code. Read the Posting

Re: [R] Extracting part of a factor

2016-03-04 Thread Sarah Goslee
You're not saving the result of mutate(). You're just printing it to the screen. Try instead: test <- mutate(testdata, place = substr(testdata$subject, 1,3)) test$place <- as.factor(test$place) # or factor() if you'd rather This is why we ask for reproducible examples with data and code. Look

Re: [R] Extracting part of a factor

2016-03-04 Thread Jeff Newmiller
I much prefer the factor function over the as.factor function for converting character to factor, since you can set the levels in the order you want them to be. -- Sent from my phone. Please excuse my brevity. On March 4, 2016 10:07:27 AM PST, Sarah Goslee wrote: >As

Re: [R] Extracting part of a factor

2016-03-04 Thread Sarah Goslee
As everyone has been telling you, as.factor(). If you like the mutate approach, you can call as.factor(test$subject) to convert it. Here's a one-liner with reproducible data. testdata <- structure(list(subject = structure(1:6, .Label = c("001-002", "002-003", "003-004", "004-005", "005-006",

Re: [R] help in maximum likelihood

2016-03-04 Thread Ravi Varadhan
Standard error = sqrt(diag(solve(opt$hessian))) Ravi From: Alaa Sindi [mailto:alaasi...@icloud.com] Sent: Wednesday, March 02, 2016 3:22 PM To: Ravi Varadhan Cc: r-help@r-project.org Subject: Re: help in maximum likelihood Thank you very much prof. Ravi, That was very

Re: [R] Extracting part of a factor

2016-03-04 Thread Sarah Goslee
Hi Ken, You do that with as.factor(), as has already been suggested. You'll need to provide a reproducible example to show us what's going wrong. Using fake data is fine, we just need to see some data that look like yours and the code you're using. Sarah On Fri, Mar 4, 2016 at 11:57 AM, KMNanus

Re: [R] Extracting part of a factor

2016-03-04 Thread KMNanus
Let me see if I can ask the question more clearly - I am trying to extract a section of a hyphenated factor. For example, 001-004 is one observation of test$ken, which is a factor, and I want to set up a new factor variable called place that would have 001 as an observation. If I call

Re: [R] difference between successive values

2016-03-04 Thread catalin roibu
I mean the first row value În Vin, 4 mar. 2016, 16:15 Jeff Newmiller, a scris: > "Keep the first values" is imprecise, but mixing an absolute value with a > bunch of differences doesn't usually work out well. I frequently choose > among > > x <- sample( 10 ) > dxright

Re: [R] difference between successive values

2016-03-04 Thread Jeff Newmiller
"Keep the first values" is imprecise, but mixing an absolute value with a bunch of differences doesn't usually work out well. I frequently choose among x <- sample( 10 ) dxright <- c( 0, diff(x) ) dxleft <- c( diff(x), 0 ) for calculation purposes depending on my needs. -- Sent from my

Re: [R-es] Representar datos longitudinales mediante splines

2016-03-04 Thread Olivier Nuñez
Prueba esto: ggplot(df,aes(x,x,y=y,color=id))+geom_smooth(method="gam")+geom_point() Un saludo. Olivier - Mensaje original - De: "Francisco Javier" Para: r-help-es@r-project.org Enviados: Jueves, 3 de Marzo 2016 21:35:57 Asunto: [R-es] Representar datos

[R] [R-pkgs] New package: DataExplorer

2016-03-04 Thread Boxuan Cui
Dear useRs, I am really excited that my first package is now on CRAN: https://cran.r-project.org/web/packages/DataExplorer/. The package aims to simplify the data exploration process before your data analysis and/or model building process. Example use case: One day, you get a random dataset

Re: [R] difference between successive values

2016-03-04 Thread Olivier Crouzet
Hi, (1) You should provide a minimal working example; (2) But anyway, does... x = sample(10) c(x[1],diff(x)) ... do what you want? Olivier. On Fri, 4 Mar 2016 13:22:07 +0200 catalin roibu wrote: > Dear all! > > I want to calculate difference between successive

[R] difference between successive values

2016-03-04 Thread catalin roibu
Dear all! I want to calculate difference between successive values (cumulative values) with R. I used diff function, but I want to keep the first values. Please help me to solve this problem! Thank you! Best regards! CR -- - - Catalin-Constantin ROIBU ​ Lecturer PhD, Forestry engineer

[R-es] Suscripcion a ayudas en español (Tony Castillo)

2016-03-04 Thread Pedro Concejero Cerezo
(sin acentos totalmente aposta, a pesar de que me raya poner "ingles", algun dia lo solucionare) Hola, Tony, puedes ser mas concreto sobre las ayudas que necesitas? En el portal r-es.org mantenemos una lista de cursos y material de formacion en castellano e ingles que te puede valer:

Re: [R] ALLOCATE in a FORTRAN subroutine

2016-03-04 Thread Berend Hasselman
> On 4 Mar 2016, at 08:51, MAURICE Jean - externe > wrote: > > Hi Berend, > > >> The question belongs on the R-devel mailinglist. > I try to find this mailing-list ... > See https://www.r-project.org/mail.html >> You are calling your Fortran routines directly