Re: [R] Estimating regression with constraints in model coefficients

2025-04-21 Thread Ben Bolker
Section 2 of the vignette for the ordinal package: https://cran.r-project.org/web/packages/ordinal/vignettes/clm_article.pdf gives a reasonably complete, if short, definition/discussion of the log-likelihood framework for ordinal models. It's probably also discussed in Venables and Ripley

Re: [R] Is it odd or not? about I() function

2025-04-19 Thread Ben Bolker
This is obviously not a complete answer, but if you look at the data closely: str(dta) 'data.frame': 40 obs. of 6 variables: $ x : num 0.915 0.937 0.286 0.83 0.642 ... $ y : num 0.3796 0.4358 0.0374 0.9735 0.4318 ... $ z : int 1 1 1 1 1 1 1 1 1 1 .

Re: [R] problem with my base_df function ?

2025-04-16 Thread Ben Bolker
advice is to start debugging at the *first* error (or even warning) you see in your code; problems often cascade, leading to less useful diagnostics farther downstream ... Ben Bolker On 2025-04-16 12:30 p.m., varin sacha wrote: Sorry, At the end of the code I get an error message Error

Re: [R] problem with my base_df function ?

2025-04-16 Thread Ben Bolker
Unless this is a continuation of a conversation I missed the beginning of, you haven't told us enough yet for us to help you. What is your problem? Do you get an error? Does the code give you an incorrect result? How do you know? (It's possible that I could figure out that your code hits

Re: [R] How to find inverse of glm model?

2025-04-15 Thread Ben Bolker
ept)`)/Cycles) You might find the drc package useful as well. cheers Ben Bolker On 4/15/25 08:57, Luigi Marongiu wrote: I have fitted a glm model to some data; how can I find the inverse function of this model? Since I don't know the y=f(x) implemented by glm (this works under the hood),

Re: [R] Error in running get_acs()

2025-04-09 Thread Ben Bolker
This might be related: https://bsky.app/profile/kylewalker.bsky.social/post/3lm3ivicrxc2q > The Census website has been blocking requests from tigris (and curl) since yesterday. (Don’t worry, the datasets are still there!) I’ve patched tigris, install with `pak::pak("walkerke/tigris@

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

2025-04-05 Thread Ben Bolker
I'm still not entirely clear what you want, in particular what you want to with factor variables ('squaring' them doesn't really seem to make sense). Some combination of sprintf/paste/reformulate might do what you want: ## get all second-order terms (doesn't square numeric values) quad_terms

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

2025-03-09 Thread Ben Bolker
I agree with Duncan. From an abstract point of view it would be interesting, and possibly useful, to analyze exactly what is going 'wrong' (in some sense) with R's built-in string-to-double function in this case, and might lead to some marginal improvements. But if you are doing anything bu

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

2025-03-09 Thread Ben Bolker
ur own strtod/atof to mitigate effects of setting LC_NUMERIC Also allows complete control of which non-numeric strings are accepted; e.g. glibc allows NAN, macOS NAN(s), this accepts "NA". ... */ Should this be escalated to r-devel (or r-bugzilla)? Nothing pops out at me from

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

2025-03-09 Thread Ben Bolker
I can't reproduce this locally. sprintf("%0.15f", as.numeric("-17725.33343267441")) [1] "-17725.33343267441" R Under development (unstable) (2025-03-08 r87909) Platform: x86_64-pc-linux-gnu Running under: Ubuntu 24.04.2 LTS On 3/9/25 13:12, Christofer Bogaso wrote: Hi, I h

Re: [R] Compressing a sequence

2025-02-21 Thread Ben Bolker
)) z <- c(1, 3, 4, 5, 7, 8, 12, 13, 14, 15, 20) condense(z) |> paste(collapse = ", ") "1, 3-5, 7-8, 12-15, 20" On 2025-02-21 9:16 p.m., Ben Bolker wrote:   There are some answers from 2016 here: https://stackoverflow.com/questions/34636461/collapse-consecutive-

Re: [R] Compressing a sequence

2025-02-21 Thread Ben Bolker
There are some answers from 2016 here: https://stackoverflow.com/questions/34636461/collapse-consecutive-runs-of-numbers-to-a-string-of-ranges On 2025-02-21 7:59 p.m., Steven Ellis wrote: Hi Dennis, A quick Claude request: "using r I have a sequence like:1, 3, 4, 5, 7, 8, 12, 13, 14

Re: [R] Bayesian VAR

2025-02-21 Thread Ben Bolker
More specifically, there is an issues list for the package here: https://github.com/nk027/bvar/issues (I got there by looking at the BugReports: field in the package description at https://CRAN.R-project.org/package=BVAR ) cheers Ben Bolker On 2/21/25 11:07, Bert Gunter wrote: It

Re: [R] How to specify a quadratic term in the contrast function

2025-02-18 Thread Ben Bolker
Looking at the 'contrasts' function, it seems to be imported from 'rms' and to take only 'rms'-type fits (which are different from base-R [g]lm() fits) as input. I'm not sure exactly what contrasts you're trying to generate, but I would probably use the emmeans package for the task, since

Re: [R] Reverse dependency checking

2025-02-13 Thread Ben Bolker
For what it's worth I use https://github.com/r-lib/revdepcheck (see also https://revdepcheck.r-lib.org/ ) ... it has some of its own warts, but it has a very informative progress bar. On 2025-02-13 8:43 a.m., Duncan Murdoch wrote: On 2025-02-12 4:42 p.m., Lenth, Russell V via R-help wrote:

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

2025-01-27 Thread Ben Bolker
This might be better for r-package-de...@r-project.org (since you're asking a question about package-checking). This is a common problem when using non-standard evaluation. Typically you can either use `utils::globalVariables` or set these variables to NULL near the top of your function.

Re: [R] Details about the boxcox function

2025-01-23 Thread Ben Bolker
MASS:::boxcox.lm (three :) which will lead you quickly to MASS:::boxcox.default where the real work gets done. cheers Ben Bolker On 1/23/25 13:22, Daniel Lobo wrote: Hi, I tried with library(MASS) methods('boxcox') # [1] boxcox.default* boxcox.formula* boxcox

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

2025-01-07 Thread Ben Bolker
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 func

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

2024-12-24 Thread Ben Bolker
?sigma On 12/24/24 10:13, Bert Gunter wrote: ?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

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

2024-12-24 Thread Ben Bolker
vcov(). ? On Tue, Dec 24, 2024, 8:45 AM Christofer Bogaso wrote: > Hi, > > I have below GLM fit > > clotting <- data.frame( > u = c(5,10,15,20,30,40,60,80,100), > lot1 = c(118,58,42,35,27,25,21,19,18), > lot2 = c(69,35,26,21,18,16,13,12,12)) > summary(glm(lot1 ~ log(u), data = clotti

Re: [R] Weird Behavior of mean

2024-12-13 Thread Ben Bolker
Thanks, I had missed/forgotten the fact that there is also an inconsistency between mean.default() and sd(). sd() calls var(), which evaluates if(na.rm) [i.e., it will try to coerce `na.rm` to logical rather than testing isTRUE] IM(H?)O, it would be best for both mean.default() and sd()

Re: [R] Non linear optimization with nloptr package fail to produce true optimal result

2024-12-13 Thread Ben Bolker
It's a long way from "X works better than Y on this particular problem" to "X is superior to Y". It's a somewhat loose analogy, but the 'no free lunch theorem' asserts that if we consider a broad enough class of optimization problems, *no* op

Re: [R] Weird Behavior of mean

2024-12-13 Thread Ben Bolker
This example is a little more subtle than that; the OP knows about name masking, but was expecting T to be coerced to logical, which would ordinarily be a reasonable expectation (IMO) ... On Fri, Dec 13, 2024 at 3:40 PM Jeff Newmiller via R-help wrote: > > This was documented in [1] forever ago

Re: [R] Non linear optimization with nloptr package fail to produce true optimal result

2024-12-13 Thread Ben Bolker
Fortune candidate? (Prof Zeileis, are you still collecting these?) Optimizers are like other tools. Some are chainsaws, others are scalpels. Don't do neurosurgery with a chainsaw unless you want a mess. __ R-help@r-project.org mailing list -- To

Re: [R] Confirmation of no Electronic Communication functionality

2024-12-13 Thread Ben Bolker
;t go out of my way to tell them about system() ... cheers Ben Bolker On 12/13/24 11:04, Sergei Ko wrote: I suspect it might be relevant for RStudio, but definitely not for pure R. On top of that you can just copy R to a flash drive or any accessible folder. It will work. Regards, Sergiy O

Re: [R] SQL and R

2024-12-11 Thread Ben Bolker
(arrow, dbplyr) that provide alternative big-data workflows. cheers Ben Bolker On 12/11/24 08:16, akshay kulkarni wrote: dear Members, I have recently started studying SQL and MySQL. My question is, what exactly is SQL used for? That is, whatever can be done

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 Ben Bolker
I think as.numeric(! duplicated(group)) might do this for you ... On Sat, Nov 30, 2024, 9:27 PM Sorkin, John wrote: > Dear R help folks, > > First my apologizes for sending several related questions to the list > server. I am trying to learn how to manipulate data in R . . . and am > having diff

Re: [R] Using vi syntax in command line editing.

2024-11-25 Thread Ben Bolker
Maybe https://stackoverflow.com/questions/6235034/vi-keybindings-for-r-command-line-like-in-bash ?? (tl;dr "set editing-mode vi" or "set keymap vi" in .inputrc ... ) On 11/25/24 20:09, Rolf Turner wrote: I have recently acquired a new laptop. (My old one was giving me ominous messages o

Re: [R] Limit

2024-11-08 Thread Ben Bolker
Check the "high performance task view" on CRAN ... https://cran.r-project.org/web/views/HighPerformanceComputing.html On Fri, Nov 8, 2024, 7:58 PM Val wrote: > Hi All, > > I am reading data file ( > 1B rows) and do some date formatting like > dat=fread(mydatafile) > dat$date1 <- as.Da

Re: [R] apply

2024-10-04 Thread Ben Bolker
It's still hard to figure out what you want. If you have two vectors you can compute their (2x2) covariance matrix using cov(cbind(x,y)). If you want to compute all pairwise squared differences between elements of x and y you could use outer(x, y, "-")^2. Can you explain a little bit more

Re: [R] when installing packages for R on Linux, is it better to use my distro's package manager, or install.packages()?

2024-09-28 Thread Ben Bolker
Use Dirk Eddelbuettel's r2u repo with bspm package On Sat, Sep 28, 2024, 6:15 PM Stephen H. Dawson, DSL via R-help < r-help@r-project.org> wrote: > Distribution package manger, always. > > *Stephen Dawson, DSL* > /Executive Strategy Consultant/ > Business & Technology > +1 (865) 804-3454 > http:/

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

2024-09-23 Thread Ben Bolker
Continuing with this approach: a1 <- available.packages() packages <- grep("^rcmdrplugin", rownames(a1), ignore.case = TRUE, value = TRUE) missing_pkgs <- setdiff(packages, rownames(installed.packages())) install.packages(missing_pkgs, dependencies = TRUE) The pacman package also handles s

Re: [R] Calculation of VCV matrix of estimated coefficient

2024-09-04 Thread Ben Bolker
The number you need for MSE is sum(residuals(model)^2)/df.residual(model) On Wed, Sep 4, 2024 at 3:34 PM Daniel Lobo wrote: > > Hi, > > I am trying to replicate the R's result for VCV matrix of estimated > coefficients from linear model as below > > data(mtcars) > model <- lm(mpg~disp+hp, data=m

Re: [R] Adding parameters for Benchmark normal distribution in shapiro.test

2024-09-02 Thread Ben Bolker
From Shapiro and Wilk's paper: > The objective is to derive a test for the hypothesis that this is a sample from a normal distribution with unknown mean mu and unknown variance sigma^2 That is, the estimates of the mean and SD are folded into the derivation of the test statistic. If y

Re: [R] boxplot of raster and shapefile

2024-08-28 Thread Ben Tupper
nd v are detailed. So, if you read your raster data with terra::rast() rather than raster::raster() your r variable will be of type 'SpatRaster' then your signatures will be extract(SpatRaster, SpatVector) which should work. CHeers, Ben On Wed, Aug 28, 2024 at 3:35 AM SIBYLLE STÖCK

Re: [R] A question on Statistics regarding regression

2024-08-24 Thread Ben Bolker
  This is probably better for Cross Validated [https://stats.stackexchange.com]. Surprisingly, I can't quickly find an answered question on this topic. My "tl;dr" answer would be: "inflated" relative to what? Having an unbalanced sample certainly decreases the *power* of an analysis, but there'

Re: [R] allequal diff

2024-08-18 Thread Ben Bolker
   The OP's original problem is that the all.equal method for raster objects (raster:::all.equal.raster), which is a wrapper around the compareRaster() function, compares a bunch of different properties of rasters (extent, resolution, values, etc.) and only returns a single overall logical (TRU

Re: [R] allequal diff

2024-08-18 Thread Ben Bolker
  To do this, I think you'll have to compare the extent (using the extent() function) and/or number of rows and columns and/or resolution of the two rasters. (Print the source code of compareRasters() and dig through it to see what's being compared ...) On 8/18/24 14:00, SIBYLLE STÖCKLI via R-

Re: [R] boxplot notch

2024-08-16 Thread Ben Bolker
I don't see anything obviously wrong here. There may be something subtle, but we probably won't be able to help without a reproducible example ... On 2024-08-16 9:24 a.m., SIBYLLE STÖCKLI via R-help wrote: Dear community I tried the following code using geom_boxplot() and notch=TRUE. D

Re: [R] allequal diff

2024-08-15 Thread Ben Bolker
Digging into the code for raster::compareRaster(): library(raster) r <- raster(ncol=3, nrow=3) values(r) <- 1:ncell(r) r2 <- r values(r2) <- c(1:8,10) all.equal(getValues(r), getValues(r2), tolerance = 0) [1] "Mean relative difference: 0.111" compareRaster has fancier machinery intern

Re: [R] Determining the Correct Help List

2024-08-12 Thread Ben Bolker
And the author & maintainer of rgl is pretty active here too ... On 2024-08-12 4:15 p.m., Bert Gunter wrote: As lattice is a core R package, I'd say right here, R-Help. -- Bert On Mon, Aug 12, 2024 at 1:07 PM Erin Hodgess wrote: Hello everyone: I have a few questions about using rgl, lat

Re: [R] a fast way to do my job

2024-08-09 Thread Ben Bolker
You can also fit a linear model with a matrix-valued response variable, which should be even faster (not sure off the top of my head how to get the residuals and reshape them to the dimensions you want) On Fri, Aug 9, 2024 at 9:31 PM Bert Gunter wrote: > > See ?lm.fit. > I must be missing somethi

Re: [R] Regarding the Security Vulnerability CVE 2024 - 27322

2024-06-26 Thread Ben Bolker
ot;, but they did allow us to use R. It would have made things very inconvenient if I had told them about the system() command, so I didn't bother ... Ben Bolker __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.e

Re: [R] Naming output file

2024-06-24 Thread Ben Bolker
As stated earlier in the thread, this is where you would need to use get(paste0("bop", im)) [the analogue of assign]. This unwieldiness is the exact reason that several posters are encouraging you to change your approach and store these objects in a list ... On 2024-06-24 8:16 a.m., Steven

Re: [R] I have Problem using the Pipe Command

2024-06-18 Thread Ben Bolker
You probably have to update your R version. The native pipe |> wasn't introduced until R version 4.4. R.version.string (among others) will tell you what version you have. If you don't want to do that, install and load the 'magrittr' package and change |> to %>% everywhere. On 2024-06-18

Re: [R] Column names of model.matrix's output with contrast.arg

2024-06-17 Thread Ben Bolker
It's sorta-kinda-obliquely-partially documented in the examples: zapsmall(cP <- contr.poly(3)) # Linear and Quadratic output: .L .Q [1,] -0.7071068 0.4082483 [2,] 0.000 -0.8164966 [3,] 0.7071068 0.4082483 FWIW the faux package provides better-named alternatives.

Re: [R] nc file

2024-06-04 Thread Ben Bolker
This question is unfortunately too vague for us to help you. A little bit of web-searching turned up this tutorial: maybe that will help? https://rpubs.com/boyerag/297592 On 2024-06-04 6:49 a.m., Farzad Ghooshi wrote: Hello I am a PhD student in ecology. The subject of my thesis is climate

Re: [R] Current version of R, 4.4.0 and patch to correct the bug fix related to the RStudio viewer pane on Windows systems

2024-05-16 Thread Ben Bolker
important issue, but I'm not optimistic about that ... Ben Bolker On 2024-05-16 1:38 p.m., CALUM POLWART wrote: Do you receive RDS objects from unknown (untrusted) sources? ?? If not - the security issue is a non-issue as I understand it. On Thu, 16 May 2024, 16:21 Vega, Ann (she/her/h

Re: [R] Print date on y axis with month, day, and year

2024-05-09 Thread Ben Bolker
gg0 <- ggplot(data=yyy[1:30,],aes(as.Date(jdate,format="%m-%d-%Y"),Sum)) +geom_point() gg0 + scale_x_date(date_labels = "%m/%d/%Y") On 2024-05-09 7:58 p.m., Sorkin, John wrote: I am trying to use ggplot to plot the data, and R code, below. The dates (jdate) are printing as Mar 01, Mar 15, etc

Re: [R] Get a copy of a matrix only for TRUE entries of a matching size boolean matrix?

2024-05-03 Thread Ben Bolker
In two steps: result <- matrix(NA_character_, nrow=nrow(mat_letters), ncol =ncol(mat_letters)) result[mat_bools] <- mat_letters[mat_bools] On 2024-05-03 8:47 a.m., DynV Montrealer wrote: Is there a way to get a copy of a matrix only for TRUE entries of a matching size boolean matrix? For *

Re: [R] x[0]: Can '0' be made an allowed index in R?

2024-04-21 Thread Ben Bolker
Also https://cran.r-project.org/package=Oarray (which is older and hence possibly more stable) On 2024-04-21 3:55 a.m., Hans W wrote: As we all know, in R indices for vectors start with 1, i.e, x[0] is not a correct expression. Some algorithms, e.g. in graph theory or combinatorics, are much

Re: [R] x[0]: Can '0' be made an allowed index in R?

2024-04-21 Thread Ben Bolker
https://cran.r-project.org/package=index0 On Sun, Apr 21, 2024, 3:56 AM Hans W wrote: > As we all know, in R indices for vectors start with 1, i.e, x[0] is not a > correct expression. Some algorithms, e.g. in graph theory or combinatorics, > are much easier to formulate and code if 0 is an allow

Re: [R] Printout and saved results

2024-03-26 Thread Ben Bolker
Fragile and probably a bad idea, but: "%.%" <- function(x,y) { assign(deparse(substitute(x)), y, parent.frame()); print(y) } > a %.% "hello" [1] "hello" > a [1] "hello" Not sure how much value this has over other idioms such as wrapping the assignment in parentheses, which makes

Re: [R] as.complex()

2024-03-25 Thread Ben Bolker
That's hard to define unambiguously at a mathematical level. What definition did you have in mind? Can you provide more context? (Maybe you want to compare Mod(x) to Mod(y) ?) On 2024-03-25 3:23 a.m., Thomas K wrote: Needing a < , > comparison for imaginary numbers __

Re: [R] an issue about subsetting a vector

2024-03-24 Thread Ben Bolker
As with a lot of things in R, the behaviour is counterintuitive but (arguably) logical. The key (maybe) is that `a[-x]` does not mean "take all of the elements of a except those indicated by `x`, but rather, "negate x, then take all but the negative elements". In other words, -integer(0)

Re: [R] Building Packages.

2024-03-21 Thread Ben Bolker
ent from utils::install.packages (e.g. add a possibility to say force=TRUE to override the "don't reinstall if already installed") ? cheers Ben On 2024-03-21 11:51 a.m., Duncan Murdoch wrote: I posted a description of their changes this morning. Duncan Murdoch On 21/03/2024 11:

Re: [R] Building Packages.

2024-03-21 Thread Ben Bolker
::disable() that you'll get back to the original-as-installed version. Even if you have RStudio installed you could change the association in your GUI file browser to open R files in emacs by default ... cheers Ben Bolker On 2024-03-21 4:40 a.m., Martin Maechler wrote: Ben Bolker o

Re: [R] Building Packages.

2024-03-20 Thread Ben Bolker
Hmm, looks platform-specific. Under Linux both RStudio and external R console return a0b52513622c41c11e3ef57c7a485767 for digest::digest(install.packages) On 2024-03-20 1:20 p.m., Duncan Murdoch wrote: On 20/03/2024 1:07 p.m., Duncan Murdoch wrote: On 20/03/2024 12:37 p.m., Ben Bolker

Re: [R] Building Packages.

2024-03-20 Thread Ben Bolker
identical results. I thought at one point this might only refer to the GUI package-installation interface, but you seem to be saying it's the install.packages() function as well. Running an up-to-date RStudio on Linux, FWIW -- maybe weirdness only happens on other OSs? Ben Bolke

Re: [R] Help

2024-02-22 Thread Ben Bolker
I agree that the posting guide is due for updating. If the mailing list maintainers were willing I think r-consult might not be a terrible idea. I do think the center of gravity has moved to Cross Validated, and it might be minimally sufficient to point people there (or Math Overflow for p

Re: [R] Use of geometric mean for geochemical concentrations

2024-01-22 Thread Ben Bolker
I think https://stats.stackexchange.com would be best: r-sig-ecology is pretty quiet these days On 2024-01-22 11:05 a.m., Rich Shepard wrote: On Mon, 22 Jan 2024, Bert Gunter wrote: better posted on r-sig-ecology? -- or maybe even stack exchange? Bert, Okay. Regards, Rich

Re: [R] Strange results : bootrstrp CIs

2024-01-13 Thread Ben Bolker
It took me a little while to figure this out, but: the problem is that if your resampling leaves out any countries (which is very likely), your model applied to the bootstrapped data will have fewer coefficients than your original model. I tried this: cc <- unique(e$Country) func <- functio

Re: [R] Obtaining a value of pie in a zero inflated model (fm-zinb2)

2024-01-07 Thread Ben Bolker
e of a closed-form solution for zero-inflation models as long as the count and/or structural-zero components depend on covariates? In any case, looking inside zeroinfl() you can see that it calls optim() [using BFGS by default, see ?pscl::zeroinfl.control] cheers Ben Bolker On 2024-01-04

Re: [R] ggplot2: Get the regression line with 95% confidence bands

2023-12-12 Thread Ben Bolker
Use scale_x_continuous() and specify your desired breaks On Tue, Dec 12, 2023, 4:19 PM varin sacha wrote: > Dear Ben, > Dear Daniel, > Dear Rui, > Dear Bert, > > Here below my R code. > I really appreciate all your comments. My R code is perfectly working but > there is

Re: [R] ggplot2: Get the regression line with 95% confidence bands

2023-12-11 Thread Ben Bolker
On 2023-12-11 5:27 p.m., Daniel Nordlund wrote: On 12/10/2023 2:50 PM, Rui Barradas wrote: Às 22:35 de 10/12/2023, varin sacha via R-help escreveu: Dear R-experts, Here below my R code, as my X-axis is "year", I must be missing one or more steps! I am trying to get the regression line wit

Re: [R] adding "Page X of XX" to PDFs

2023-12-02 Thread Ben Bolker
., Jeff Newmiller via R-help wrote: He clearly stated he was using the pdf() graphics device. On December 2, 2023 10:36:44 AM PST, Ben Bolker wrote: It's still not entirely clear to me what framework you're using to generate the PDF, but if it's rmarkdown/Rnw (Sweave)/Quarto-bas

Re: [R] adding "Page X of XX" to PDFs

2023-12-02 Thread Ben Bolker
It's still not entirely clear to me what framework you're using to generate the PDF, but if it's rmarkdown/Rnw (Sweave)/Quarto-based, then as far as I know all of those frameworks use LaTeX as the last step in the script-to-PDF pipeline, and allow the inclusion of arbitrary LaTeX code, so the

Re: [R] Mann Kendall mutation package?

2023-12-01 Thread Ben Bolker
Have you looked at the Kendall package? https://stackoverflow.com/questions/62288340/mann-kendall-in-r (you've cross-posted a version of this question to SO as well: https://stackoverflow.com/questions/77587426/what-is-the-algorithm-for-the-mann-kendall-mutation-test ) Please don't cross-p

Re: [R] Code editor for writing R code

2023-11-29 Thread Ben Bolker
Presumably there's nothing stopping you *writing* LaTeX in comments -- do you want a code editor that will render and display the LaTeX as you write? (Or am I misunderstanding something?) Does anyone do classic literate programming *sensu* Knuth any more? https://rpubs.com/bbolker/3153

Re: [R] Barplot for data frame

2023-11-29 Thread Ben Tupper
Another great resource is RSeek.org https://rseek.org/?q=barplot On Wed, Nov 29, 2023 at 4:26 AM Ivan Krylov wrote: > В Wed, 29 Nov 2023 00:29:49 + > Livio Beqiri пишет: > > > how can i create a vertical barplot that displays brands in x-axis > > and Revenue in Y-axis > > What have you tri

Re: [R] make a lattice dotplot with symbol size proportional to a variable in the plotted dataframe

2023-11-08 Thread Ben Bolker
Non-standard evaluation On 2023-11-08 10:56 a.m., Christopher W. Ryan via R-help wrote: Very helpful, Deepayan, and educational. Thank you. What does NSE stand for? Thanks, Chris Deepayan Sarkar wrote: --Chris Ryan __ R-help@r-project.org mail

Re: [R] How can I remove my packages from rdrr.io?

2023-11-01 Thread Ben Bolker
There is a github site with an issues list: https://github.com/rdrr-io/rdrr-issues/issues It looks like people have successfully requested removal in the past, e.g. https://github.com/rdrr-io/rdrr-issues/issues/113 On 2023-11-01 9:06 a.m., Kim Emilia wrote: Hello all, I would like to ta

Re: [R] weights vs. offset (negative binomial regression)

2023-10-31 Thread Ben Bolker
e it gives me significant effects" is automatically suspicious.) This would be a good question for CrossValidated (https://stats.stackexchange.com), you could try posting it there (I would be interested in the answer!) cheers Ben Bolker On 2023-10-30 8:19 p.m., 유준택 wrote: Dear

Re: [R] weights vs. offset (negative binomial regression)

2023-10-28 Thread Ben Bolker
general you should *not* check overdispersion of the raw data (i.e., the *marginal distribution* of the data, you should check overdispersion of a fitted (e.g. Poisson) model, as below. cheers Ben Bolker edata <- data.frame(Catch, Effort, xx1, xx2, xx3) ## graphical exploration libr

Re: [R] Need help to resolve the Error: evaluation nested too deeply: infinite recursion / options(expressions=)? Execution halted

2023-10-26 Thread Ben Bolker
Hmm, I can't replicate (i.e., it works fine for me). What are the results of your sessionInfo() (from a *clean* R session)? == R Under development (unstable) (2023-10-25 r85410) Platform: x86_64-pc-linux-gnu Running under: Pop!_OS 22.04 LTS Matrix products: default BLAS: /usr/local/lib/R/l

Re: [R] running crossvalidation many times MSE for Lasso regression

2023-10-23 Thread Ben Bolker
For what it's worth it looks like spm2 is specifically for *spatial* predictive modeling; presumably its version of CV is doing something spatially aware. I agree that glmnet is old and reliable. One might want to use a tidymodels wrapper to create pipelines where you can more easily swit

Re: [R] [Tagged] Re: Fwd: r-stats: Geometric Distribution

2023-10-19 Thread Ben Bolker
e of definition from yours. You can certainly write your code to do `dgeom(x-1, p)`: in fact, you could write a wrapper my_dgeom <- function(x, ...) dgeom(x-1, ...) so that you never have to think about it again ... cheers Ben Bolker On 2023-10-19 3:20 a.m., Jeff Newmiller via R

Re: [R] Yamamoto test in BreakPoints package

2023-10-19 Thread Ben Bolker
Maybe contact the package maintainer (maintainer("BreakPoints")) and ask? (Normally I avoid bugging package maintainers if I can, but it seems you've looked everywhere else you can ...) Ben Bolker On 2023-10-19 4:18 a.m., Richard O'Keefe wrote: Visit the page at

Re: [R] Best way to test for numeric digits?

2023-10-18 Thread Ben Bolker
There are some answers on Stack Overflow: https://stackoverflow.com/questions/14984989/how-to-avoid-warning-when-introducing-nas-by-coercion On 2023-10-18 10:59 a.m., Leonard Mada via R-help wrote: Dear List members, What is the best way to test for numeric digits? suppressWarnings(as.do

Re: [R] if-else that returns vector

2023-10-12 Thread Ben Bolker
how about if(T) c(1,2,3) else c(5,6) ? On 2023-10-12 4:22 p.m., Christofer Bogaso wrote: Hi, Following expression returns only the first element ifelse(T, c(1,2,3), c(5,6)) However I am looking for some one-liner expression like above which will return the entire vector. Is there any way

Re: [R] Linear discriminant analysis

2023-10-12 Thread Ben Bolker
It's possible that neither of these will help, but (1) you can look at the source code of the predict method (MASS:::predict.lda) (2) you can look at the source reference ("Modern Applied Statistics in S", Venables and Ripley) to see if it gives more information (although it might not); th

Re: [R] R issue / No buffer space available

2023-10-05 Thread Ben Bolker
This looks like an RStudio issue; it might be better to post the question on their forum On Thu, Oct 5, 2023, 7:43 AM Ohad Oren, MD wrote: > Hello, > > I keep getting the following message about 'no buffer space available'. I > am using R studio via connection to server. I verified that the conn

Re: [R] download.file strict certificate revocation check

2023-10-04 Thread Ben Bolker
51.0 4 2023-10-03 plotrix 3,082310 of 18,024 98.3 5 2023-10-03 prettyR90 1,954 of 18,024 89.1 It seems that at least plotrix and prettyR would be worth rescuing ... volunteers ... ? (prettyR has 1 strong reverse dep, plotrix has many ...) Ben Bolk

Re: [R] Question about R software and output

2023-10-03 Thread Ben Bolker
It's conceivable that functions in a contributed package would communicate/transmit or receive data from a remote server, but base R does nothing like that (unless you explicitly ask it to). cheers Ben Bolker On 2023-10-02 3:48 a.m., Ferguson Charity (CEMINFERGUSON) wrote: To wh

Re: [R] replace character by numeric value

2023-09-29 Thread Ben Bolker
The reason you're getting the result as character is that you have 'side' as your alternative result in the second ifelse(). If "BUY" and "SELL" are the only options you might try ifelse(side == 'BUY', 1, ifelse(side == 'SELL', -1, NA)) or c(1,-1)[match(side, c("BUY", "SELL"))] or

Re: [R] Odd result

2023-09-24 Thread Ben Bolker
For what it's worth the janitor::remove_empty() (which removes all-NA rows by default, can be set to remove columns instead) can be useful for this kind of cleanup. On 2023-09-24 5:58 a.m., Michael Dewey wrote: Dear David To get the first 46 rows just do KurtzData[1:43,] However really you

Re: [R] Theta from negative binomial regression and power_NegativeBinomiial from PASSED

2023-09-15 Thread Ben Bolker
Yes, theta is the 'size' or overdispersion parameter. Sometimes also denoted as k. Wikipedia discusses this parameterization in the paragraph starting "In negative binomial regression ..." (but they call this parameter r rather than theta or k). You can also see this in MASS on google bo

Re: [R] graph in R with grouping letters from the turkey test with agricolae package

2023-09-13 Thread Ben Bolker
As a side note, I'm curious how often "Tukey test" is misspelled as "Turkey test". Googling '"turkey test" mean comparison' gives 36.1K results (vs 14.3M for '"tukey test" mean comparison" ... On 2023-09-13 10:02 a.m., Richard O'Keefe wrote: d <- read.table("data.txt", TRUE) cor(d[, 3:6

Re: [R] Query on finding root

2023-08-28 Thread Ben Bolker
(I mean pdavies) On Mon, Aug 28, 2023, 7:52 AM Ben Bolker wrote: > I would probably use the built in qdavies() function... > > On Mon, Aug 28, 2023, 7:48 AM Leonard Mada via R-help < > r-help@r-project.org> wrote: > >> Dear R-Users, >> >> Just out of curi

Re: [R] Query on finding root

2023-08-28 Thread Ben Bolker
I would probably use the built in qdavies() function... On Mon, Aug 28, 2023, 7:48 AM Leonard Mada via R-help wrote: > Dear R-Users, > > Just out of curiosity: > Which of the 2 methods is the better one? > > The results seem to differ slightly. > > > fun = function(u){((26104.50*u^0.03399381)/((

Re: [R] Query on finding root

2023-08-27 Thread Ben Bolker
This doesn't look like homework to me -- too specific. The posting guide says that the list is not intended for "Basic statistics and classroom homework" -- again, this doesn't seem to fall into that category. tl;dr, I think the difference b

Re: [R] Interpreting Results from LOF.test() from qpcR package

2023-08-20 Thread Ben Bolker
The p-values are non-significant by any standard cutoff (e.g. p<=0.05, p<=0.1) but note that this is a *lack-of-fit* test -- i.e., "does my function fit the data well enough?", **not** a "significant pattern" test (e.g., "does my function fit the data better than a reasonable null model?").

Re: [R] Issues when trying to fit a nonlinear regression model

2023-08-20 Thread Ben Bolker
I haven't looked to see whether you or Bert made an algebraic mistake in translating the parameters of the log-linear model to their equivalents for the nonlinear model, but nls() gives me the same answer as nls() in this case (I called my data 'dd2'): n1 <- nlxb(y~theta1 - theta2*exp(

Re: [R] Issues when trying to fit a nonlinear regression model

2023-08-20 Thread Ben Bolker
My answer is WAY longer than Bert Gunter's but maybe useful nonetheless. (Q for John Nash: why does the coef() method for nlmrt objects return the coefficient vector **invisibly**? That seems confusing!) Here's what I did: * as a preliminary step, adjust the formula so that I don't ha

Re: [R] Determining Starting Values for Model Parameters in Nonlinear Regression

2023-08-19 Thread Ben Bolker
Adding one more method: glm(y~ x1 + x2 + x3 - 1, family = gaussian(link = "inverse"), data = mydata) will fit the exact model (including the desired error structure). The default GLM starting values usually work OK, but it is true that inverse-links can sometimes be more finicky than more

Re: [R] MASS::mvrnorm() on MKL may produce different numbers even when the seed is the same?

2023-08-17 Thread Ben Bolker
Thanks, I was missing the point that this was *non-repeatability on the same platform*. On 2023-08-17 10:31 a.m., Bill Dunlap wrote: MKL's results can depend on the number of threads running and perhaps other things. They blame it on the non-associativity of floating point arithmetic. This

Re: [R] MASS::mvrnorm() on MKL may produce different numbers even when the seed is the same?

2023-08-17 Thread Ben Bolker
> However, should the numbers > generated identical if the same seed is used? I don't see how using the same seed can overcome floating-point differences across platforms (compilers etc.) stemming from differences in an eigen() computation (based on arcane details like use of registers, co

Re: [R] X11 font

2023-08-16 Thread Ben Bolker
There's an ancient related question ... maybe it helps? https://stat.ethz.ch/pipermail/r-help//2016-October/442326.html sudo apt-get install xfonts-100dpi sudo-apt-get install xfonts-75dpi apt-cache search xfonts doesn't pull up anything else obvious (presumably you already have xfonts-base

Re: [R] Noisy objective functions

2023-08-13 Thread Ben Bolker
This is a huge topic. Differential evolution (DEoptim package) would be one good starting point; there is a simulated annealing method built into optim() (method = "SANN") but it usually requires significant tuning. Also genetic algorithms. You could look at the NLopt list of algorit

Re: [R] group consecutive dates in a row

2023-08-07 Thread Ben Bolker
rle(as.numeric(diff(mydf$data_POSIX))) should get you started, I think? On 2023-08-07 12:41 p.m., Stefano Sofia wrote: Dear R users, I have a data frame with a single column of POSIXct elements, like mydf <- data.frame(data_POSIX=as.POSIXct(c("2012-02-05", "2012-02-06", "2012-02-07", "2012-0

  1   2   3   4   5   6   7   8   9   10   >