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

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] Regarding error in RStudio

2023-09-05 Thread Jeff Newmiller
R is not RStudio. RStudio is not R. RStudio helps you work with R, but to do so it "types" in some commands behind the scenes. I suspect those errors are because you have a pairing of versions of RStudio with a version of R that the RStudio team did not test. Someone here might be able to

Re: [R] [Pkg-Collaboratos] BioShapes Almost-Package

2023-09-03 Thread Jeff Newmiller
Leonard... the reason roxygen exists is to allow markup in source files to be used to automatically generate the numerous files required by standard R packages as documented in Writing R Extensions. If your goal is to not use source files this way then the solution is to not use roxygen at

Re: [R] Problems with installing R packages from source and running C++ in R, even on fresh R installation

2023-08-30 Thread Jeff Newmiller
TL:DR there are at least three maybe four ways to address this depending on what you plan to do. I usually adjust PATH to add Rtools using .Rprofile. But if you do that then if you want to use the command line to invoke R then you need to set the PATH separately when you start the shell. For

Re: [R] Questions about R

2023-08-17 Thread Jeff Newmiller
1. R is open source software. You are welcome to review the source code of the R interpreter for handling of PII. No warranty is offered by the (volunteer) developers of R. 2. R software is a programming interpreter, which by definition allows for a wide range of behaviours. Users of R

Re: [R] 'apply' for 0 or 1 element member.

2023-08-10 Thread Jeff Newmiller
Define mean0na <- function(x) { x[ 0 == x ] <- NA mean( x, na.rm = TRUE ) } and then use that instead of mean. On August 10, 2023 7:25:08 PM PDT, ani jaya wrote: >Hello, > >I try to calculate the mean of an array with a condition. My array is >B=c(181,101,420) in dimensions. And I want to

Re: [R] Could not read time series data using read.zoo()

2023-08-03 Thread Jeff Newmiller
no commas? On August 3, 2023 7:53:07 AM PDT, Christofer Bogaso wrote: >Hi, > >I have a CSV which contains data like below (only first few rows), > >Date Adj Close lret >02-01-1997 737.01 >03-01-1997 748.03 1.48416235 >06-01-1997 747.65 -0.050813009 >07-01-1997 753.23 0.743567202 >08-01-1997

Re: [R] Downloading a directory of text files into R

2023-07-25 Thread Jeff Newmiller
You cannot read files using name patterns. You can use list.files with patterns on your local filesystems, and you can use RCurl or httr contributed packages to parse out the web listing of files returned by the web server. See the example in ?RCurl. Then you can download the individual files

Re: [R] plotly question

2023-07-21 Thread Jeff Newmiller
plotly is _not_ associated with posit. I think you are unlikely to find expertise with plotly in their forums. You might find help at stackoverflow.com. On July 21, 2023 1:40:49 PM PDT, Bert Gunter wrote: >As you apparently haven't received any responses yet, I'll try to >suggest something

Re: [R] Create matrix with column names wiht the same prefix xxxx and that end in 1, 2

2023-07-03 Thread Jeff Newmiller
ical Center >10 North Greene Street >GRECC (BT/18/GR) >Baltimore, MD 21201-1524 >(Phone) 410-605-7119 >(Fax) 410-605-7913 (Please call phone number above prior to >faxing) > >On Jul 3, 2023, at 2:11 PM, Jeff Newmiller wrote: > >?colnames > >On July 3, 202

Re: [R] Create matrix with column names wiht the same prefix xxxx and that end in 1, 2

2023-07-03 Thread Jeff Newmiller
?colnames On July 3, 2023 11:00:32 AM PDT, "Sorkin, John" wrote: >I am trying to create an array, myvalues, having 2 rows and 4 columns, where >the column names are j,k,xxx1,xxx2. The code below fails, with the following >error, "Error in dimnames(myvalues) <- list(NULL, zzz) : > length of

Re: [R] Adding a numeric class to a data.frame

2023-06-04 Thread Jeff Newmiller
Still waiting for you to communicate... https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example On June 4, 2023 7:20:56 PM PDT, Jeff Reichman wrote: >Yes - I could have done that but I have over 5,000 calculated probabilities. >So yes a little more detail would

Re: [R] Adding a numeric class to a data.frame

2023-06-04 Thread Jeff Newmiller
The obvious answer is My_df$col_2 <- prob_result but whether that would work might depend on the structure of prob_result. What does dput(prob_result) return? On June 4, 2023 4:11:08 PM PDT, Jeff Reichman wrote: >R-Help Community > > > >How do I add a numeric class to a data .frame. > >

Re: [R] extract parts of a list before symbol

2023-05-25 Thread Jeff Newmiller
What a remarkable set of detours, Avi, all deriving apparently from a few gaps in your understanding of R. As Rolf said, "names(test)" is the answer. a) Lists are vectors. They are not atomic vectors, but they are vectors, so as.vector(test) is a no-op. test <- list( a = 1, b = 2, c=3 )

Re: [R] data.frame with a column containing an array

2023-05-25 Thread Jeff Newmiller
Maybe... if you want it to act like a matrix... then you should... use a matrix... I think making this behaviour work with 2d arrays could be a feature, but making it work with higher dimension arrays would be difficult, and differentiating between 2d and higher dimension arrays could have

Re: [R] mclapply enters into an infinite loop....

2023-05-16 Thread Jeff Newmiller
It does not look to me like you are providing the necessary arguments to arfima. Try making this work with lapply first... then try mclapply. On May 16, 2023 3:10:45 PM PDT, akshay kulkarni wrote: >Dear members, > I am using arfima in an mclapply construction (from >

Re: [R] Recombining Mon and Year values

2023-05-16 Thread Jeff Newmiller
I don't use lubridate, but that package works with Date and POSIXt types, which I do use. Just remember to include a day when converting (1st of month is typical), and use an output format to hide the day when you plot. On May 16, 2023 1:29:27 PM PDT, Jeff Reichman wrote: >R Help > > > >I

Re: [R] aggregate wind direction data with wind speed required

2023-05-13 Thread Jeff Newmiller
You don't have to bother with the subtracting from pi/2 bit ... just assume the cartesian complex values are (y,x) instead of (x,y). On May 13, 2023 1:38:51 PM PDT, Bill Dunlap wrote: >I think that using complex numbers to represent the wind velocity makes >this simpler. You would need to

Re: [R] Error in as.POSIXlt.character(x, tz, ...)

2023-05-11 Thread Jeff Newmiller
I find your claim suspect... a period is not interchangeable with a colon. On May 11, 2023 1:56:41 AM PDT, Jinsong Zhao wrote: >Hi there, > >When I run the following code in R 4.3.0 on FreeBSD, I got error. > >> as.POSIXct("1970-01-01 00:00.00 UTC") >Error in as.POSIXlt.character(x, tz, ...) : >

Re: [R] problem installing RUcausal library

2023-04-23 Thread Jeff Newmiller
Perhaps read the Posting Guide, note that there is a special mailing list for MacOSX-specific questions, and post there instead? You don't appear to have installed gfortran. I am aware that there are specific instructions for getting that installed in MacOS that you need to find and follow

Re: [R] detect and replace outliers by the averaged

2023-04-21 Thread Jeff Newmiller
0 On April 21, 2023 4:08:08 AM GMT+09:00, Dr Eberhard W Lisse wrote: >There is at least one outliers package on CRAN. > >el >On 20/04/2023 20:43, AbouEl-Makarim Aboueissa wrote: >> Dear All: *please discard my previous email* >> >> >> >> *Re:* detect and replace outliers by the average >>

Re: [R] AIc and BIC in caret...

2023-04-19 Thread Jeff Newmiller
This is a statistical question, not actually a question about R, and thus not on topic. Using too many variables leads to models that tend to have large errors on new data (not from your fitting sample). [1] [1] https://en.m.wikipedia.org/wiki/Overfitting On April 19, 2023 6:50:44 AM PDT,

Re: [R] converting a character matrix into numeric....

2023-04-12 Thread Jeff Newmiller
Isn't this like trying to tie up the horse after it has left the barn? Why not figure all this out _before_ converting to xts? On April 12, 2023 12:29:49 PM PDT, akshay kulkarni wrote: >Dear Rui, > Not working. I have entirely removed the column containing % > but am still

Re: [R] extracting pdf tables...

2023-04-09 Thread Jeff Newmiller
"X4" > >THe above has to be the first row of IDT[[4]]. The first row is getting parsed >as the column name. How do you make that the first row of IDT[[4]]? > >Thanking you, >Yours sincerely, >AKSHAY M KULKARNI > >From: Jeff

Re: [R] extracting pdf tables...

2023-04-09 Thread Jeff Newmiller
eff, > I want to rbind. > >Thanking you, >Yours sincerely, >AKSHAY M KULKARNI > >From: R-help on behalf of Jeff Newmiller > >Sent: Sunday, April 9, 2023 11:57 PM >To: r-help@r-project.org >Subject: Re: [R] extracting pdf tabl

Re: [R] extracting pdf tables...

2023-04-09 Thread Jeff Newmiller
Sorry, did not read closely enough. Did you want rbind (which has no problem with different numbers of rows) or merge (which requires that there be key columns that can be aligned by repeating data)? On April 9, 2023 10:49:09 AM PDT, Jeff Newmiller wrote: >Clearly the column na

Re: [R] extracting pdf tables...

2023-04-09 Thread Jeff Newmiller
Clearly the column names are different. You need to decide what to do about that. Choose the subset of dataframes where the column names are the same? Rename columns? Omit some columns? Add missing columns filled with NA? On April 9, 2023 10:22:32 AM PDT, akshay kulkarni wrote: >Dear members,

Re: [R] on lexical scoping....

2023-04-04 Thread Jeff Newmiller
Leading off with you can only have two things in an environment definitely indicates this should be read with a skeptical eye. Although the title of "Advanced R" may be more scary than someone writing notes on GitHub like a bro, IMHO Adv R is quite readable for anyone interested in questions

Re: [R] on lexical scoping....

2023-04-04 Thread Jeff Newmiller
Namespaces. Packages only export specific object names from their namespaces. But few instances of x would be found there. Also, function argument lists are not added to the search path until the functions are running, and then the search path only goes through the environments in which the

Re: [R] Simple Stacking of Two Columns

2023-04-03 Thread Jeff Newmiller
unname(unlist(NamesWide)) On April 3, 2023 8:08:59 AM PDT, "Sparks, John" wrote: >Hi R-Helpers, > >Sorry to bother you, but I have a simple task that I can't figure out how to >do. > >For example, I have some names in two columns >

Re: [R] printing a data.frame without row numbers

2023-03-27 Thread Jeff Newmiller
Read ?print.data.frame. There is an argument for that. On March 27, 2023 10:05:10 AM PDT, Dennis Fisher wrote: >R 4.2.3 >OS X > >Colleagues, > >I am printing a large number of tables using the print command. A simple >example is: > print(data.frame(COL1=1:5, COL2=10:6)) > >The result in

Re: [R] lexical scoping for scripts......

2023-03-19 Thread Jeff Newmiller
rom the shell prompt. > or from crontab in Linux. I think you get the context. > >thanking you, >yours sincerely >AKSHAY M KULKARNI > >____ >From: Jeff Newmiller >Sent: Monday, March 20, 2023 1:01 AM >To: r-help@r-project.org ; akshay kul

Re: [R] lexical scoping for scripts......

2023-03-19 Thread Jeff Newmiller
What do _you_ mean when you use the term "interactive"? Because R distinguishes between executing code in a function and executing code from the global environment, but it does not care whether a person is doing the typing or not. I get the feeling that you think of your R code in terms of

Re: [R] Removing variables from data frame with a wile card

2023-02-12 Thread Jeff Newmiller
columns of x headed by V2. What I need is the opposite——I >need a data grime with those columns excluded. > >Steven from iPhone > >> On Feb 13, 2023, at 9:33 AM, Rolf Turner wrote: >> >>  >>> On Sun, 12 Feb 2023 14:57:36 -0800 >>> Jeff Ne

Re: [R] Removing variables from data frame with a wile card

2023-02-12 Thread Jeff Newmiller
x["V2"] is more efficient than using drop=FALSE, and perfectly normal syntax (data frames are lists of columns). I would ignore the naysayers, or put a comment in if you want to accelerate their uptake. As I understand it, one of the main reasons tibbles exist is because of drop=TRUE.

Re: [R] Extracting data using subset function

2023-02-05 Thread Jeff Newmiller
5, 2023 12:10:46 PM PST, Upananda Pani wrote: >Hi Jeff, > >Thanks for your reply. What do you exactly mean by "interactively"? Would >you please give me an example? >Upananda > >On Mon, Feb 6, 2023 at 1:27 AM Jeff Newmiller >wrote: > >> No, it means wh

Re: [R] Extracting data using subset function

2023-02-05 Thread Jeff Newmiller
No, it means what it says: it is best used interactively rather than in functions. That is not saying you cannot use it... merely that you should probably use it interactively. The fact is, though, that integer indexing is much simpler and clearer for your particular example than subset is. q

Re: [R] Bug in R-Help Archives?

2023-01-26 Thread Jeff Newmiller
Every email thread (mailing list or not) gets a hidden identifier that is used to identify that thread. It is not that Outlook outsmarted John... any email program would have done the same. John... please don't reply to existing posts with a new subject... many mailing list users may be using

Re: [R] implicit loop for nested list

2023-01-26 Thread Jeff Newmiller
Elegance is in the eyes of the beholder... extractor <- function( simlist, sim_name ) { do.call( cbind , lapply( simlist , function( r ) r[[ sim_name ]] ) ) } extractor( mysim, "two.mat" ) ... but using do.call will be much more memory efficient than successive cbind

Re: [R] Minimal match to regexp?

2023-01-25 Thread Jeff Newmiller
Perhaps sub( "^.*(a.*?a).*$", "\\1", x ) On January 25, 2023 4:19:01 PM PST, Duncan Murdoch wrote: >The docs for ?regexp say this: "By default repetition is greedy, so the >maximal possible number of repeats is used. This can be changed to ‘minimal’ >by appending ? to the quantifier.

Re: [R] Shadow Graphics Error in R Studio

2023-01-25 Thread Jeff Newmiller
If the problem goes away in R but persists in RStudio, then most likely you will need to ask in a forum where RStudio experts hang out, like the RStudio community forum website. On January 24, 2023 11:35:52 AM PST, Brinkley Norton wrote: >Good afternoon! > >I'm new to R Studio and am

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

2023-01-20 Thread Jeff Newmiller
This is not a "problem" ... it is a "feature". Packages often use functions from other packages, but that does NOT mean that you as a user can automatically use those functions also. If Package A uses Package B to implement something, but Package B becomes unavailable, the maintainer of

Re: [R] MLE Estimation of Gamma Distribution Parameters for data with 'zeros'

2023-01-19 Thread Jeff Newmiller
Beware of adding a constant... the magnitude of the constant used can have an outsized impact on the answer obtained. See e.g. https://gist.github.com/jdnewmil/99301a88de702ad2fcbaef33326b08b4 On January 19, 2023 3:49:29 AM PST, peter dalgaard wrote: >Not necessarily homework, Bert. There's a

Re: [R] R emulation of FindRoot in Mathematica

2023-01-19 Thread Jeff Newmiller
But it is simultaneously an example of why some researchers like black box solvers... a system of dozens of nonlinear equations can potentially have many or even infinite solutions. If the researcher is weak in math, they may have no idea which solutions are possible and having a tool like

Re: [R] Printing special characters

2023-01-16 Thread Jeff Newmiller
Use the Cairo PDF device? On January 16, 2023 12:18:48 AM PST, Dennis Fisher wrote: >R 4.2.2 >OS X > >Colleagues > >A file that I have read includes strings like this: > "EVENT ≥ 30 sec" >When I include the string in a graphic using: > mtext(STRING, …) >it appears as: > "EVENT

Re: [R] return value of {....}

2023-01-09 Thread Jeff Newmiller
I suspect akshay is (or was? Not sure) unclear about what braces do. They are not closures... they create an expression that wraps multiple expressions into one expression... they are a little more like parentheses than closures. They are not intrinsically associated with creation of

Re: [R] extracting a table from pdf file....

2023-01-08 Thread Jeff Newmiller
Here is a start for two of them... PDF files are actually programs written in the Postscript language... there are a lot of ways to write a program to put marks on a page, so this mess is actually not as bad a result as you might have encountered. str(IDTpdf) DF <- IDTpdf[[1]][ -(1:2), ]

Re: [R] Pipe operator

2023-01-03 Thread Jeff Newmiller
> R is a functional language, hence the pipe operator is not needed. Not factual... just opinion. Please be conscious of your biases and preface opinion with a disclaimer. I heard identical complaints from embedded assembly language programmers when C became all the rage... "don't need another

Re: [R] Pipe operator

2023-01-03 Thread Jeff Newmiller
Ick. Some people like x |> cos() |> max(pi/4) |> round(3) -> x but I much prefer x <- x |> cos() |> max(pi/4) |> round(3) On January 3, 2023 11:00:46 AM PST, Boris Steipe wrote: >Working off Avi's example - would: > > x |> cos() |> max(pi/4) |> round(3) |> assign("x", value = _) > >...be

Re: [R] Pipe operator

2023-01-03 Thread Jeff Newmiller
The other responses here have been very good, but I felt it necessary to point out that the concept of a pipe originated around when you started programming [1] (text based). It did take awhile for it to migrate into programming languages such as OCaml, but Powershell makes extensive use of

Re: [R] R Certification

2023-01-02 Thread Jeff Newmiller
I think this request is like saying "I want a unicorn." There are many organizations that will enter your name into a certificate form for a fee, possibly with some credibility... but if they put "r-project.org" down as the name of the organization granting this "certificate" then you are

Re: [R] Integer division

2022-12-19 Thread Jeff Newmiller
See https://en.m.wikipedia.org/wiki/Modulo_operation, Variants of the definition, esp the point that Knuth recommended the floor definition. The behavior of %/% follows from the definition of %% given the documented relation in ?Arithmetic. R is not obligated to repeat the mistakes of C or

Re: [R] Error 3221226505

2022-12-18 Thread Jeff Newmiller
Doesn't happen to me. On December 16, 2022 12:44:17 AM PST, "Mathurin, Gottfried via R-help" wrote: >Hello, >I currently face the issue of Windows 10 throwing a code 3221226505 >whenever I try to use R-4.1.3. >Is this issue known and could you possibly share a fix? > >Thank you in advance, >

Re: [R] Adding comment in C++ code for debugging purpose

2022-12-16 Thread Jeff Newmiller
a) This is not the Rcpp help list. b) Writing to stdout without going through R is not supported in packages. Do read the Writing R Extensions manual. On December 16, 2022 3:32:33 PM PST, Christofer Bogaso wrote: >Hi, > >I am using an R package where there are some C++ code. > >To check some

Re: [R] is.na()<- on a character vector

2022-12-16 Thread Jeff Newmiller
I don't find _either_ of these acceptable. On the other hand, x[ is.na( x ) ] <- 1 should have no effect on x. On December 16, 2022 10:28:52 AM PST, "Göran Broström" wrote: >I'm confused: > >> x <- 1:2 >> is.na(x) <- 1 >> x >[1] NA 2 > >OK, but > >> x <- c("A", "B") >> is.na(x) <- "A"

Re: [R] library(tseries) - spellng error in output

2022-12-14 Thread Jeff Newmiller
Contact the package maintainer. See maintainer(). On December 14, 2022 7:04:28 PM PST, roslinazairimah zakaria wrote: >Hi R-users, > >Just to inform that there is one spelling error in the output for *Jarque-Bera >test in R.* > >*library(tseries)* > > > > > > > > > > > >*> #Jarque-Bera

Re: [R] Plot a line using ggplot2

2022-12-08 Thread Jeff Newmiller
Please run your code before you send it. Your example is not reproducible. library(ggplot2) linedata<- data.frame( PointEstx = c( 1, 2 ) , PointEsty = c( 1, 1.5 ) ) # make sure we have a data frame str(linedata) #plot the data ggplot( linedata , aes( x = PointEstx , y = PointEsty

Re: [R] setting timezone variable permanently...

2022-12-07 Thread Jeff Newmiller
;THanking you, >Yours sincerely, >AKSHAY M KULKARNI > >________ >From: Jeff Newmiller >Sent: Wednesday, December 7, 2022 10:44 PM >To: r-help@r-project.org ; akshay kulkarni >; R help Mailing list >Subject: Re: [R] setting timezone variable permanentl

  1   2   3   4   5   6   7   8   9   10   >