Re: [R] Notational derivative in R

2020-05-15 Thread Jialin Ma
Hi, There is a new package published on CRAN called symengine (I am the maintainer). That might be suitable for your need. Best, Jialin On Thursday, May 14, 2020 2:00:20 PM EDT Jeff Newmiller wrote: > FWIW I have found all such tools to require babysitting... and for > interactive use I prefer

Re: [R] sort

2020-05-15 Thread Rui Barradas
Hello, Here is a dplyr solution. arrange() sorts by name and desc(ddate) and top_n keeps the first 2 after grouping by ddate. Then it's a matter of being careful with diff() in the summarise instruction. library(dplyr) DF1 %>% mutate(ddate = as.Date(ddate)) %>% arrange(name,

[R] Date from text

2020-05-15 Thread Poizot Emmanuel
Dear all, I've a data frame with a column "Date": [1] 11-1993 11-1993 11-1993 11-1993 11-1993 11-1993 11-1996 11-1996 11-1996 [10] 11-1996 11-1996 11-1996 02-1998 02-1998 02-1998 02-1998 02-1998 02-1998 [19] 11-1998 11-1998 11-1998 11-1998 11-1998 11-1998 10-2001 10-2001 10-2001 [28] 10-2001

Re: [R] Date from text

2020-05-15 Thread Enrico Schumann
On Fri, 15 May 2020, Poizot Emmanuel writes: > Dear all, > > I've a data frame with a column "Date": > > [1] 11-1993 11-1993 11-1993 11-1993 11-1993 11-1993 11-1996 11-1996 11-1996 > [10] 11-1996 11-1996 11-1996 02-1998 02-1998 02-1998 02-1998 02-1998 02-1998 > [19] 11-1998 11-1998 11-1998

Re: [R] Notational derivative in R

2020-05-15 Thread Eric Berger
Hi Jialin, I was not aware of symengine. I just did a search and found that you were recognized by the 'John Chambers Statistical Software Award' committee for 2020 for your work on the symengine package. Congratulations! On Fri, May 15, 2020 at 1:34 PM Jialin Ma wrote: > Hi, > > There is a

Re: [R] Date from text

2020-05-15 Thread Marc Schwartz via R-help
Hi, For the usual R text to date conversions, you need a complete date. Since you are missing the day of the month in your source text, you would need to impute that part before making the conversion. Also, since you don't appear to need to worry about time of day, just use as.Date(),

Re: [R] how to extract strings in any column and in any row that start with

2020-05-15 Thread Jeff Newmiller
Read about regular expressions... they are extremely useful. df1 <- tot %>% filter_all(any_vars(grepl( '^E10', .))) It is bad form not to put spaces around the <- assignment. On May 15, 2020 10:00:04 AM PDT, Ana Marija wrote: >Hello, > >I have a data frame: > >> dim(tot) >[1] 502536 1093 >

[R] [R-pkgs] Package "roptions"

2020-05-15 Thread Anurag Agrawal
Thanks all, My package "roptions" is now available on CRAN. My package contains a collection of tools to develop options strategies, value option contracts using the Black-Scholes-Merten option pricing model and calculate the option Greeks. For more information see Hull, John C. "Options, Futures,

[R] how to extract strings in any column and in any row that start with

2020-05-15 Thread Ana Marija
Hello, I have a data frame: > dim(tot) [1] 502536 1093 How would I extract from it all strings that start with E10? I know how to extract all rows that contain with E10 df0<-tot %>% filter_all(any_vars(. %in% c('E10'))) > dim(df0) [1] 5105 1093 but I just need a vector of strings that start

Re: [R] how to extract strings in any column and in any row that start with

2020-05-15 Thread Rui Barradas
Hello, I have tried several options and with large dataframes this one was the fastest (in my tests, of the ones I have tried). s1 <- sapply(tot, function(x) grep('^E10', x, value = TRUE)) Then unlist(s1). A close second (15% slower) was s2 <- tot[sapply(tot, function(x) grepl('^E10',

Re: [R] how to extract strings in any column and in any row that start with

2020-05-15 Thread Abby Spurdle
> How would I extract from it all strings that start with E10? Hi Ana, Here's a simple solution: x <- c ("P24601", "E101", "E102", "3.141593", "E101", "xE101", "e103", " E104 ") x [substring (x, 1, 3) == "E10"] You' will need to replace x with another *character vector*. (As

Re: [R] how to extract strings in any column and in any row that start with

2020-05-15 Thread Ana Marija
Hello, this command was running for more than 2 hours grep("E10",tot,value=T) and no output and this command df1 <- tot %>% filter_all(any_vars(grepl( '^E10', .))) gave me a subset (a data frame) of tot where ^E10 what I need is just a vector or all values in tot which start with E10. Thanks

Re: [R] how to extract strings in any column and in any row that start with

2020-05-15 Thread Jeff Newmiller
If you want to treat your data frame as if it were a vector, then convert it to a vector before you give it to grep. unlist(tot) On May 15, 2020 12:24:17 PM PDT, Ana Marija wrote: >Hello, > >this command was running for more than 2 hours >grep("E10",tot,value=T) >and no output > >and this

Re: [R] how to extract strings in any column and in any row that start with

2020-05-15 Thread cpolwart
This is almost certainly not the most efficient way: tot <- data.frame(v1 = paste0(LETTERS[seq(1:5)],seq(1:10)), v2 = paste0(LETTERS[seq(1:5)],seq(from = 101, to=110, by = 1)), v3 = paste0(LETTERS[seq(1:5)],seq(from = 111, to=120, by = 1)), v4 =

Re: [R] "effects" package with "lme4"

2020-05-15 Thread Fox, John
Dear Axel, There only one fixed effect in the model, ns(Days, 3), so I don't know what you expected. Best, John -- John Fox, Professor Emeritus McMaster University Hamilton, Ontario, Canada Web: socialsciences.mcmaster.ca/jfox/ > -Original

[R] "effects" package with "lme4"

2020-05-15 Thread Axel Urbiz
Hello John and others, I’d appreciate your help as I’m trying to plot the effect of predictor “Days” on Reaction by Subject. I’m only getting one plot in the example below. ### Start example library(lme4) library(splines) data("sleepstudy") fm1 <- lmer(Reaction ~ ns(Days, 3) + (ns(Days, 3) |

Re: [R] "effects" package with "lme4"

2020-05-15 Thread Axel Urbiz
Dear John, Thank you for your response. My apologies as I’m only recently getting exposed to mixed-model. My understanding, is that the model specified below also has random intercepts and slope, as they vary by Subject. `coef(fm1)` shows this. I was looking to plot the fitted splines by

Re: [R] "effects" package with "lme4"

2020-05-15 Thread Fox, John
Dear Axel, > On May 15, 2020, at 7:39 PM, Axel Urbiz wrote: > > Dear John, > > Thank you for your response. > > My apologies as I’m only recently getting exposed to mixed-model. My > understanding, is that the model specified below also has random intercepts > and slope, as they vary by

Re: [R] how to extract strings in any column and in any row that start with

2020-05-15 Thread Ana Marija
Hi Rui, thank you so much that is exactly what I needed! Cheers, Ana On Fri, May 15, 2020 at 5:12 PM Rui Barradas wrote: > > Hello, > > I have tried several options and with large dataframes this one was the > fastest (in my tests, of the ones I have tried). > > > s1 <- sapply(tot, function(x)

[R] addScales package announcement

2020-05-15 Thread Bert Gunter
In case anyone here is interested (this appeared on the r-packages list, but it seems that posts there are no longer forwarded here): addScales is a small package now on CRAN that modifies trellis objects created using lattice graphics by adding horizontal and/or vertical reference lines to

Re: [R] How to find a split point in a curve?

2020-05-15 Thread PIKAL Petr
Hi Maybe I am wrong but it seems to me that it is cumulative data from recent epidemy in some state. If yes, instead of inventing wheel I would go to canned and proved solution using tools from https://www.repidemicsconsortium.org/ I found useful and enlightening this blog especially first part

[R] gdistance::accCost fails on some cases

2020-05-15 Thread Deniz Ugur
Referring to my mail bellow, this situation is not a expected behavior. Do you think that this is because of a fault in my codes or some bug in gdistance? What could be the problem? Thank you for your consideration. -- Forwarded message - From: Deniz Uğur Date: Thu, May 14,