similar to: An error message with the command fm<-1m

Displaying 20 results from an estimated 3000 matches similar to: "An error message with the command fm<-1m"

2024 Apr 08
1
duplicated() on zero-column data frames returns empty
I appreciate the compliment from Ivan and still share the puzzlement at the empty return. What is the policy for changing something that is wrong? There is a trade-off between breaking old code that worked around a problem and breaking new code written by people who make reasonable assumptions. Mathematically, it seems obvious to me that duplicated.matrix(A) should do something like this: v
2023 Nov 03
1
[EXTERNAL] RE: I need to create new variables based on two numeric variables and one dichotomize conditional category variables.
Yes, that will halve the number of multiplications. If you?re looking for such optimisations then you can also consider ifelse(G=='male', 65L, 58L). That will definitely use less time & memory if WC is integer, but the trade-offs are more complicated if WC is floating point. Regards, Jorgen Harmse. From: avi.e.gross at gmail.com <avi.e.gross at gmail.com> Date: Friday,
2025 Jan 06
1
Extracting specific arguments from "..."
Thanks Jorgen. I thought your approach to getting the argument expressions was clever, but somewhat convoluted. I think the usual simple way is to use match.call() (or sys.call() )to get the unevaluated argument expressions; e.g. ... f <- function(...){ match.call() } > f(a = 'red', b = sin(zzz)) f(a = "red", b = sin(zzz)) The return value is an object of class call
2025 Jan 06
2
Extracting specific arguments from "..."
Bert and other on this Chain, The original question asked by Bert Gunter, highlights one of my long standing wishes. Perhaps my wish has already been fulfilled (if it has, please let me know where I can look of fulfill my wish), if it hasn't perhaps someone can grant me my wish. I have tried to understand how to write a function (beyond a basic function), get values of the parameters, and
2025 Jan 07
1
Extracting specific arguments from "..."
It is a pretty tricky topic, but IMO Advanced R [1] steps you through it systematically... you just have to be prepared to follow along in R with the examples as you read it. In particular, the chapter on Functions goes through this. The subtleties of how base R gives you control over these topics is what lead to the tidyverse creating new packages to build such function interfaces. Manipulating
2023 Nov 03
2
I need to create new variables based on two numeric variables and one dichotomize conditional category variables.
Just a minor point in the suggested solution: df$LAP <- with(df, ifelse(G=='male', (WC-65)*TG, (WC-58)*TG)) since WC and TG are not conditional, would this be a slight improvement? df$LAP <- with(df, TG*(WC - ifelse(G=='male', 65, 58))) -----Original Message----- From: R-help <r-help-bounces at r-project.org> On Behalf Of Jorgen Harmse via R-help Sent: Friday,
2023 Nov 06
0
I need to create new variables based on two numeric variables and one dichotomize conditional category
Avi: Thank you for checking. I think the optimization is limited. If test is all TRUE or all FALSE then at most one vector is evaluated. Anything beyond that would be very complicated. (Inspect the two expressions and verify that both specify elementwise computations. Then use indexing to shrink the input properly. Take into account all recycling rules for binary operations.) > ifelse(0:1,
2025 Jan 07
1
Extracting specific arguments from "..."
Jeff: Would you care to offer an example of: "String literals are surprisingly simple alternatives that don't bite you in the butt nearly so often as NSE does." "No" is a perfectly acceptable answer. I would generally agree with you about NSE, but my original query was motivated by something simple. I like to use lattice graphics when I fool around with graphing data, as
2025 Jan 06
1
Extracting specific arguments from "..."
I think Bert Gunter is right, but do you want partial matches (not found by match), and how robust do you want the code to be? f <- function(?) { pos <- match('a', ...names()) if (is.na(pos)) stop("a is required.") ?elt(pos) } Incidentally, what is the best way to extract the expression without evaluating it? g <- function(...) { pos <-
2024 Mar 21
1
Building Packages.
With all this discussion, I shudder to ask this. I may have missed the answers but the discussion seems to have been about identifying and solving the problem rapidly rather than what maybe is best going forward if all parties agree. What was the motivation for what RSTUDIO did for their version and the decision to replace what came with utils unless someone very explicitly over-rode them by
2023 Nov 05
1
I need to create new variables based on two numeric variables and one dichotomize conditional category variables.
There are many techniques Callum and yours is an interesting twist I had not considered. Yes, you can specify what integer a factor uses to represent things but not what I meant. Of course your trick does not work for some other forms of data like real numbers in double format. There is a cost to converting a column to a factor that is recouped best if it speeds things up multiple times. The
2024 Apr 07
1
duplicated() on zero-column data frames returns empty
? Fri, 5 Apr 2024 16:08:13 +0000 Jorgen Harmse <JHarmse at roku.com> ?????: > if duplicated really treated a row name as part of the row then > any(duplicated(data.frame(?))) would always be FALSE. My expectation > is that if key1 is a subset of key2 then all(duplicated(df[key1]) >= > duplicated(df[key2])) should always be TRUE. That's a good argument, thank you! Would
2024 May 12
1
duplicated() on zero-column data frames returns empty
(Sorry for only getting back to this more than a month later.) ? Mon, 8 Apr 2024 17:03:00 +0000 Jorgen Harmse <JHarmse at roku.com> ?????: > What is the policy for changing something that is wrong? There is a > trade-off between breaking old code that worked around a problem and > breaking new code written by people who make reasonable assumptions. First of all, quantify the
2018 Aug 03
0
glm Argument-Evaluation Does Not Match Documentation.
Details in documentation: "All of ?weights?, ?subset?, ?offset?, ?etastart? and ?mustart? are evaluated in the same way as variables in ?formula?, that is first in ?data? and then in the environment of ?formula?." In fact, `data` is usually not an environment, and I have not seen arguments evaluated in `environment(formula)` when `data` is provided. (Information in `environment(formula)`
2024 Mar 21
1
Building Packages.
I posted a description of their changes this morning. Duncan Murdoch On 21/03/2024 11:37 a.m., avi.e.gross at gmail.com wrote: > With all this discussion, I shudder to ask this. I may have missed the > answers but the discussion seems to have been about identifying and solving > the problem rapidly rather than what maybe is best going forward if all > parties agree. > > What
2025 Jan 07
1
Extracting specific arguments from "..."
There's an ancient (2003) document on the CRAN "developers' page" https://developer.r-project.org/model-fitting-functions.html that is sort of (but not exactly) what you're looking for ... On 2025-01-07 5:03 p.m., Sorkin, John wrote: > Colleagues, > > My interest is not in writing ad hoc functions (which I might use once to analyze my data), but rather what I
2025 Jan 07
2
Extracting specific arguments from "..."
Colleagues, My interest is not in writing ad hoc functions (which I might use once to analyze my data), but rather what I will call a system function that might be part of a package. The lm function is a paradigm of what I call a system function. The lm function begins by processing the arguments passed to the function (represented in the function as parameters, see code below.) Much of this
2024 Jul 30
1
round and trailing zero
Duncan Murdoch answered your question, but I have another. Are you going to do some computation with the rounded numbers, or are they just for display? (One thing I like about Excel is that I can change the display format of a cell without changing answers that depend on that cell.) In the latter case, why stash them in a variable? For more control of the display, consider sprintf (or a wrapper
2025 Jan 07
1
Extracting specific arguments from "..."
Ben, As always, thank you. You are correct, it is something like what I want, but not exactly. Perhaps someday someone will write a more complete guide. Thank you, John John David Sorkin M.D., Ph.D. Professor of Medicine, University of Maryland School of Medicine; Associate Director for Biostatistics and Informatics, Baltimore VA Medical Center Geriatrics Research, Education, and Clinical
2025 Jan 07
1
Extracting specific arguments from "..."
Interesting discussion. A few things occurred to me. Apologies to Iris Simmons: I mixed up his answer with Bert's question. Bert raises questions about promises, and I think they are related to John Sorkin's question. A big difference between R and most other languages is that function arguments are computed lazily. match.call & substitute tell us what expressions will be evaluated