Re: [R] Creating NA equivalent

2021-12-20 Thread Bert Gunter
Beyond known limits are left/right censored data. You need to use statistical methodology that handles censoring. See the survival package and the CRAN Survival task view for this -- or consult an appropriate expert. There are of course standard ways of annotating such data in these packages. Bert

[R] Creating NA equivalent

2021-12-20 Thread Marc Girondot via R-help
Dear members, I work about dosage and some values are bellow the detection limit. I would like create new "numbers" like LDL (to represent lower than detection limit) and UDL (upper the detection limit) that behave like NA, with the possibility to test them using for example is.LDL() or is.UD

Re: [R] Sum every n (4) observations by group

2021-12-20 Thread Rasmus Liland
Dear Miluji, I went through different combinations, and find it elegant to sum the values with respect to ID + High/Low Date levels like if this was a list of Dose/Material/Group experiments: x[x$Date %in% c(4143, 4147),"j"] <- tapply(x$Value, paste0(x$ID, ife

Re: [R] Adding SORT to UNIQUE

2021-12-20 Thread Rui Barradas
Hello, Inline. Às 21:18 de 20/12/21, Stephen H. Dawson, DSL via R-help escreveu: Thanks. sort(unique(Data[[1]])) This syntax provides row numbers, not column values. This is not right. The syntax Data[1] extracts a sub-data.frame, the syntax Data[[1]] extracts the column vector. As for m

Re: [R] Adding SORT to UNIQUE

2021-12-20 Thread Avi Gross via R-help
Duncan and Martin and ..., There are multiple groups where people discuss R and this seems to be a help group. The topic keeps coming up as to whether you should teach anything other than base R and I claim it depends. Many packages are indeed written mostly using base R or using other package

Re: [R] Adding SORT to UNIQUE

2021-12-20 Thread Stephen H. Dawson, DSL via R-help
Thanks for the reply. sort(unique(Data[1])) Error in `[.data.frame`(x, order(x, na.last = na.last, decreasing = decreasing)) :   undefined columns selected The recommended syntax did not work, as listed above. *Stephen Dawson, DSL* /Executive Strategy Consultant/ Business & Technology +1 (86

Re: [R] Adding SORT to UNIQUE

2021-12-20 Thread Stephen H. Dawson, DSL via R-help
Thanks. sort(unique(Data[[1]])) This syntax provides row numbers, not column values. *Stephen Dawson, DSL* /Executive Strategy Consultant/ Business & Technology +1 (865) 804-3454 http://www.shdawson.com On 12/20/21 11:58 AM, Stephen H. Dawson, DSL via R-help wrote:

Re: [R] Adding SORT to UNIQUE

2021-12-20 Thread Stephen H. Dawson, DSL via R-help
Thanks for the reply. sort(unique(Data[1])) Error in `[.data.frame`(x, order(x, na.last = na.last, decreasing = decreasing)) :   undefined columns selected The recommended syntax did not work, as listed above. *Stephen Dawson, DSL* /Executive Strategy Consultant/ Business & Technology +1 (865

Re: [R] Bug in list.files(full.names=T)

2021-12-20 Thread Andrew Simmons
I've tried a bunch of different R versions, I can't seem to replicate what you described. Here's the code I used: R.pattern <- paste0("^R-", .standard_regexps()$valid_R_system_version, "$") x <- list.files(dirname(R.home()), pattern = R.pattern, full.names = TRUE) x <- x[file.info(x, extra_cols =

Re: [R] Adding SORT to UNIQUE

2021-12-20 Thread Bert Gunter
Martin: I think the issue is this: > sort(c('a10','a1','a3')) [1] "a1" "a10" "a3" > ## wanted 'a1', 'a3', 'a10' ?? The OP would have to confirm, of course. If he only wanted to sort just numerics, coercing to numeric first would presumably handle it. For situations like the above, one probably n

Re: [R] Adding SORT to UNIQUE

2021-12-20 Thread Jeff Newmiller
Er, I suppose what was wrong was the absence of unique... as.data.frame( lapply( dta, function(v) sort( unique( v, decreasing = TRUE ) ) ) ) I do think "better" involves value judgements as to whether using one of many specialized tools (tidyverse model) is better or worse than using a sequence

Re: [R] Bug in list.files(full.names=T)

2021-12-20 Thread Bill Dunlap
> grep(value=TRUE, invert=TRUE, "$", strsplit(Sys.getenv("PATH"), ";")[[1]]) [1] "C:\\rtools40\\usr\\bin" [2] "C:\\Program Files (x86)\\Common Files\\Oracle\\Java\\javapath" [3] "C:\\Program Files\\ImageMagick-7.0.11-Q16-HDRI" [4] "C:\\WINDOWS\\system32" [5] "C:\\WINDOWS" [6] "C:\\WINDOWS

Re: [R] Adding SORT to UNIQUE

2021-12-20 Thread Duncan Murdoch
On 20/12/2021 12:32 p.m., Martin Maechler wrote: Rui Barradas on Mon, 20 Dec 2021 17:05:33 + writes: > Hello, > Package stringr has functions str_sort and str_order, both with an > argument 'numeric' that will sort the numbers correctly. > Maybe that's what you are

Re: [R] Adding SORT to UNIQUE

2021-12-20 Thread Avi Gross via R-help
Stephen, Sorry about that. I tried modifying what you had and realize the use of [] returned a data.frame and you need [[]] to return a vector. Try this: sort(unique(Data[[1]])) From: Stephen H. Dawson, DSL Sent: Monday, December 20, 2021 12:32 PM To: Avi Gross ; r-help@r-proj

Re: [R] Adding SORT to UNIQUE

2021-12-20 Thread Martin Maechler
> Rui Barradas > on Mon, 20 Dec 2021 17:05:33 + writes: > Hello, > Package stringr has functions str_sort and str_order, both with an > argument 'numeric' that will sort the numbers correctly. > Maybe that's what you are looking for, see the example below. >

Re: [R] Bug in list.files(full.names=T)

2021-12-20 Thread Martin Maechler
> Bill Dunlap > on Mon, 20 Dec 2021 08:40:04 -0800 writes: >> >> > Why would one ever *add* a final unneeded path separator, >> > unless one wanted it? >> > Good question, but it is common for Windows installer programs to add a > terminal backslash to PATH

Re: [R] Adding SORT to UNIQUE

2021-12-20 Thread Jeff Newmiller
What is wrong with as.data.frame(lapply( Data, sort, decreasing = TRUE )) ? On December 20, 2021 8:58:48 AM PST, "Stephen H. Dawson, DSL via R-help" wrote: >Hi, > > >Running a simple syntax set to review entries in dataframe columns. Here >is the working code. > >Data <- read.csv("./input/So

Re: [R] Adding SORT to UNIQUE

2021-12-20 Thread Avi Gross via R-help
Stephen, You can sort using sort() either before or after doing a unique. Unique removes all duplicates in any order so sorting before may be wasteful. in your data shown below, do this: sort(unique(Data[1])) sort(unique(Data[2])) sort(unique(Data[3])) sort(unique(Data[4])) Even simpler is to de

Re: [R] Adding SORT to UNIQUE

2021-12-20 Thread Rui Barradas
Hello, Package stringr has functions str_sort and str_order, both with an argument 'numeric' that will sort the numbers correctly. Maybe that's what you are looking for, see the example below. x <- sample(sprintf("ab%d", 1:20)) # shuffle the vector stringr::str_sort(x, numeric = TRUE) #

[R] Adding SORT to UNIQUE

2021-12-20 Thread Stephen H. Dawson, DSL via R-help
Hi, Running a simple syntax set to review entries in dataframe columns. Here is the working code. Data <- read.csv("./input/Source.csv", header=T) describe(Data) summary(Data) unique(Data[1]) unique(Data[2]) unique(Data[3]) unique(Data[4]) I would like to add sort the unique entries. The dat

Re: [R] Bug in list.files(full.names=T)

2021-12-20 Thread Bill Dunlap
> > > Why would one ever *add* a final unneeded path separator, > > unless one wanted it? > Good question, but it is common for Windows installer programs to add a terminal backslash to PATH entries. E.g., on my Windows laptop I get > grep(value=TRUE, "$", strsplit(Sys.getenv("PATH")

Re: [R] Bug in list.files(full.names=T)

2021-12-20 Thread Jorgen Harmse via R-help
There is a possibly related problem in file.path. As Murdoch says, it's ugly even if the OS accepts it, and I don't see that the base version is any better than paste(sep=fsep, ...). Pasting the result into emacs wouldn't work. I wrote my own version to remove trailing fsep from all but the last

Re: [R] Bug in list.files(full.names=T)

2021-12-20 Thread Martin Maechler
> Martin Maechler > on Mon, 20 Dec 2021 09:46:23 +0100 writes: > Mario Reutter > on Sat, 18 Dec 2021 15:55:37 +0100 writes: >> Dear everybody, >> I'm a researcher in the field of psychology and a >> passionate R user. After having updated to the newest >

[R] Call for proposals to organize useR! 2023 as a hybrid conference

2021-12-20 Thread Martin Maechler
Dear All, The R Foundation Conference Committee invites proposals to organize useR! 2023 as a hybrid conference: https://www.r-project.org/conferences/useR_2023_call.html The call is open to hosts worldwide and the deadline for outline proposals is **Friday 28 January 2022**. Any queries s

Re: [R] Sum every n (4) observations by group

2021-12-20 Thread Leonard Mada via R-help
Dear Miluji, something like this could help: sapply(tapply(x$Value, x$ID, cumsum),     function(x) x[seq(4, length(x), by=4)] - c(0, x[head(seq(4, length(x), by=4), -1)])) 1.) Step 1: Compute the cumsum for each ID: tapply(x$Value, x$ID, cumsum) 2.) Step 2: - iterate over the resulting

Re: [R] help with LDA topic modelling..

2021-12-20 Thread akshay kulkarni
Thanks a lot From: Jim Lemon Sent: Monday, December 20, 2021 1:43 PM To: akshay kulkarni Cc: R help Mailing list Subject: Re: [R] help with LDA topic modelling.. Hi Akshay, It depends upon how the circles are calculated. If each circle encloses all of the member

Re: [R] Bug in list.files(full.names=T)

2021-12-20 Thread Martin Maechler
> Mario Reutter > on Sat, 18 Dec 2021 15:55:37 +0100 writes: > Dear everybody, > I'm a researcher in the field of psychology and a > passionate R user. After having updated to the newest > version, I experienced a problem with list.files() if the > parameter full.

Re: [R] help with LDA topic modelling..

2021-12-20 Thread Jim Lemon
Hi Akshay, It depends upon how the circles are calculated. If each circle encloses all of the members of each group, yes. I doubt you would get perfect separation in any real example, though. At the moment: Hanukkah is finished, Margashirsha Punima has just happened and Christmas is coming up. No m