Re: [R] How to average minutes per hour per month in the form of '# hours #minutes'

2021-03-26 Thread Jeff Newmiller
Avi, I see no limitations in using R for this task, so throwing Python into the discussion seems only to confuse the issue. I just see multiple ways to interpret the desired calculation of the result, as illustrated by your discussion and elaborated in my next paragraph, and I would rather the

Re: [R] local maxima positions in a vector with duplicated values

2021-03-26 Thread Abby Spurdle
Hi Stefano, My package, vectools, is partly designed for this purpose. (Unfortunately, the package *is* subject to *change*, and some of the functions may change in the next update). library (vectools) which.maxs (x, ret.type="intervals")[,1] # c (8, 10, 13) which.mins (x,

Re: [R] How to average minutes per hour per month in the form of '# hours #minutes'

2021-03-26 Thread Avi Gross via R-help
There are rather straightforward ways to manipulate your data step by step to make harder things possible, or you can use creative ways harder for people to understand. So adding columns to your data that take existing times/dates and record them with names like Q1Y2021 can give you abilities

[R] [R-pkgs] gm: create music & generate scores and audios in R Markdown, Jupyter Notebooks

2021-03-26 Thread Renfei Mao
Dear all, I am happy to announce that gm 1.0.0 is released on CRAN. https://CRAN.R-project.org/package=gm gm provides an elegant and intuitive language, with which you can create music algorithmically. gm converts your description of music to musical

[R-es] Media de los valores de una lista

2021-03-26 Thread Manuel Mendoza
Muy buenas, tengo una matriz (probs) de 100 x 2, que son probabilidades. > head(probs, 3) 1 2 [1,] 0.8282016 0.1717984 [2,] 0.1288460 0.8711540 [3,] 0.8830735 0.1169265 A partir de ella obtengo un vector de 100 elementos que incluye el valor máximo de los dos.

[R-es] (sin asunto)

2021-03-26 Thread Manuel Mendoza
Muy buenas, tengo una matriz (probs) de 100 x 2, que son probabilidades. > head(probs, 3) 1 2 [1,] 0.8282016 0.1717984 [2,] 0.1288460 0.8711540 [3,] 0.8830735 0.1169265 A partir de ella obtengo un vector de 100 elementos que incluye el valor máximo de los dos.

Re: [R] Shapes of the districts of Brandenburg

2021-03-26 Thread Bert Gunter
There is a specific help list devoted to geography and mapping related issues that may be a better place to post this: r-sig-geo Cheers, Bert Gunter "The trouble with having an open mind is that people keep coming along and sticking things into it." -- Opus (aka Berkeley Breathed in his "Bloom

[R] Shapes of the districts of Brandenburg

2021-03-26 Thread Ferri Leberl
Dear ∀, I have today done tentative steps in the use of the cartogram packages, trying the examples on page https://www.rdocumentation.org/packages/cartogram/versions/0.2.2 Can anybody tell me how to adapt the examples to the districts of Brandenburg? I know the population data relevant to my

Re: [R] local maxima positions in a vector with duplicated values

2021-03-26 Thread Bert Gunter
WARNING: I have not carefully tested the following, so you will need to do so before using. Like Bill, I found rle a clearer approach. Here's my (not so elegant, probably) version: > x <-c(1,0,0,0,2,2,3,4,0,1,1,0,5,5,5,0,1) > z <- rle(x) > vals <- z$values > n <- length(vals) >

Re: [R] local maxima positions in a vector with duplicated values

2021-03-26 Thread Bill Dunlap
Using rle() may make it easier - finding the peak values is easier and select from cumsum(lengths) to get the positions of the last values before the peaks, then add 1. I have not tested the following very much. function(x) { rx <- rle(x) cumsum(rx$lengths)[c(diff(diff(rx$values)>0) ==

Re: [R] dplyr: summarise across using variable names and a condition

2021-03-26 Thread Rui Barradas
Hello, Here is a way of doing what the question asks for. There might be others, simpler, but this one works. have %>% summarise(across( .cols = !contains("ptno"), .fns = list(mean = mean, std = sd), .names = "{col}_{fn}" )) %>% select( -matches("^gender_.*_std$"),

[R] local maxima positions in a vector with duplicated values

2021-03-26 Thread Stefano Sofia
Dear list users, I need to find local maxima and local minima positions in a vector where there might be duplicates; in the particular in case of - duplicated local maxima, I should take the position of the first duplicated value; - duplicated local minima, I should take the position of the last

[R] dplyr: summarise across using variable names and a condition

2021-03-26 Thread Paul Miller via R-help
Hello All, Would like to be able to summarize across in dplyr using variable names and a condition. Below is an example "have" data set followed by an example "need" data set. After that, I've got a vector of numeric variable names. After that, I've got the very humble beginnings of a

Re: [R-es] poner un código en Internet

2021-03-26 Thread Francisco Rodriguez Sanchez
Buenos días Manuel, Hasta donde yo sé, pastebin no garantiza que ese código quede archivado y público de manera permanente (https://pastebin.com/faq#18). Tampoco GitHub, GitLab, etc. Si es un artículo científico, lo deseable es que cualquiera pueda acceder a ese código dentro de 1, 5, ó 10

Re: [R] How to average minutes per hour per month in the form of '# hours #minutes'

2021-03-26 Thread Jim Lemon
Hi, As you still seem to be asking for an answer, the following code may help. # begin with a minimal data frame patdb<-data.frame(patno=paste0("p",sample(100:300,200,TRUE)), date=c(paste(2020,11,sort(sample(1:31,66,TRUE)),sep="-"), paste(2020,12,sort(sample(1:31,67,TRUE)),sep="-"),

Re: [R] Off topic --- underdispersed (pseudo) binomial data.

2021-03-26 Thread Duncan Murdoch
On 25/03/2021 10:25 p.m., Rolf Turner wrote: On Fri, 26 Mar 2021 13:41:00 +1300 Abby Spurdle wrote: I haven't checked this, but I guess that the number of students that *pass* a particular exam/subject, per semester would be like that. e.g. Let's say you have a course in maximum likelihood,

Re: [R] How to average minutes per hour per month in the form of '# hours #minutes'

2021-03-26 Thread Dr Eberhard W Lisse
Jeff, thank you. However, if I knew how to do this, I would probably not have asked :-)-O I think I have been reasonably comprehensive in describing my issue, but let me do it now with the real life problem: My malpractice insurance gives me a discount if I consult up to 22 hours per week in a