Re: [R] problem: try to passing macro value into submit block

2021-12-21 Thread David Winsemius
On 12/21/21 6:00 PM, Kai Yang via R-help wrote: Hi team,I'm trying to pass macro variable into R script in Proc iml. I want to do change variable in color= and export the result with different file name.If I don't use macro, the code work well. But when I try to use macro below, I got error

[R] problem: try to passing macro value into submit block

2021-12-21 Thread Kai Yang via R-help
Hi team,I'm trying to pass macro variable into R script in Proc iml. I want to do change variable in color= and export the result with different file name.If I don't use macro, the code work well. But when I try to use macro below, I got error message: "Submit block cannot be directly placed in

Re: [R] Creating NA equivalent

2021-12-21 Thread Avi Gross via R-help
Jim, there are indeed many mathematical areas where data are not quite fixed. Consider inequalities such as a value that can be higher than some number but lower than another. A grade of A can often mean a score between 90 and 100 (no extra credit). An event deemed to be "significant at the

Re: [R] [EXT] Re: Creating NA equivalent

2021-12-21 Thread David K Stevens
Hello all, My two cents. We use the term "below the detection limit" for any physical measurement that is cannot be distinguished from noise in the measurement system. This may either be instance specific (determine the detection limit for each instance) or "below the reporting limit" which

Re: [R] Creating NA equivalent

2021-12-21 Thread Jim Lemon
Hi Bert, What troubles me about this is that something like detectable level(s) is determined at a particular time and may change. Censoring in survival tells us that the case lasted "at least this long". While a less than detectable value doesn't give any useful information apart from perhaps

Re: [R] Creating NA equivalent

2021-12-21 Thread Bert Gunter
But you appear to be missing something, Jim -- see inline below (and the original post): Bert On Tue, Dec 21, 2021 at 2:00 PM Jim Lemon wrote: > > Please pardon a comment that may be off-target as well as off-topic. > This appears similar to a number of things like fuzzy logic, where an >

Re: [R] Creating NA equivalent

2021-12-21 Thread Jim Lemon
Please pardon a comment that may be off-target as well as off-topic. This appears similar to a number of things like fuzzy logic, where an instance can take incompatible truth values. It is known that an instance may have an attribute with a numeric value, but that value cannot be determined. It

Re: [R] Adding SORT to UNIQUE

2021-12-21 Thread Bert Gunter
Stephen: You seem confused about data frames. sort(unique(...)) has no problem sorting individual columns in a data frame (mod the issues about mixing numerics and non-numerics that have already been discussed). But the problem is that the results can *not* be put back in a data frame because,

Re: [R] Adding SORT to UNIQUE

2021-12-21 Thread Jeff Newmiller
It is not about outlawing matrix notation... to the contrary, it is about consistency. For tibbles, [] always returns another tibble. If you wanted a column vector, you should have asked for a column vector. Does the fact that DF[ 1, ] yields a different type than DF[ , 1 ] and DF[ 1:2, ]

Re: [R] Creating NA equivalent

2021-12-21 Thread Avi Gross via R-help
I wonder if the package Adrian Dușa created might be helpful or point you along the way. It was eventually named "declared" https://cran.r-project.org/web/packages/declared/index.html With a vignette here: https://cran.r-project.org/web/packages/declared/vignettes/declared.pdf I do not know

Re: [R] Adding SORT to UNIQUE

2021-12-21 Thread Fox, John
Dear Jeff, I haven't investigated your claim systematically, but out of curiosity, I did try extending my previous example, admittedly arbitrarily. In doing so, I assumed that you intended col in the first case to be the column subscript, not the row subscript. Here's what I got (on a newish

Re: [R] Adding SORT to UNIQUE

2021-12-21 Thread Avi Gross via R-help
Duncan, Let's not go there discussing the trouble with tibbles when the topic asked how to do things in more native R. The reality is that tibbles when used in the tidyverse often use somewhat different ways to select what columns you want including some very quite sophisticated ones like:

Re: [R] Adding SORT to UNIQUE

2021-12-21 Thread Avi Gross via R-help
Stephen, Languages have their own philosophies and are often focused initially on doing specific things well. Later, they tend to accumulate additional functionality both in the base language and extensions. I am wondering if you have explained your need precisely enough to get the answers

Re: [R] Adding SORT to UNIQUE

2021-12-21 Thread Duncan Murdoch
On 21/12/2021 12:53 p.m., Duncan Murdoch wrote: On 21/12/2021 12:29 p.m., Jeff Newmiller wrote: It is a very rational choice, not a design flaw. I don't like every choice they have made for that class, but this one is very solid, and treating data frames as lists of columns consistently helps

Re: [R] Adding SORT to UNIQUE

2021-12-21 Thread Jeff Newmiller
When your brain is wired to treat a data frame like a matrix, then you think things like for ( col in colnames( col ) ) { idx <- expr D[ col, idx ] <- otherexpr } are reasonable, when for ( col in colnames( col ) ) { idx <- expr D[[ col ]][ idx ] <- otherexpr } does actually run

Re: [R] Adding SORT to UNIQUE

2021-12-21 Thread Duncan Murdoch
On 21/12/2021 12:29 p.m., Jeff Newmiller wrote: It is a very rational choice, not a design flaw. I don't like every choice they have made for that class, but this one is very solid, and treating data frames as lists of columns consistently helps all of us. I think outlawing matrix notation is

Re: [R] Adding SORT to UNIQUE

2021-12-21 Thread Jeff Newmiller
It is a very rational choice, not a design flaw. I don't like every choice they have made for that class, but this one is very solid, and treating data frames as lists of columns consistently helps all of us. On December 21, 2021 9:02:56 AM PST, Duncan Murdoch wrote: >On 21/12/2021 11:59

Re: [R] Adding SORT to UNIQUE

2021-12-21 Thread Fox, John
Dear Jeff, On 2021-12-21, 11:59 AM, "R-help on behalf of Jeff Newmiller" wrote: Intuitive, perhaps, but noticably slower. I think that in most applications, one wouldn't notice the difference; for example: > D <- data.frame(matrix(rnorm(1000*1e6), 1e6, 1000)) > microbenchmark(D[, 1])

Re: [R] Adding SORT to UNIQUE

2021-12-21 Thread Duncan Murdoch
On 21/12/2021 11:59 a.m., Jeff Newmiller wrote: Intuitive, perhaps, but noticably slower. And it doesn't work on tibbles by design. Data frames are lists of columns. That's just one of the design flaws in tibbles, but not the worst one. Duncan Murdoch On December 21, 2021 8:38:35 AM PST,

Re: [R] Adding SORT to UNIQUE

2021-12-21 Thread Jeff Newmiller
Intuitive, perhaps, but noticably slower. And it doesn't work on tibbles by design. Data frames are lists of columns. On December 21, 2021 8:38:35 AM PST, Duncan Murdoch wrote: >On 21/12/2021 11:31 a.m., Duncan Murdoch wrote: >> On 21/12/2021 11:20 a.m., Stephen H. Dawson, DSL wrote: >>>

Re: [R] Adding SORT to UNIQUE

2021-12-21 Thread Duncan Murdoch
On 21/12/2021 11:31 a.m., Duncan Murdoch wrote: On 21/12/2021 11:20 a.m., Stephen H. Dawson, DSL wrote: Thanks for the reply. sort(unique(Data[1])) Error in `[.data.frame`(x, order(x, na.last = na.last, decreasing = decreasing)) :   undefined columns selected That's the wrong syntax:

Re: [R] Adding SORT to UNIQUE

2021-12-21 Thread Duncan Murdoch
On 21/12/2021 11:20 a.m., Stephen H. Dawson, DSL wrote: Thanks for the reply. sort(unique(Data[1])) Error in `[.data.frame`(x, order(x, na.last = na.last, decreasing = decreasing)) :   undefined columns selected That's the wrong syntax: Data[1] is not "column one of Data". Use Data[[1]]

Re: [R] Adding SORT to UNIQUE

2021-12-21 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. What I want is the sort of distinct column output. Again, the column may be text

Re: [R] Adding SORT to UNIQUE

2021-12-21 Thread Duncan Murdoch
On 21/12/2021 10:16 a.m., Stephen H. Dawson, DSL via R-help wrote: Thanks everyone for the replies. It is clear one either needs to write a function or put the unique entries into another dataframe. It seems odd R cannot sort a list of unique column entries with ease. Python and SQL can do it

Re: [R] Adding SORT to UNIQUE

2021-12-21 Thread Stephen H. Dawson, DSL via R-help
Thanks everyone for the replies. It is clear one either needs to write a function or put the unique entries into another dataframe. It seems odd R cannot sort a list of unique column entries with ease. Python and SQL can do it with ease. QUESTION Is there a simpler means than other than

Re: [R] Creating NA equivalent

2021-12-21 Thread Viechtbauer, Wolfgang (SP)
Say 'yi' is left censored. Then: # naive regression model res1 <- lm(yi ~ xi, data=dat) # tobit model via survreg() res2a <- survreg(Surv(yi, yi > censval, type="left") ~ xi, dist="gaussian", data=dat) # tobit model via tobit() from AER package res2b <- tobit(yi ~ xi, left=censval, data=dat)

Re: [R] Creating NA equivalent

2021-12-21 Thread Chris Evans
Many thanks Wolfgang, I guess I can see that survival analyses don't have to be time based but clearly I need to read up on that. I can't see an example in the survival package. And it proves to be hard to search for one. Can anyone point me to useful resources on that, in {survival} or not?

Re: [R] Creating NA equivalent

2021-12-21 Thread Viechtbauer, Wolfgang (SP)
Hi Chris, The survival package provides machinery for handling censored observations. Whether time is censored or some other type of variable (e.g., viral load due to some lower detection limit) does not make a fundamental difference. In fact, the type of model you are thinking of with 2) is a

Re: [R] Creating NA equivalent

2021-12-21 Thread Chris Evans
I am neither a programmer nor a professional statistician but this topic interests me because: 1) I remember from long, long ago that S had a way to create labels that could denote multiple ways in which a value could be missing that was sometimes useful to me as my field sometimes has

Re: [R] Creating NA equivalent

2021-12-21 Thread Duncan Murdoch
On 20/12/2021 11:41 p.m., Marc Girondot via R-help wrote: 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