[R] Off topic: Reference to "Box and whisker plots" make the weather report

2025-07-11 Thread Bert Gunter
For statistical graphics enthusiasts and John Tukey admirers in particular, for the first time in my lifetime, I have seen a reference to Tukey's "box-and-whisker plots" in a public non-technical forum -- a National Weather Service report for the San Francisco Bay Area: "Looking at box and whisker

Re: [R] Converting dataframe to matrix

2025-06-25 Thread Bert Gunter
To add to Rolf's comments: 1. What you do with your data may depend on what you want to do with it *after* you have fiddled with its structure. Treating numerical categories as numerics is often a bad idea for many kinds of analyses or even graphics; 2. Note that na.omit(d) when d is a data frame

Re: [R] Does this exist: diff(range(VAR, na.rm=T))

2025-06-25 Thread Bert Gunter
Just wanted to point out that: 1. range() is a generic function and the default version works for character objects also: > range("Joe", "Q", "Public") [1] "Joe" "Q" ## but > diff(range("Joe", "Q", "Public")) Error in r[i1] - r[-length(r):-(length(r) - lag + 1L)] : non-numeric argument to bin

Re: [R] From strings to column names

2025-06-18 Thread Bert Gunter
mns in a data frame/table for processing If I've misunderstood, of course just ignore the above. -- Bert On Wed, Jun 18, 2025 at 7:48 AM Bert Gunter wrote: > If I understand correctly, see ?"[" : data tables inherit from data > frames, and data frame columns can be i

Re: [R] From strings to column names

2025-06-18 Thread Bert Gunter
If I understand correctly, see ?"[" : data tables inherit from data frames, and data frame columns can be indexed by their names as character strings. The following should give you the idea: d <- data.frame(a1 = 1:3, a2 = 4:6) x <- vector("numeric",2) for(i in 1:2){ nm <- paste0("a",i) x[i]

Re: [R] Simulating mid-points from a defined range

2025-06-06 Thread Bert Gunter
mple). Context matters! Cheers, Bert On Thu, Jun 5, 2025 at 10:09 PM Bert Gunter wrote: > ... and here is a a simple 2-liner without a sort that I think is linear > in time and space (but please correct if this is wrong): > > x <- cumsum(runif(10)) > x/x[10] *

Re: [R] Simulating mid-points from a defined range

2025-06-05 Thread Bert Gunter
tics? I believe yes, but someone more statistically competent than me needs to verify or correct this. Cheers, Bert On Thu, Jun 5, 2025 at 5:19 AM Bert Gunter wrote: > > Richard: > > "The "use an upper bound of 100 - (n+1)*5" and then "add back > cumsum(

Re: [R] Simulating mid-points from a defined range

2025-06-05 Thread Bert Gunter
Richard: "The "use an upper bound of 100 - (n+1)*5" and then "add back cumsum(rep(5,n)) at the end" (or equivalent) trick ensures the gaps are right but does nothing about the distribution.." If I understand you correctly, I think the above is wrong. Here is a one-line version of Peter's code for

Re: [R] Simulating mid-points from a defined range

2025-06-04 Thread Bert Gunter
can I extend this to draw only integer > mid-point between 0-100 while maintaining minimum difference as 5? > > Also, are all generated points are equally likely? > > Thanks for your time and suggestions. > > Thanks and regards, > > On Wed, 4 Jun 2025 at 17:13, Bert Gunte

Re: [R] Simulating mid-points from a defined range

2025-06-04 Thread Bert Gunter
To answer my own question, yes they are different. Peter's code can generate the solution 1 20 26 32 38 44 50 56 62 68. Mine cannot. So, again, context? -- Bert On Wed, Jun 4, 2025 at 4:43 AM Bert Gunter wrote: > Is Peter's solution different then: > > diffs <- cumsum(r

Re: [R] Simulating mid-points from a defined range

2025-06-04 Thread Bert Gunter
Is Peter's solution different then: diffs <- cumsum(runif(9, 5, 100/9)) x <-runif(1,0,100-diffs[9]) c(x, x+diffs) I ask because: 1. If yes, this is why more context is needed; 2. If no, the above avoids a sort. Cheers, Bert On Tue, Jun 3, 2025 at 2:15 PM peter dalgaard wrote: > Can't you j

Re: [R] Simulating mid-points from a defined range

2025-05-31 Thread Bert Gunter
s. > [Here, "k_(i)" is the usual notation for order statistics.] > > Is that the task? > > If so, are there are other requirements on the k_i ? > > The word "simulate" suggests the k_i are supposed to be realizations of > random variables. If so, what sort

Re: [R] Simulating mid-points from a defined range

2025-05-31 Thread Bert Gunter
If this is a real problem and not homework, can you tell us the context? It is not at all clear (to me) what you mean by "simulate", i.e. what your target distribution is, which may depend on/be defined by the context. Bert "An educated person is one who can entertain new ideas, entertain others,

Re: [R] Only one label from axis() is shown

2025-05-28 Thread Bert Gunter
Oh, and for your last example, what you actually do is plot 25 separate axes with one label each, one on top of the other. Again, correction requested if this is wrong. -- Bert "An educated person is one who can entertain new ideas, entertain others, and entertain herself." On Wed, May 28, 2025

Re: [R] Only one label from axis() is shown

2025-05-28 Thread Bert Gunter
I believe the following is the reason, but please correct is this is wrong: from ?axis: "The code tries hard not to draw overlapping tick labels, and so will omit labels where they would abut or overlap previously drawn labels. This can result in, for example, every other tick being labelled. The

Re: [R] Why is there no macro facility for R?

2025-05-22 Thread Bert Gunter
project.org/articles/RN-2001-021/RN-2001-021.pdf > > Bert is correct about the 20+ year time frame… :-) > > Regards, > > Marc Schwartz > > > On May 22, 2025, at 10:32 PM, Bert Gunter wrote: > > John: > 1. You might get a better response if you could give at

Re: [R] Why is there no macro facility for R?

2025-05-22 Thread Bert Gunter
John: 1. You might get a better response if you could give at least a couple of use case examples of what you mean. 2. I have a hazy memory of this being actually discussed on this list ca ~ 20 years ago. As I recall, some sort of macro facility may have been implemented in a package using R's com

Re: [R] OT: A philosophical question about statistics

2025-05-06 Thread Bert Gunter
5, 21:58 Bert Gunter wrote: > I am out of the country and will reply more fully to you (privately) when > I return. But briefly, and subject to my possible > misunderstanding/misinterpretation of your specification, I would say both > your examples illustrate exactly what I said. In th

Re: [R] OT: A philosophical question about statistics

2025-05-06 Thread Bert Gunter
I am out of the country and will reply more fully to you (privately) when I return. But briefly, and subject to my possible misunderstanding/misinterpretation of your specification, I would say both your examples illustrate exactly what I said. In the first, the clea On Tue, May 6, 2025, 14:23 Kev

Re: [R] OT: A philosophical question about statistics

2025-05-05 Thread Bert Gunter
Heh. I suspect you'll get some interesting responses, but I won't try to answer your questions. Instead, I'll just say: (All just imo, so caveat emptor) 1. What you have been taught is mostly useless for addressing "real" statistical issues; 2. Most of my 40 or so years of statistical practice i

Re: [R] Generate random vectors (continuous number) with a fixed sum

2025-04-26 Thread Bert Gunter
ote: > On 2025-04-24 3:25 p.m., Bert Gunter wrote: > > Folks: > > > > Unless my wee old brain errs (always a danger), uniform sampling from an > > n-vector for which 0 <= ai <= xi <= bi and SUM(xi) = k, a constant, > > where to ensure that the constraints are

Re: [R] Generate random vectors (continuous number) with a fixed sum

2025-04-24 Thread Bert Gunter
Folks: Unless my wee old brain errs (always a danger), uniform sampling from an n-vector for which 0 <= ai <= xi <= bi and SUM(xi) = k, a constant, where to ensure that the constraints are consistent (and nontrivial), SUM(ai)< k and SUM(bi) > k, is a simple linear transformation (details left to

Re: [R] Drawing a sample based on certain condition

2025-04-15 Thread Bert Gunter
ot considered. > I only worked with the vector. If the vector is part of a data frame where > I need to know that "this zero" came from Bob, and the other zero came from > Samantha, then the code will not work as written. My solution would be to > ask ChatGPT more questions an

Re: [R] Drawing a sample based on certain condition

2025-04-14 Thread Bert Gunter
Just a comment: You wish to draw subsets of size n with or without replacement -- and I suspect without replacement is simpler than with -- from a set of positive integers that sum to a fixed value T. This sounds related to the so-called subset sum problem in computational complexity theory: Given

Re: [R] An opinion question, please

2025-04-07 Thread Bert Gunter
My *opinion*: 1. As it stands, this "opinion survey" seems pretty useless; 2. It *might* be more useful if you explained what the package will do, who it's intended users are, etc. -- Bert "An educated person is one who can entertain new ideas, entertain others, and entertain herself." On Mon

Re: [R] [External] Creating model formulas programmatically

2025-04-05 Thread Bert Gunter
. Heiberger wrote: > > somenames <- c("Heigh", "Ho", "Silver", "Away") > > as.formula(paste("~(",paste(somenames, collapse="+"),")^2")) > ~(Heigh + Ho + Silver + Away)^2 > > > > &g

Re: [R] join/merge two data frames

2025-04-05 Thread Bert Gunter
You might do better posting here: https://stat.ethz.ch/mailman/listinfo/r-sig-finance Cheers, Bert "An educated person is one who can entertain new ideas, entertain others, and entertain herself." On Wed, Apr 2, 2025 at 4:39 PM Arnaud Gaboury wrote: > I will try to be more precised. Here is

Re: [R] Problems with svg() exporting graphics with gradients

2025-04-03 Thread Bert Gunter
The R-help listserv deletes most attachments (as security risks) and your attachments (I assume) did not come through. Provide code for a minimal reprex or a site from which those interested in helping can get your plots instead if no one who already knows about this issue responds. You might also

Re: [R] Creating model formulas programmatically

2025-03-30 Thread Bert Gunter
; On Sun, Mar 30, 2025 at 6:11 AM Gabor Grothendieck wrote: > Another solution. reformulate + substitute + as.formula: > > substitute(~ (.)^2, list(. = reformulate(somenames)[[2]])) |> as.formula() > > On Sat, Mar 29, 2025 at 5:31 PM Bert Gunter > wrote: > > &

Re: [R] [External] Creating model formulas programmatically

2025-03-29 Thread Bert Gunter
eling system without generating a > formula (a string) that gets parsed. > > -Original Message- > From: R-help On Behalf Of Richard M. > Heiberger > Sent: Saturday, March 29, 2025 8:47 PM > To: Bert Gunter > Cc: R-help > Subject: Re: [R] [External] Creating model

[R] Creating model formulas programmatically

2025-03-29 Thread Bert Gunter
Note: I am almost certain that this has been asked and answered here before, so my apologies for the redundant query. I also know that there are several packages that will do this, but I wish to do it using base R functions only (see below). The query: Suppose I have a character vector of names l

[R] Fwd: how to create model matrix of second order terms

2025-03-24 Thread Bert Gunter
(I neglected to cc the list) -- Forwarded message - From: Bert Gunter Date: Mon, Mar 24, 2025 at 11:00 AM Subject: Re: [R] how to create model matrix of second order terms To: Stephen Bond In view of the fact that your claim that: "The current setup for formulas doe

Re: [R] how to create model matrix of second order terms

2025-03-24 Thread Bert Gunter
Full disclosure: I did not attempt to decipher your code. But ~(A+B +C)^2 - (A + B + C) gives all 2nd order interactions whether the terms are factors or numeric. ~I(A^2) + I(B^2) gives quadratics in A and B, which must be numeric, not factors, of course You can combine these as necessary to get

Re: [R] What don't I understand about sample()?

2025-03-13 Thread Bert Gunter
Bravo for your unrequired R efforts. You misunderstand the nested call. sample() is called only once, producing 1 sample of 10 with replacement. Since your matrix call needs 50 values, ?matrix tells you (in details): "If there are too few elements in data to fill the matrix, then the elements in d

Re: [R] Number changed weirdly when converting to numeric

2025-03-09 Thread Bert Gunter
As has now been explained, there is a lot going on under the hood here. I would just note that the Rmpfr package can do arbitrary precision arithmetic; and so can the Ryacas package, which extends these capabilities to e.g. arbitrary precision linear algebra. (I am just parroting what I found via

Re: [R] expression in lattice panel strip

2025-03-02 Thread Bert Gunter
Full disclosure: I have never plotted time series using this xyplot method. However, ?xyplot.ts says: "screens factor (or coerced to factor) whose levels specify which panel each series is to be plotted in. screens = c(1, 2, 1) would plot series 1, 2 and 3 in panels 1, 2 and 1. May also be a nam

Re: [R] Compressing a sequence

2025-02-22 Thread Bert Gunter
Hi Ben: I realize that for the OP whether it takes 1/2 second or 1 microsecond to do what he wants may be irrelevant, but just for fun I thought I'd time the condense() function you found vs. the compr() function I worked out, which are similar in their approach. compr <- function(x, sep ="-") {

Re: [R] Compressing a sequence

2025-02-22 Thread Bert Gunter
Well, as I predicted, my initial suggestions were, ... ummm, rather dumb. Also, Rui's suggestions are probably preferable to the below. However, it *is* a very simple, bare-boned approach to converting a sequence of increasing integers to a character representation using interval notation. The code

Re: [R] Compressing a sequence

2025-02-21 Thread Bert Gunter
Cute exercise! "Simple" is in the eyes of the beholder, of course. There is probably a package out there that can do this in a trice . But my first thought -- so caveat emptor!, as my thoughts, first or last, are often not so, um... thoughtful -- is to diff() the sequence (as numerics) -- so that

Re: [R] Bayesian VAR

2025-02-21 Thread Bert Gunter
It sounds like your first course of action should be to contact the package maintainer. See ?maintainer or consult the Description file for the package for their email. Cheers, Bert "An educated person is one who can entertain new ideas, entertain others, and entertain herself." On Fri, Feb 21

[R] Completely Off Topic: Renowned scientific integrity investigator endows fund to support fellow sleuths

2025-02-13 Thread Bert Gunter
Again, **Completely Off Topic,** but I hope of interest to at least some on this forum. https://www.science.org/content/article/renowned-scientific-integrity-investigator-endows-fund-support-fellow-sleuths Please do not reply. This is just FYI. Best to all, Bert "An educated person is one who c

Re: [R] pairs plot

2025-02-06 Thread Bert Gunter
Possibly because: panel.hist is not an existing R function -- you have to first create it so pairs() can use it. ?pairs shows you how in the Help examples, i.e. panel.hist <- function(x, ...) { usr <- par("usr") par(usr = c(usr[1:2], 0, 1.5) ) h <- hist(x, plot = FALSE) breaks <- h

Re: [R] Interpreting the output of str on a data frame created using aggregate function

2025-01-24 Thread Bert Gunter
I think there may be some confusion here. 4) x which is a 844x7 matrix having value "Good", "Moderate", etc. Correct. ** To be clear: x is a matrix of **integers** (presumably population counts) with 7 columns with names "Good", "Moderate",

Re: [R] Details about the boxcox function

2025-01-23 Thread Bert Gunter
See ?"::" Many packages hide some of their internal objects, because they are not meant to be directly called by users. As the Help file referenced above explains, they can be referenced by the triple colon operatorm in this case: MASS:::boxcox.lm See also ?methods and methods(boxplot) for furt

Re: [R] ggplot with major and MINOR tick marks on a log scale

2025-01-20 Thread Bert Gunter
dget() should be dput(), of course. But you don't need dput() either, as assigning the structure() call suffices. -- Bert On Mon, Jan 20, 2025 at 6:18 PM Sorkin, John wrote: > I have used ggplot to create a graph on which the y-axis is on the log > scale. (see data and code, below.) I would lik

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

2025-01-09 Thread Bert Gunter
AM Ian Farm wrote: > I might add that there seems to be a subtle difference between using > `...elt()` and `match.call()`, which is that the former causes `a` itself > to be evaluated while the latter doesn't: > ``` > # Some approaches that have been suggested: > > #

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

2025-01-08 Thread Bert Gunter
gt; c(one, two, three(...)) > } > > three <- function(a, ...) { > a > } > > f1(a = 1, b = 2, c = 3) > #> [1] 1 1 1 > > > On Sun, Jan 5, 2025 at 12:00 PM Bert Gunter > wrote: > >> Consider: >> >> f1 <- function(...){ >> one <

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

2025-01-06 Thread Bert Gunter
Biostatistics and Informatics Core, University of Maryland School of > Medicine Claude D. Pepper Older Americans Independence Center; > >Senior Statistician University of Maryland Center for Vascular Research; > > > >Division of Gerontology and Paliative Care, > >10 North

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

2025-01-06 Thread Bert Gunter
have I entirely misunderstood you?! NB. Terminology: Function "arguments" not "parameters". "Parameters" actually means something different in R. Cheers, Bert On Mon, Jan 6, 2025 at 3:26 PM Sorkin, John wrote: > Bert and other on this Chain, > > The origina

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

2025-01-06 Thread Bert Gunter
e way you want in that situation. I leave such delights to wiser heads, as well as any corrections or refinements to anything that I've said here. Cheers, Bert On Mon, Jan 6, 2025 at 9:55 AM Jorgen Harmse wrote: > I think Bert Gunter is right, but do you want partial matches (not f

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

2025-01-05 Thread Bert Gunter
Thanks, Iris. That is what I suspected, but it wasn't clear to me from the docs. Best, Bert On Sun, Jan 5, 2025 at 10:16 AM Iris Simmons wrote: > > I would use two because it does not force the evaluation of the other > arguments in the ... list. > > > > On Sun, Jan

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

2025-01-05 Thread Bert Gunter
Consider: f1 <- function(...){ one <- list(...)[['a']] two <- ...elt(match('a', ...names())) c(one, two) } ## Here "..." is an argument list with "a" somewhere in it, but in an unknown position. > f1(b=5, a = 2, c=7) [1] 2 2 Which is better for extracting a specific named argument, one<- o

Re: [R] Extract estimate of error variance from glm() object

2024-12-24 Thread Bert Gunter
... but do note: glm(lot1 ~ log(u), data = clotting, family = gaussian) is a plain old *linear model*, which is of course a specific type of glm, but not one that requires the machinery of glm() to fit. That is, the above is exactly the same as: lm(lot1 ~ log(u), data = clotting) and gives exac

Re: [R] Extract estimate of error variance from glm() object

2024-12-24 Thread Bert Gunter
?deviance ?anova Bert On Tue, Dec 24, 2024 at 6:22 AM Christofer Bogaso wrote: > > I think vcov() gives estimates of VCV for coefficients. > > I want estimate of SD for residuals > > On Tue, Dec 24, 2024 at 7:24 PM Ben Bolker wrote: > > > > vcov(). ? > > > > > > On Tue, Dec 24, 2024, 8:45 AM C

Re: [R] Query concerning working directory for file.choose()

2024-12-18 Thread Bert Gunter
choose.files is only for MS Windows (the Help file says). -- Bert On Wed, Dec 18, 2024 at 8:06 AM Gabor Grothendieck wrote: > > Try choose.files > > choose.files(default = file.path(mydir, "*.*"), multi = FALSE) > > On Wed, Dec 18, 2024 at 10:33 AM J C Nash wrote: > > > > I've been working

Re: [R] get.symbols doesn' work

2024-12-18 Thread Bert Gunter
Please look at what you wrote. get.symbols vs. getSymbols. -- Bert On Wed, Dec 18, 2024 at 7:56 AM Phil Smith via R-help wrote: > > Hello r-project: > > I want to load and use the tiny quant libary. > > Hello R-project: > > get.symbols doesn't work this morning. > > I use this code: > >

Re: [R] Mutate issue help needed

2024-12-17 Thread Bert Gunter
Bruce, You failed to post (some of) your data using dput() as was requested by John Kane. The reason that this is important is that it would tell us exactly what your data consist of -- i.e date-times, character, factors, etc. -- which your use of cut and paste does not. So if for some reason you

Re: [R] Weird Behavior of mean

2024-12-13 Thread Bert Gunter
ributes including names. > Character strings ‘c("T", "TRUE", "True", "true")’ are regarded as > true, ‘c("F", "FALSE", "False", "false")’ as false, and all others > as ‘NA’. > > > On

Re: [R] Weird Behavior of mean

2024-12-13 Thread Bert Gunter
Ivo, et al.: --IMHO only ... and with apologies for verbosity Defining, let alone enforcing, "consistent behavior" can be a philosophical conundrum: what one person deems "consistent" behavior for a function across different data structures and circumstances may not be the same as another's. While

Re: [R] Confirmation of no Electronic Communication functionality

2024-12-13 Thread Bert Gunter
Thanks, Ivan. Exactly my reaction. And as a Turing complete language, R allows one to do anything in R -- including writing an email package that does email directly from R: see package emayili . Indeed, I think one would find it difficult to find *any* software that does not interact with the in

Re: [R] SQL and R

2024-12-11 Thread Bert Gunter
Just a slight technical note -- Ben gave you a good answer already, imo. The note is: R is Turing complete, which mean that *anything* any language can do, R could be programmed to do also. The point is what can be done well in R and what can be done (often much) better with other tools, as Ben ex

Re: [R] Spreadsheets data

2024-12-05 Thread Bert Gunter
Please read **and follow** the posting guide linked below to learn how to ask for help on this list. Cheers, Bert On Thu, Dec 5, 2024 at 2:16 PM Figueiredo, Carlos via R-help wrote: > > Hi there > > > I want to create a script in Rstudio and load in the reagent dataset ensuring > that the diffe

Re: [R] Undocumented behaviour of diag when replacing the diagonal of a matrix?

2024-12-05 Thread Bert Gunter
tps://www.uni-giessen.de/math/eichner > - > > Am 04.12.2024 um 14:38 schrieb Bert Gunter: > > matrices are vectors with a "dim" attribute. > > So what I think is happening is: > > > >> A &

Re: [R] Undocumented behaviour of diag when replacing the diagonal of a matrix?

2024-12-04 Thread Bert Gunter
matrices are vectors with a "dim" attribute. So what I think is happening is: > A <- matrix(1:25, nrow = 5, ncol = 5) > diag(A[-1,]) <- 0 > A [,1] [,2] [,3] [,4] [,5] [1,]16 11 16 21 [2,]07 12 17 22 [3,]30 13 18 23 [4,]490 19 24 [5,]

Re: [R] Identify first row of each ID within a data frame, create a variable first =1 for the first row and first=0 of all other rows

2024-12-01 Thread Bert Gunter
riatrics Research, Education, and Clinical Center; > PI Biostatistics and Informatics Core, University of Maryland School of > Medicine Claude D. Pepper Older Americans Independence Center; > Senior Statistician University of Maryland Center for Vascular Research; > > Division of Geron

Re: [R] Identify first row of each ID within a data frame, create a variable first =1 for the first row and first=0 of all other rows

2024-12-01 Thread Bert Gunter
Rui: "f these two, diff is faster. But of all the solutions posted so far, Ben Bolker's is the fastest." But the explicit version of diff is still considerably faster: > D <- c(rep(1,10),rep(2,6),rep(3,2)) > microbenchmark(c(1L,diff(D)), times = 1000L) Unit: microseconds expr min

Re: [R] Identify first row of each ID within a data frame, create a variable first =1 for the first row and first=0 of all other rows

2024-11-30 Thread Bert Gunter
May I ask *why* you want to do this? It sounds to me like like you're using SAS-like strategies for your data analysis rather than R-like. -- Bert -- Bert On Sat, Nov 30, 2024 at 6:27 PM Sorkin, John wrote: > > Dear R help folks, > > First my apologizes for sending several related questions to

Re: [R] Trying to get the prior value of a record from a data.frame . . . data.frame

2024-11-30 Thread Bert Gunter
I assume that the responses that John already received to his recent post met his needs. However, when I read it, I had a slightly different interpretation. So feel free to ignore the rest of this post if you like, but here's my interpretation and a simple solution to it. An example to help explai

Re: [R] R Processing dataframe by group - equivalent to SAS by group processing with a first. and retain statments

2024-11-27 Thread Bert Gunter
The grouping solutions offered seem to be the obvious way to do this and may even be more efficient in R then what follows below. However, note that they are to some extent doing unnecessary work, since the ordering in the data frame already implicitly provides the grouping, and the hashing or wha

Re: [R] R coding to extract allele frequencies from NCBI for ALL alleles of one SNP?

2024-11-15 Thread Bert Gunter
If you haven't already done so, this might be better posted on Bioconductor: https://www.bioconductor.org/ Cheers, Bert On Fri, Nov 15, 2024 at 2:53 AM Clark Jeremy wrote: > Dear All, > > The following code extracts from NCBI very nice output for ONE allele of a > SNP (often the allele with th

Re: [R] Limit

2024-11-08 Thread Bert Gunter
Is the problem reading the file in or processing it after it has been read in? Bert On Fri, Nov 8, 2024 at 5:13 PM Jeff Newmiller via R-help < r-help@r-project.org> wrote: > Can you tell us what is wrong with the "chunked" package which comes up > when you Google "r read large file in chunks"? >

Re: [R] Using multiple dat files

2024-11-06 Thread Bert Gunter
Sorry, wrong language. "through the function's closures" in my email should be: through the function's chain of environments. (A function in R *is* a closure). -- Bert On Wed, Nov 6, 2024 at 12:46 PM Bert Gunter wrote: > "It seems therefore that there

Re: [R] Using multiple dat files

2024-11-06 Thread Bert Gunter
0 1990 1990 1990 1990 1990 1990 1990 1990 ... > $ DOY : num 1 2 3 4 5 6 7 8 9 10 ... > $ Ta: num -2.67 -2.77 -2.23 -2.21 -0.98 0.82 0.49 -1.02 -2.31 -3.36 ... > $ Tmin : num -3.5 -3.7 -4.26 -2.87 -2.98 0.3 -0.83 -1.27 -3 -3.82 ... > $ Tmax : num -1.13 -0.15 -0.13 -0.45 1

Re: [R] Using multiple dat files

2024-11-06 Thread Bert Gunter
Not quite sure if I understand you. list.files() simply returns a character vector(not a list). You can simply use a vector index to select whatever file you wish to read. So if your desired filename is the 5th element of filelist above, something like myfile <- read.table(filename[5], ...) You

Re: [R] readLines() and unz() and non-empty final line

2024-10-24 Thread Bert Gunter
But note: > zip("hello.zip", "hello.txt") updating: hello.txt (stored 0%) > readChar(unz("hello.zip","hello.txt"),100) [1] "hello" I leave it to you and other wiser heads to figure out. Cheers, Bert On Thu, Oct 24, 2024 at 8:57 AM Iris Simmons wrote: > Hi Mikko, > > > I tried running a few di

Re: [R] JASP vs R

2024-10-17 Thread Bert Gunter
Thomas: 1. I have no knowledge of JASP 2. I am pretty sure that the answer strongly depends on what sort of statistics one needs to do. I am also certain that no GUI out there can come close to R's breadth and depth of capabilities. 3. There are many GUIs for R. Here's one fairly recent discussi

[R] Coda: On the efficiency of unsplit() for Rolf Turner's recent post

2024-10-06 Thread Bert Gunter
(only of interest -- maybe! -- to those who followed this thread of a couple of weeks ago) Just for the heckuva it, I compared the timing of Deepayan's unsplit(x,f) solution to my as.vector(do.call(rbind, x)) approach to the query for a list of 3 vectors each of length 1000 (the original toy examp

Re: [R] Is there a sexy way ...?

2024-09-27 Thread Bert Gunter
:33 AM Deepayan Sarkar > > > wrote: > > >> > > >> > unsplit(x, f) > > >> [1] 7 2 6 13 5 9 1 14 15 4 8 12 10 11 3 > > >> > > >> Is more general (works if the subgroups are imbalanced), and hopefully > > more > > >> se

Re: [R] Is there a sexy way ...?

2024-09-26 Thread Bert Gunter
... And, in fact, I just realized that c(do.call(rbind, x)) is even better. -- Bert On Thu, Sep 26, 2024 at 9:26 PM Bert Gunter wrote: > Sorry, hit send by accident. > The 2-line version is: > > x <- do.call(rbind, x) > dim(x) <- NULL > > Cheers, > Bert >

Re: [R] Is there a sexy way ...?

2024-09-26 Thread Bert Gunter
Sorry, hit send by accident. The 2-line version is: x <- do.call(rbind, x) dim(x) <- NULL Cheers, Bert On Thu, Sep 26, 2024 at 9:23 PM Bert Gunter wrote: > How about: > as.vector(do.call(rbind,x)) > > Cheers, > Bert > > > > > However, I much prefer a 2 li

Re: [R] Is there a sexy way ...?

2024-09-26 Thread Bert Gunter
How about: as.vector(do.call(rbind,x)) Cheers, Bert However, I much prefer a 2 line version: On Thu, Sep 26, 2024 at 8:56 PM Rolf Turner wrote: > > I have (toy example): > > x <- list(`1` = c(7, 13, 1, 4, 10), > `2` = c(2, 5, 14, 8, 11), > `3` = c(6, 9, 15, 12, 3)) > an

[R] OFF TOPIC: "Scientific rigor proponents retract paper on benefits of scientific rigor"

2024-09-25 Thread Bert Gunter
This is off topic and only tangentially related to statistics or R (through "HARK"ing -- Hypothesizing After Results are Known). But given the research interests of many on this list, I thought others would enjoy it. My apologies if I have overstepped (please let me know if so). Also, PLEASE DON'T

Re: [R] Problem with converting grib file to excel

2024-09-24 Thread Bert Gunter
You might try posting on r-sig-geo if you don't get a satisfactory response here. I assume there's a lot of expertise there on handling raster-type data. Cheers, Bert On Mon, Sep 23, 2024 at 11:31 PM javad bayat wrote: > > Dear R users; > I have downloaded a grib file format (Met.grib) and I wan

Re: [R] Loading multiple packages with install.packages()...

2024-09-23 Thread Bert Gunter
"If you can get a vector with all the package names (I do not know how to do this)..." See ?available.packages grep-ing the rownames of the available.packages() result appropriately should give you a vector of the desired package names to install, which can then be given to install.packages. ...

Re: [R] store list objects in data.table

2024-09-21 Thread Bert Gunter
Well, you may have good reasons to do things this way -- and you certainly do not have to explain them here. But you might wish to consider using R's poly() function and a basic nested list structure to do something quite similar that seems much simpler to me, anyway: x <- rnorm(20) df <- data.fr

Re: [R] (no subject)

2024-09-16 Thread Bert Gunter
Hmmm... typos and thinkos ? Maybe: mean_narm<- function(x) { m <- mean(x, na.rm = T) if (is.nan (m)) NA else m } -- Bert On Mon, Sep 16, 2024 at 4:40 PM CALUM POLWART wrote: > > Rui's solution is good. > > Bert's suggestion is also good! > > For Berts suggestion you'd make the list bit >

Re: [R] (no subject)

2024-09-16 Thread Bert Gunter
need to go there and need help. Cheers, Bert On Mon, Sep 16, 2024 at 11:02 AM Bert Gunter wrote: > > It's NA *not* Na. Details matter. > > Ah, but note: > > mean(c(NA,NA), na.rm = TRUE) > [1] NaN > > So if that might happen, you'll have to write your own mean fun

Re: [R] (no subject)

2024-09-16 Thread Bert Gunter
ncesca wrote: > > All' Na Is Na. > > > Il lun 16 set 2024, 16:29 Bert Gunter ha scritto: >> >> See the na.rm argument of ?mean >> >> But what happens if all values are NA? >> >> -- Bert >> >> >> On Mon, Sep 16, 2024 at 7:24 AM Fr

Re: [R] (no subject)

2024-09-16 Thread Bert Gunter
See the na.rm argument of ?mean But what happens if all values are NA? -- Bert On Mon, Sep 16, 2024 at 7:24 AM Francesca wrote: > > Sorry for posting a non understandable code. In my screen the dataset > looked correctly. > > > I recreated my dataset, folllowing your example: > > test<-data.fr

Re: [R] how to specify point symbols in the key on a lattice dotplot

2024-09-13 Thread Bert Gunter
Oh, and for correct syntax with R's |> operator, "data = ." , should be "data = _" ; although the former seemed to work. -- Bert On Fri, Sep 13, 2024 at 10:45 AM Bert Gunter wrote: > > "Why does key = list(points = 16:17) not work? " > >

Re: [R] how to specify point symbols in the key on a lattice dotplot

2024-09-13 Thread Bert Gunter
"Why does key = list(points = 16:17) not work? " Because, from the "key" section of ?xyplot " The contents of the key are determined by (possibly repeated) components named "rectangles", "lines", "points" or "text". Each of these must be **lists** with relevant graphical parameters (see later) co

Re: [R] Reading a txt file from internet

2024-09-07 Thread Bert Gunter
Ha, the proper answer! Thanks for this, Iris. I followed up by consulting the Wikipedia "byte order mark" entry and learned something I knew nothing about. FWIW, if I had simply searched on t it would have immediately led me to BOMs. Best, Bert On Sat, Sep 7, 2024 at 1:30 PM Iris Simmons wrote:

Re: [R] Reading a txt file from internet

2024-09-07 Thread Bert Gunter
Well, this is frankly an unsatisfactory answer, as it does not try to deal properly with the issues that you experienced, which I also did. However, it's simple and works. As this is a small text file, simply copy it in your browser to the clipboard, and then use: thefile <- read.table(text = "", h

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

2024-09-05 Thread Bert Gunter
efined > -> 0 + 0i + Inf i + NaN * i^2 > -> 0 + 0i + Inf i - NaN > -> NaN + Inf i > > I am not sure how complex arithmetic could arrive at another answer. > > I advise against messing with infinities... use atan2() if you don't > actually need complex arithmetic.

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

2024-09-05 Thread Bert Gunter
l division/multiplication on a > complex number. Which R actually does for these very particular cases; but > not when only Im(x) is Inf. > > Sincerely, > > Leonard > > -- > *From:* Bert Gunter > *Sent:* Friday, September 6, 2024 1:12 AM

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

2024-09-05 Thread Bert Gunter
Perhaps > Inf*1i [1] NaN+Infi clarifies why it is *not* a bug. (Boy, did that jog some long dusty math memories :-) ) -- Bert On Thu, Sep 5, 2024 at 2:48 PM Duncan Murdoch wrote: > On 2024-09-05 4:23 p.m., Leo Mada via R-help wrote: > > Dear R Users, > > > > Is this desired behaviour? > > I

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

2024-09-05 Thread Bert Gunter
What version of R are you using and on what platform? I get: > atan(1i) [1] 0.7853982+Infi > atan(1i)/5 [1] NaN+Infi on: R version 4.4.1 (2024-06-14) Platform: aarch64-apple-darwin20 Running under: macOS Sonoma 14.6.1 -- Bert On Thu, Sep 5, 2024 at 1:23 PM Leo Mada via R-help wrote: > Dear R

Re: [R] lattice log scale labels.

2024-09-05 Thread Bert Gunter
Do the "at" and "labels" components of the "scales" list argument to xyplot not do what you want? Cheers, Bert On Thu, Sep 5, 2024 at 4:05 AM Gerrit Draisma wrote: > Dear R-helpers, > > In the plot below I would like to have labels at positions 2^(3*(0:10)), > and keep the labels in the exponen

Re: [R] fixed set.seed + kmeans output disagree on distinct platforms

2024-09-03 Thread Bert Gunter
I have no clue, but I did note that you are using different versions of BLAS/LAPACK on the different platforms. Could that be (part) of the issue? Cheers, Bert On Tue, Sep 3, 2024 at 10:24 PM Iago Giné Vázquez wrote: > Hi all, > > I build a dataset processing in the same way the same data in Wi

Re: [R] Fill NA values in columns with values of another column

2024-08-29 Thread Bert Gunter
n. > > On August 29, 2024 2:29:16 PM PDT, Bert Gunter > wrote: > >Petr et.al: > > > >I think using merge is a very nice idea! (note that the email omitted the > >last rows of the result, though your code of course produced them) > > > >The only minor

  1   2   3   4   5   6   7   8   9   10   >