Re: [R] R CMD check says no visible binding for global variable

2025-01-29 Thread Jorgen Harmse via R-help
could also wrap all the code in a function and use the debugger to step through that (which may help if the error occurs in an iteration of a loop body). Regards, Jorgen Harmse. Message: 1 Date: Mon, 27 Jan 2025 22:46:21 + From: Naresh Gurbuxani To: "r-help@r-project.org" Subject:

Re: [R] Extracting specific arguments from "..."

2025-01-07 Thread Jorgen Harmse via R-help
he design was probably too devious in the first place. } } Regards, Jorgen Harmse. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/

Re: [R] Extracting specific arguments from "..."

2025-01-06 Thread Jorgen Harmse via R-help
to extract the expression without evaluating it? g <- function(...) { pos <- match('a',...names()) if (is.na(pos)) stop("a is missing.") (function(a,...) substitute(a)) (...) } Regards, Jorgen Harmse. Message: 8 Date: Sun, 5 Jan 2025 11:17:02 -0800 From

Re: [R] [EXTERNAL] R-help Digest, Vol 260, Issue 19

2024-10-24 Thread Jorgen Harmse via R-help
I think that Stevie Pederson has the right idea, but it is not obvious what the threshold should be. Example: > n <- 2428716; sum(rep(1/n,n)) - 1 [1] -3.297362e-14 I assume that equally large errors in the other direction are also possible. Regards, Jorgen

Re: [R] BUG: atan(1i) / 5 = NaN+Infi ?

2024-09-06 Thread Jorgen Harmse via R-help
s)*1i) is pi/2, and the real part of atan((1-.Machine$double.eps)*1i) is zero, and someone apparently decided to average those for atan(1i). TL;DR: The documentation needs more details, and I don't really like the extended complex plane that R implemented, but within that frame

Re: [R] An error message with the command fm<-1m

2024-08-06 Thread Jorgen Harmse via R-help
oval must be 'o' or 'O', not the digit '0'. (Digits after the first character are standard.) Regards, Jorgen Harmse. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIB

Re: [R] round and trailing zero

2024-07-30 Thread Jorgen Harmse via R-help
latter case, why stash them in a variable? For more control of the display, consider sprintf (or a wrapper that combines sprintf with cat). Regards, Jorgen Harmse. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To

Re: [R] grep

2024-07-12 Thread Jorgen Harmse via R-help
which(grepl()) looks odd. Doesn't grep by itself return the correct vector of indices? Regards, Jorgen Harmse. Message: 5 Date: Fri, 12 Jul 2024 17:42:05 +0800 From: Steven Yen mailto:st...@ntu.edu.tw>> To: Uwe Ligges mailto:lig...@statistik.tu-dortmund.de>>, R-help Mail

Re: [R] Listing folders on One Drive

2024-05-21 Thread Jorgen Harmse via R-help
or other machinery to thin it out. Regards, Jorgen Harmse. -- Message: 1 Date: Mon, 20 May 2024 14:36:58 +0100 From: Nick Wray mailto:nickmw...@gmail.com>> To: r-help@r-project.org <mailto:r-help@r-project.org>

Re: [R] [EXTERNAL] Re: duplicated() on zero-column data frames returns empty

2024-05-13 Thread Jorgen Harmse via R-help
Good luck! It looks like a significant effort for someone not already on the team. Regards, Jorgen Harmse. From: Mark Webster Date: Monday, May 13, 2024 at 04:07 To: Jorgen Harmse , Ivan Krylov Cc: r-help@r-project.org Subject: [EXTERNAL] Re: duplicated() on zero-column data frames returns

Re: [R] duplicated() on zero-column data frames returns empty

2024-04-08 Thread Jorgen Harmse via R-help
our would be to issue a warning that the change is coming in a future version.) The protection for old code could be just a warning that can be turned off with a call to options. The new documentation should be more explicit. Regards, Jorgen. From: Mark Webster To: Jorgen Harmse , Ivan Krylov

Re: [R] duplicated() on zero-column data frames returns empty

2024-04-05 Thread Jorgen Harmse via R-help
(I do not know how to make Outlook send plain text, so I avoid apostrophes.) For what it is worth, I agree with Mark Webster. The discussion by Ivan Krylov is interesting, but if duplicated really treated a row name as part of the row then any(duplicated(data.frame(�))) would always be FALSE. My

Re: [R] Building Packages.

2024-03-21 Thread Jorgen Harmse via R-help
> Turns out that RStudio replaces the install.packages object in the utils > package. > Duncan Murdoch So RStudio unlocks the bindings and alters the exported environment? That seems like another reason to stick to the terminal interface. >> Thank you. tools:::.install_packages works. > I'm gl

Re: [R] Building Packages.

2024-03-20 Thread Jorgen Harmse via R-help
urce) ) file.copy(DESC.source, file.path(package.dir,"DESCRIPTION"), overwrite=TRUE) roxygenise(package.dir,clean=clean) tar <- devtools::build(package.dir) if (install) install.packages(tar,type='source',repos=NULL) invisible() } From: Ivan Krylov Date:

Re: [R] Building Packages.

2024-03-20 Thread Jorgen Harmse via R-help
x27;width')} #' #' @export width <- function(dw) options(width = options('width')[[1L]] + as.integer(dw)) From: Duncan Murdoch Date: Wednesday, March 20, 2024 at 12:09 To: Jorgen Harmse , Ivan Krylov , Jorgen Harmse via R-help Subject: [EXTERNAL] Re: [R] Buildi

Re: [R] Building Packages.

2024-03-20 Thread Jorgen Harmse via R-help
From: Ivan Krylov Date: Wednesday, March 20, 2024 at 11:14 To: Jorgen Harmse via R-help Cc: Jorgen Harmse Subject: [EXTERNAL] Re: [R] Building Packages. � Wed, 20 Mar 2024 16:02:27 + Jorgen Harmse via R-help �: > > install.packages(tar,type='source',repos=NULL) >

[R] Building Packages.

2024-03-20 Thread Jorgen Harmse via R-help
I have a source file with oxygen-style comments (and description & licence files), and I’m trying to build a package. oxygen & devtools seem to work, and the tarball exists, but install.packages balks. Does anyone know what’s happening? Regards, Jorgen Harmse. > roxygenise(packag

Re: [R] I need to create new variables based on two numeric variables and one dichotomize conditional category

2023-11-06 Thread Jorgen Harmse via R-help
mes.") return(L[[1L]]) } if (missing(yes1)) { if (length(L <- list(...)) != 0L) stop("Wrong number of arguments or confusing argument names.") return(test1) } return( ifelse(test1, yes1, ifelses(...)) ) } Regards, Jorgen Harmse (not Jordan). -

Re: [R] [EXTERNAL] Re: I need to create new variables based on two numeric variables and one dichotomize conditional category variables.

2023-11-06 Thread Jorgen Harmse via R-help
of another formula? Regards, Jorgen Harmse. From: CALUM POLWART Date: Saturday, November 4, 2023 at 18:23 To: avi.e.gr...@gmail.com Cc: Jorgen Harmse , r-help@r-project.org , mkzama...@gmail.com Subject: [EXTERNAL] Re: [R] I need to create new variables based on two numeric variables and one

Re: [R] [EXTERNAL] RE: I need to create new variables based on two numeric variables and one dichotomize conditional category variables.

2023-11-03 Thread Jorgen Harmse via R-help
egards, Jorgen Harmse. From: avi.e.gr...@gmail.com Date: Friday, November 3, 2023 at 16:12 To: Jorgen Harmse , r-help@r-project.org , mkzama...@gmail.com Subject: [EXTERNAL] RE: [R] I need to create new variables based on two numeric variables and one dichotomize conditional category variables

Re: [R] I need to create new variables based on two numeric variables and one dichotomize conditional category variables.

2023-11-03 Thread Jorgen Harmse via R-help
df$LAP <- with(df, ifelse(G=='male', (WC-65)*TG, (WC-58)*TG)) That will do both calculations and merge the two vectors appropriately. It will use extra memory, but it should be much faster than a 'for' loop. Regards, Jorgen Harmse. -- Mess

Re: [R] save(), load(), saveRDS(), and readRDS()

2023-09-29 Thread Jorgen Harmse via R-help
Ivan Krylov points out that load(file, e <- new.env()) is cumbersome. I put it into a function. Regards, Jorgen Harmse. #' Save & load lists & environments #' #' \code{\link{save}} has to be told what to save from an environment, and the obvious way #' to sa

Re: [R] Could you manually replicate execution of a R function

2023-09-20 Thread Jorgen Harmse via R-help
{�, and parse(text=�.) to break the function into expressions. That might be easier than copy-pasting function code. Regards, Jorgen Harmse. Message: 1 Date: Tue, 19 Sep 2023 23:09:18 +0530 From: Brian Smith To: r-help@r-project.org Subject: [R] Could you manually replicate execution of a R f

Re: [R] preserve class in apply function

2023-02-08 Thread Jorgen Harmse via R-help
matrix must have the same type. Regards, Jorgen Harmse. Message: 1 Date: Tue, 7 Feb 2023 07:51:50 -0500 From: Naresh Gurbuxani To: "r-help@r-project.org" Subject: [R] preserve class in apply function Message-ID: Content-Type: text/plain; charset="us-ascii"

Re: [R] [EXTERNAL] Re: function doesn't exists but still runs..... (akshay kulkarni)

2023-01-23 Thread Jorgen Harmse via R-help
2 Date: Sun, 22 Jan 2023 14:25:59 + From: akshay kulkarni To: Jorgen Harmse , "r-help@r-project.org" , "williamwdun...@gmail.com" Subject: Re: [R] [EXTERNAL] Re: function doesn't exists but still runs. (akshay kulkarni)

Re: [R] [EXTERNAL] Re: function doesn't exists but still runs..... (akshay kulkarni)

2023-01-20 Thread Jorgen Harmse via R-help
gging the public package function because it didn't do what you expected, or were you just curious how it worked? Regards, Jorgen. From: akshay kulkarni Date: Friday, January 20, 2023 at 11:19 To: Jorgen Harmse , r-help@r-project.org , williamwdun...@gmail.com Subject: [EXTERNAL] Re

Re: [R] function doesn't exists but still runs..... (akshay kulkarni)

2023-01-20 Thread Jorgen Harmse via R-help
cts and everything in the ancestor environments. You can repeat the trick to see private environments of packages you didn't directly pull in. I think you can even unlock bindings and do ghastly things to the package's private environment. Regards, Jorgen Harmse. ---

Re: [R] Get data from a list of data frames (Stefano Sofia)

2022-12-16 Thread Jorgen Harmse via R-help
data frame will be meaningful. Regards, Jorgen Harmse. From: R-help on behalf of r-help-requ...@r-project.org Date: Friday, 16December, 2022 at 05:00 To: r-help@r-project.org Subject: [EXTERNAL] R-help Digest, Vol 238, Issue 16 Message: 1 Date: Thu, 15 Dec 2022 13:52:35 + From: Stefano

Re: [R] [EXTERNAL] RE: unexpected 'else' in " else"

2022-10-28 Thread Jorgen Harmse via R-help
use delayedAssign to preserve short-circuit behaviour), but I was discussing my line-break preferences in case breaks are needed. Regards, Jorgen Harmse. From: Ebert,Timothy Aaron Date: Friday, 28October, 2022 at 10:22 To: Jorgen Harmse , r-help@r-project.org Subject: [EXTERNAL] RE

Re: [R] unexpected 'else' in " else"

2022-10-28 Thread Jorgen Harmse via R-help
ructure of the code, and I would usually rather throw in a few extra delimiters than obscure the structure. Regards, Jorgen Harmse. Examples (best viewed in a real text editor so things line up): { if (x To: Jinsong Zhao Cc: "r-help@r-project.org" Subject: Re: [R] unexpected 'el

Re: [R] [EXTERNAL] Re: unexpected 'else' in " else" (Ebert, Timothy Aaron)

2022-10-25 Thread Jorgen Harmse via R-help
Good catch! I also misread it, and I think most people would. If I wanted to write confusing documentation then I could play similar games with 'mode' and 'length'. Regards, Jorgen Harmse. > test <- c(TRUE,FALSE,FALSE) > attr(test,'class') <- 

Re: [R] [EXTERNAL] Re: unexpected 'else' in " else" (Ebert, Timothy Aaron)

2022-10-24 Thread Jorgen Harmse via R-help
I agree that the documentation should be clarified. Moreover, my last example shows that the class can be different even when no mode coercion is required. I don't know enough about S3 & S4 to comment on your last point. Regards, Jorgen Harmse. From: Bert Gunter Date: Monday, 24Octo

Re: [R] unexpected 'else' in " else" (Ebert,Timothy Aaron)

2022-10-24 Thread Jorgen Harmse via R-help
o the classes of `yes` & `no`. Regards, Jorgen Harmse. > ifelse(FALSE, {cat("Evaluating the vector for 'if'.\n"); 1:3}, > {cat("Evaluating the vector for 'else'.\n"); 0:4}) Evaluating the vector for 'else'. [1] 0 > ifelse(rep

Re: [R] [EXTERNAL] Re: unexpected 'else' in " else"

2022-10-21 Thread Jorgen Harmse via R-help
, Jorgen. > evalq( if (FALSE) cat("This shouldn't happen.\n") else cat("Everything is fine.\n"), + .GlobalEnv + ) Everything is fine. > x <- 1:5 > x[ if(FALSE) 1L +else 2L + ] [1] 2 From: Andrew Simmons Date: Friday, 21October, 2022 at

Re: [R] unexpected 'else' in " else"

2022-10-21 Thread Jorgen Harmse via R-help
NULL if the condition is FALSE, so it might be necessary to undo an assignment, and that seems very difficult.) Regards, Jorgen Harmse. On Fri., Oct. 21, 2022, 05:29 Jinsong Zhao, wrote: > Hi there, > > The following code would cause R error: > > > w <- 1:5 > > r

Re: [R] Question about Line Ending Choice

2022-09-28 Thread Jorgen Harmse via R-help
,LF) else if (target %in% c(�Unix�,�Mac�)) eol <- LF else if �. else stop(�Unexpected target.�) write.table(eol=eol, �.) Regards, Jorgen Harmse. Message: 7 Date: Tue, 27 Sep 2022 11:35:54 -0400 From: "Stephen H. Dawson, DSL" To: Bert Gunter Cc: r-help Subject: Re: [R] Q

Re: [R] How important is set.seed

2022-03-22 Thread Jorgen Harmse via R-help
using a hash of something involving the unique key. Then the selection of a salt is the equivalent of a call to set.seed in non-parallel processing. The results should be the same as long as you fix the data set & the salt, and then you can test sensitivity to changes in the salt. Jorgen Ha

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

2021-12-20 Thread Jorgen Harmse via R-help
rom all but the last argument. > base::file.path('foo/','bar') [1] "foo//bar" > file.path('foo/','bar') [1] "foo/bar" Incidentally, I don't like T & F for Booleans (or t for transpose) in production code. Single letters

Re: [R] names.data.frame?

2021-11-04 Thread Jorgen Harmse via R-help
length and some overloading of list functions to ensure that that is always true.) The other answers confused me more. Regards, Jorgen Harmse. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more

Re: [R] assumptions about how things are done

2021-10-11 Thread Jorgen Harmse via R-help
[cond],b[cond]) is what we want), or it might return a+rev(b). Avi Gross correctly notes that the implementation is not what he wants, but I think that what he wants is possible only in special cases. Regards, Jorgen Harmse.  Message: 2 Date: Sat, 9 Oct 2021 15:35:55 -0400 Fro

[R] Documentation of Trigonometric Functions.

2021-04-14 Thread Jorgen Harmse via R-help
ion. Jorgen Harmse. __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, s

Re: [R] Re move row.names column in dataframe

2013-03-11 Thread Jorgen Harmse
identical(df[1,],df[2,]) is FALSE because of the row names. all( == ) is just a work-around that I attempted. Jorgen. On Mar 11, 2013, at 02:53 , PIKAL Petr wrote: >> >>> df <- data.frame(x=c(1,1,NA,NA), y=c(2,2,7,7)) >>> identical(df[1,],df[2,]) >> [1] FALSE >>> all(df[1,]==df[2,]) >> [1] TRU