Re: [R] [External] Using the pipe, |>, syntax with "names<-"

2024-07-21 Thread Jeff Newmiller via R-help
I think that the simplicity of setNames is hard to beat: z |> setNames( c( "a", "foo" ) ) and if you are determined not to load dplyr then column_rename <- function( DF, map ) { on <- names( DF ) on[ match( map, on ) ] <- names( map ) names( DF ) <- on DF } is more robust to column

Re: [R] Extract

2024-07-19 Thread Jeff Newmiller via R-help
Here is another way... for data analysis, the idiomatic result is usually more useful, though for presentation in a final result the wide result might be desired. library(dplyr) library(tidyr) dat<-read.csv(text= "Year, Sex,string 2002,F,15 xc Ab 2003,F,14 2004,M,18 xb 25 35 21 2005,M,13 25

Re: [R] ggplot two-factor legend

2024-07-18 Thread Jeff Newmiller via R-help
If I follow your question, you want redundant aesthetics. Ggplot normally notices correlated aesthetic mapping variables and merges the legends, so the most likely answer is that your data are not fully correlated in all rows. I have also seen this where data are drawn from different dataframes

Re: [R] summaryRprof: Unexpected unit for memory profiling

2024-07-02 Thread Jeff Newmiller via R-help
There was a time when people pretty much ignored the distinction between MB and MiB in computer applications, and using the binary version was usually assumed because, well, this _is_ memory we are measuring. I think this is a leftover from that time. On July 1, 2024 6:33:43 AM PDT, "Sauer,

Re: [R] Create matrix with variable number of columns AND CREATE NAMES FOR THE COLUMNS

2024-07-01 Thread Jeff Newmiller via R-help
I think you should reconsider your goal. Matrices must have all elements of the same type, and in this case you seem to be trying to mix a number of something (integer) with mean values (double). This would normally be stored together in a data frame or separately in a vector for counts and a

Re: [R] [Tagged] Re: Referencing Sys.Date to a different time zone

2024-06-28 Thread Jeff Newmiller via R-help
The key points are that: a) Date values have no idea what timezone means. b) Sys.Date starts with local time and converts to Date, losing timezone info. c) You try comparing a Date with a POSIXt time value, and the conversion from Date to POSIXt _assumes UTC_. This is a problem for anyone not

Re: [R] devtools - bad credentials R4.4.1

2024-06-20 Thread Jeff Newmiller via R-help
I would delete the PAT from the credential manager since it seems to be timed out anyway... I don't know my way around the Windows Credential Manager very well, but it seems to me

Re: [R] devtools - bad credentials R4.4.1

2024-06-20 Thread Jeff Newmiller via R-help
My guess is that this is related to you saving an expired Personal Access Token in your global git options or credentials store? Git is perfectly capable of using per-repo credentials... don't configure a credential in your global configuration and it won't fall back on using it to access

Re: [R] slowness when I use a list comprehension

2024-06-16 Thread Jeff Newmiller via R-help
I would be more strong on this advice: learn to think in R, rather than thinking in Python, when programming in R. R has atomic vectors... Python does not (until you import a package that implements them). I find that while it is possible to import R thinking into Python, Python programmers

Re: [R] code for year month day hr format

2024-06-15 Thread Jeff Newmiller via R-help
Please run your sequence of R statements one at a time so you can tell where the problem is. Only "run a script" after the code works one line at a time. There are too many places where things can go wrong otherwise. Is your file being read in properly? Is the filename correct? was the header

Re: [R] Integration of functions with a vector argument

2024-06-13 Thread Jeff Newmiller via R-help
How do you integrate perpendicular to a plane if you don't have a concept of 3d? In that direction the plane is just a point. Vectors in R do not have any concept of "n by 1"... they are like a string of beads. When you take a column out of a matrix `a` using indexing b <- a[,j] the resulting

Re: [R] Issues with R's forecast function

2024-05-27 Thread Jeff Newmiller via R-help
You have completely ignored mentioning what R contributed packages you may have been using in "back when it worked". It is critical that you keep track of which "library" statements are necessary to run your code, if any. I searched for "R usemethod forecast" in Google and this [1] came up.

Re: [R] Listing folders on One Drive

2024-05-20 Thread Jeff Newmiller via R-help
What does "doesn't work" mean? What have you tried? On May 20, 2024 6:36:58 AM PDT, Nick Wray wrote: >Hello I have lots of folders of individual Scottish river catchments on my >uni One Drive. Each folder is labelled with the river name eg "Tay" and >they are all in a folder named "Scotland" >I

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

2024-04-23 Thread Jeff Newmiller via R-help
While I certainly think using negative indices to denote element exclusion is a cool feature, I think people wanting to use zero-based indexes probably are not planning to use that feature. Python uses negative numbers to index from the end, which is a completely different use of negative

Re: [R] passing a modified argument to an S3 method

2024-04-20 Thread Jeff Newmiller via R-help
The parameters in a specific call to a function are stored in a special list which is used to move/copy data from the calling environment into the environment created for a particular function call. UseMethod does not act like a normal function call... it does a kind of magic substitution of

Re: [R] [Tagged] Re: Import multiple tif raster

2024-04-18 Thread Jeff Newmiller via R-help
Your original code with relative path would also work if you did not put the leading slash. On April 18, 2024 10:04:04 AM PDT, "SIBYLLE STÖCKLI via R-help" wrote: >Dear community >Dear Ivan > >Thanks a lot. The code works now. Solution: direct and full path to the .tif >files. >I confused

Re: [R] missing() fails to detect missing

2024-04-17 Thread Jeff Newmiller via R-help
Fascinating. Or, well, not. Failing to use a method signature that is compatible with the generic is a no-no. So your bug seems to me to be outside the bounds of how R is supposed to be used. So don't do that. On April 17, 2024 4:25:38 PM PDT, "Boylan, Ross via R-help" wrote: >When a generic

Re: [R] Output of tapply function as data frame: Problem Fixed

2024-03-28 Thread Jeff Newmiller via R-help
I would guess your version of R is earlier than 4.1, when the built-in pipe was introduced to the language On March 28, 2024 6:43:05 PM PDT, Ogbos Okike wrote: >Dear Rui, >Thanks again for resolving this. I have already started using the version >that works for me. > >But to clarify the second

Re: [R] Printout and saved results

2024-03-25 Thread Jeff Newmiller via R-help
Your desire is not unusual among novices... but it is really not a good idea for your function to be making those decisions. Look at how R does things: The lm function prints nothing... it returns an object containing the result of a linear regression. If you happen to call it directly from the

Re: [R] as.complex()

2024-03-25 Thread Jeff Newmiller via R-help
?complex On March 25, 2024 12:23:43 AM PDT, Thomas K wrote: >Needing a < , > comparison for imaginary numbers > >__ >R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see >https://stat.ethz.ch/mailman/listinfo/r-help >PLEASE do read the

Re: [R] Generating mouse click and hold using R

2024-03-13 Thread Jeff Newmiller via R-help
No idea if the package below would work. This package is MSWindows only. Since this was readily found using a search engine, you should have mentioned that you already found this and why it didn't work for you when you posted.

Re: [R] Initializing vector and matrices

2024-03-02 Thread Jeff Newmiller via R-help
To be fair, these replies no longer include the original question, which was IMO really quite clear (if misguided), and was actually targeted at understanding pre-allocation for better performance. Richard's suggestion to store the along-the-way constructed vectors in a list and examine the

Re: [R] installation: while running make, unable to run pdflatex on 'NEWS.tex'

2024-03-01 Thread Jeff Newmiller via R-help
This really is all LaTeX errors, not R errors. Both examples complain that pdftexcmds.sty is not installed. Most "sty" files are in LaTeX packages. Each LaTeX distribution has its own way to install packages ... but the difficulty is usually on the same order of difficulty as installing R

Re: [R] Trouble reading a UTF-16LE file

2024-02-28 Thread Jeff Newmiller via R-help
When you specify LE you are overriding any useful information that the BOM could convey... see https://softwareengineering.stackexchange.com/questions/370088/is-the-bom-optional-for-utf-16-and-utf-32. ?Encoding On February 28, 2024 5:44:49 AM PST, "Ebert,Timothy Aaron" wrote: >Dear R-help, >

Re: [R] converting MATLAB -> R | element-wise operation

2024-02-27 Thread Jeff Newmiller via R-help
Why anything but sweep? The fundamental data type in Matlab is a matrix... they don't have vectors, they have Nx1 matrices and 1xM matrices. Vectors don't have any concept of "row" vs. "column". Straight division is always elementwise with recycling as needed, and matrices are really vectors

Re: [R] Rtools and things dependent on it

2024-02-23 Thread Jeff Newmiller via R-help
RTools is a set of command-line programs needed for compiling R and its packages on Windows. You don't need it if your OS is not Windows. In theory, users on Windows should not need to worry about compiling packages to binary (zip) form, because CRAN compiles the source code for every package

Re: [R] Help

2024-02-20 Thread Jeff Newmiller via R-help
Regarding 1 and 2, please read the Posting Guide mentioned at the bottom of every R-help post. R does not equal statistics... and education about statistics is way too ambitious to include in this mailing list that is about a tool that happens to be useful for statisticians. There are forums

Re: [R] Network issue

2024-02-20 Thread Jeff Newmiller via R-help
... and if the problem is networking, then you will likely need help from someone who knows your local configuration. Employers often do things that limit what R can do, and none of us are likely to know about those things. On February 20, 2024 11:43:24 AM PST, stephen sefick wrote: >Maybe I

Re: [R] List of Words in BioWordVec

2024-02-01 Thread Jeff Newmiller via R-help
I thought so too, but Google suggests there is at least one package on CRAN with this symbol in it. OP: a) You should always mention which contributed package you are using. Most references to this term online seem to be related to Python rather than R. b) This seems like extremely

Re: [R] Use of geometric mean .. in good data analysis

2024-01-22 Thread Jeff Newmiller via R-help
Still OT... but here is my own (I think previously mentioned here) rant on people thrashing about with log transformation and an all-too-common kludge to deal with zeros mixed among small numbers... https://gist.github.com/jdnewmil/99301a88de702ad2fcbaef33326b08b4 OP perhaps posting a link

Re: [R] Sorting based a custom sorting function

2023-12-14 Thread Jeff Newmiller via R-help
This sounds suspiciously like homework (which is off-topic... see the Posting Guide), and you haven't indicated how you plan to encode your poker hands, and most core features of other languages are possible in R so if you really understand these other techniques and R then you should be able

Re: [R] reshape() not dropping varaibles

2023-12-10 Thread Jeff Newmiller via R-help
It would be nice to see what OP wanted to end up with, but the link contained input data to experiment with. The first problem is that if you are not interested in working with the whole set of columns then you need to only give a data frame with the columns you want to work with: dta.wide <-

Re: [R] Volume of polygon

2023-12-05 Thread Jeff Newmiller via R-help
A raster is just a matrix of elevations. Each element of that matrix has a horizontal area. If you subtract that elevation from a reference elevation and zero out all negative values then you are left with a bunch of rectangular parallelopipeds of varying height. Add those heights up and

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

2023-12-02 Thread Jeff Newmiller via R-help
t;> 12, and the more complex the formatting the harder to deal with rows as >> related to page size. >> >> Thankfully I do not think I will have to do this, so the question is for >> theoretical interest on my part (at least for now). >> >> Tim >> &g

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

2023-12-02 Thread Jeff Newmiller via R-help
One of the most fundamental characteristics of R programming is the use of data frames of column vectors, and one of the very first challenges I had as a then-Perl-programmer was coming to grips with the fact that unknown-length CSV files would be read completely into memory as rows and once

Re: [R] Code editor for writing R code

2023-11-29 Thread Jeff Newmiller via R-help
Quarto is built on top of RMarkdown when R is used, so RMarkdown isn't going anywhere soon. Don't spread unnecessary FUD. Quarto is well-supported in VSCode, though. And reply to the right branch of the thread... Bert is not in the thread below. On November 29, 2023 10:29:03 AM PST, Eric

Re: [R] Why Rprofile.site is not built with manual installation of R devel in linux?

2023-11-09 Thread Jeff Newmiller via R-help
No clue. Tip: R-devel is the mailing list for anything related to development versions of R. Off-topic here. On November 9, 2023 2:59:44 AM PST, "Iago Giné Vázquez" wrote: >Hi all, > >I downloaded R-devel as explicited in >https://developer.r-project.org/SVNtips.html >Then, I tried to install

Re: [R] strptime with +03:00 zone designator

2023-11-05 Thread Jeff Newmiller via R-help
I usually just use a regex to strip the colon. On November 5, 2023 3:45:01 PM PST, Richard O'Keefe wrote: >I have some data that includes timestamps like this: >2017-02-28T13:35:00+03:00 >The documentation for strptime says that %z expects >an offset like 0300. I don't see any way in the

Re: [R] Sum data according to date in sequence

2023-11-03 Thread Jeff Newmiller via R-help
Cbind is not a very good tool for adding columns to a data frame. Either use explicit column referencing like dt1$x <- new_data_vector but you do have to make sure the new data vector has the same number of values and in the same order as the other data in dt1. The transition from multiple

Re: [R] [Tagged] Re: col.names in as.data.frame() ?

2023-10-28 Thread Jeff Newmiller via R-help
as.data.frame is a _converter_, while data.frame is a _constructor_. Changing the object contents is not what a conversion is for. On October 28, 2023 11:39:22 AM PDT, Boris Steipe wrote: >Thanks Duncan and Avi! > >That you could use NULL in a matrix() dimnames = list(...) argument wasn't

Re: [R] Yext in parentheses.

2023-10-26 Thread Jeff Newmiller via R-help
I recommend cutting snippets out of your code by stopping the code at the point of interest and using dput() to pull out "data as it is" before the troublesome section and then using the reprex package to test that the snippet runs. Either you will notice the problem on your own while taking

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

2023-10-19 Thread Jeff Newmiller via R-help
What makes sense in a math class is not necessarily the same as what makes sense in a floating point analysis environment. You lose a lot of significant digits when you add 1 to a floating point number that is close to zero, and this implementation allows the user to avoid that structural

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

2023-10-18 Thread Jeff Newmiller via R-help
Use any occurrence of one or more digits as a separator? s <- c( "CCl3F", "Li4Al4H16", "CCl2CO2AlPO4SiO4Cl" ) strsplit( s, "\\d+" ) On October 18, 2023 7:59:01 AM PDT, Leonard Mada via R-help wrote: >Dear List members, > >What is the best way to test for numeric digits? >

Re: [R] Ynt: creating a time series

2023-10-16 Thread Jeff Newmiller via R-help
Then your data has extra data points... either duplicates or records with timestamps not on 15min intervals. On October 16, 2023 7:29:25 AM PDT, "ahmet varlı" wrote: >hello, > >because ı have data between these times and it has 177647 elements > >Gönderen: Marc

Re: [R] Plot to a device and examine the plot?

2023-10-15 Thread Jeff Newmiller via R-help
This question is not clear to me. What is it you hope to retrieve from the device? Note that the type of device in your example is system-dependent. The content in a png() would be different than the content in a win.graph() device. On October 15, 2023 8:04:00 AM PDT, Shu Fai Cheung wrote:

Re: [R] Create new data frame with conditional sums

2023-10-14 Thread Jeff Newmiller via R-help
Pre-compute the per-interval answers and use findInterval to look up the per-row answers... dat <- read.table( text= "Tract Pct Totpop 1 0.054000 2 0.033500 3 0.014500 4 0.124100 5

Re: [R] if-else that returns vector

2023-10-12 Thread Jeff Newmiller via R-help
What a strange question... ifelse returns a vector (all data in R is vectors... some have length 1, but length zero is also possible, as are longer vectors) that is exactly as long as the logical vector that you give it, filled with elements from the respective positions in the vectors supplied

Re: [R] Is it possible to get a downward pointing solid triangle plotting symbol in R?

2023-10-08 Thread Jeff Newmiller via R-help
Ah, I accidentally replied only to you. I re-introduced the list here... Maybe this [1] will help? [1] https://coolbutuseless.github.io/2021/11/04/custom-ggplot2-point-shapes-with-gggrid/ On October 8, 2023 1:04:23 AM PDT, Chris Evans wrote: > >On 07/10/2023 17:45, Jeff Newmiller wrote: >>

Re: [R] Confirming MySQL Alive

2023-10-07 Thread Jeff Newmiller via R-help
Not really an R question, but some processes are connected to interactive terminals (where someone can type) and some are not (because they were created and managed by another process). The system call creates a process and controls all interactions with that process. You really should not be

Re: [R] R Gigs

2023-10-06 Thread Jeff Newmiller via R-help
That list is _very_ low volume... most employers who would benefit from the skills of an R user don't know that R exists. On October 6, 2023 1:50:17 PM PDT, Fred Kwebiha wrote: >Thanks Bert. > >I have Subscribed now to that list. > >*Best Regards,* > >*FRED KWEBIHA* >*+256-782-746-154* > > >On

Re: [R] Is it possible to get a downward pointing solid triangle plotting symbol in R?

2023-10-06 Thread Jeff Newmiller via R-help
Doesn't the outcome of this suggestion still depend on which fonts and output device you are using? ... and that is to some degree still system dependent... On October 6, 2023 7:50:00 AM PDT, Rui Barradas wrote: >Às 10:09 de 06/10/2023, Chris Evans via R-help escreveu: >> The reason I am asking

[R] Jim Lemon RIP (was Re: save(), load(), saveRDS(), and readRDS())

2023-10-04 Thread Jeff Newmiller via R-help
Thank you for informing us. Jim was a remarkably patient helper of many lost R analysts. His efforts will be missed. On October 4, 2023 3:36:50 PM PDT, Jim Lemon wrote: >Hello, >I am very sad to let you know that my husband Jim died on 18th September. I >apologise for not letting you know

Re: [R] save() and load()

2023-09-25 Thread Jeff Newmiller via R-help
You never created any object in R called irisdataTest. Objects in the global environment have names that are unrelated to the names of files on disk. The load function modifies an environment to create a variable named as it was named in the environment from which it was saved. Thus, you cannot

Re: [R] Mantel Haenszel test

2023-09-23 Thread Jeff Newmiller via R-help
?cor cor( M, t( M ) ) On September 23, 2023 7:56:29 AM PDT, tgs77m--- via R-help wrote: >Colleagues, > >I am trying to write a script for the Mantel Haenszel test. > >For the MH test, the test statistic is chi-square (MH) = (W-1) * r^2 >Where W = sum of the case weights. This is straight

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

2023-09-14 Thread Jeff Newmiller via R-help
This request sounds a lot like "do my work for me"... even like it might be homework... both scenarios are disallowed here. Also, you need to read the Posting Guide... not all attachments are allowed on this mailing list, so even if you attached an image we did not get it. Go look at the

Re: [R] only install.packages with type="source" will install packages

2023-09-14 Thread Jeff Newmiller via R-help
There is/was a discrepancy between versions in source form and in binary form for that package on the CRAN server. (The server that compiles binaries for MacOS has been stuck recently.) You declined (automatically or explicitly) to upgrade from source. This meant you kept an out-of-date binary

Re: [R] Rd files with duplicated alias 'plot'

2019-05-10 Thread Jeff Newmiller via R-help
a) Wrong list. Read the Posting Guide. b) Don't use @aliases for this purpose. c) Just use @export... plot already has a dispatch function. d) Best for you to be clear (don't assume everyone will know what you are talking about) that this question is about a contributed package called