Re: [R] Weird and changed as.roman() behavior

2025-01-17 Thread Richard O'Keefe
"Roman numerals" is actually a tricky subject, since there were different versions at different times. It is worth noting that the Unicode character set (and R does support Unicode, does it not?) includes the Roman numeral characters for 5,000 10,000 50,000 and 100,000 so the idea that 3999 is an a

Re: [R] Weird Behavior of mean

2024-12-13 Thread Richard O'Keefe
My preference would be for anything that is defined as taking a "logical" parameter to report an error if given anything else. On Sat, 14 Dec 2024 at 12:21, Ben Bolker wrote: > >Thanks, I had missed/forgotten the fact that there is also an > inconsistency between mean.default() and sd(). > >

Re: [R] apply

2024-10-04 Thread Richard O'Keefe
> x <- runif(10) > y <- runif(10) > cov(cbind(x,y)) x y x 0.1205034 0.02642830 y 0.0264283 0.09945432 I understand wanting to calculate covariance matrices. What I DON'T understand is wanting to do it using apply(). (And that's what looked like a homework problem, it's so artifi

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

2024-09-28 Thread Richard O'Keefe
I for one am grateful to have been reminded of the existence of split and especially unsplit. On Sun, 29 Sept 2024 at 15:48, wrote: > > Admit it, Rolf. Haven't you wondered if S, in a more private way, is sexier > than R? > > OK, kidding aside, we have talked this to death. > > Just FYI, the con

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

2024-09-06 Thread Richard O'Keefe
rting that R did not agree with C (or LIA-3). What really annoys me is that I wrote an entire technical report on (some of the) problems with complex arithmetic, and this whole "just treat x as (x, +0.0)" thing completely failed to occur to me as something anyone might do. On Fri, 6

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

2024-09-05 Thread Richard O'Keefe
The thing is that real*complex, complex*real, and complex/real are not "complex arithmetic" in the requisite sense. The complex numbers are a vector space over the reals, and complex*real and real*complex are vector*scalar and scalar*vector. For example, in the Ada programming language, we have fu

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

2024-09-05 Thread Richard O'Keefe
I expect that atan(1i) = (0 + infinity i) and that atan(1i)/5 = (0 + infinity i)/5 = (0 + infinity i). Here's what I get in C: (0,1) = (0, 1) atan((0,1)) = (0, inf) atan((0,1))/5 = (0, inf) Note the difference between I*infinity = (0,1)*infinity = (0*infinity,1*infinity) = (NaN,infinity) and (0,in

Re: [R] please help generate a square correlation matrix

2024-07-28 Thread Richard O'Keefe
why I got negative > correlation values for all pairs. > > In my case, we measured all mutations for all 1000 samples using an exactly > same sequencing method, so no issue of never-reporting. > > I am very grateful for help and comments from Rui, Richard and Bert!! > &g

Re: [R] please help generate a square correlation matrix

2024-07-27 Thread Richard O'Keefe
All of which is a long-winded way of saying that - Pearson correlations on binary columns can be computed very efficiently - the rows with x=0 and y=0 may be very informative, even essential for analysis - delete them at your peril. - really, delete them at your peril. On Sat, 27 Jul 2024 at 23:07

Re: [R] please help generate a square correlation matrix

2024-07-27 Thread Richard O'Keefe
Let's go back to the original posting. > > > >> in each column, less than 10% values are 1, most of them are 0; > > > > > > > >> so I want to remove a row with value of zero in both columns when > >> calculate correlation between two columns. > > So we're talking about correlations between bina

Re: [R] OFF TOPIC: Nature article on File Drawer Problem in Reserach

2024-07-25 Thread Richard O'Keefe
I know you didn't want to stimulate discussion, but the problem is not confined to publication. "Adverse reaction to medication" monitoring programs are plagued by a similarly massive under-reporting problem: adverse reactions are seldom reported unless they are particularly bad or surprising. (T

Re: [R] Converting .grib to excel file

2024-06-26 Thread Richard O'Keefe
tarts with: Extract values from a SpatRaster for a set of locations. The locations can be a SpatVector (points, lines, polygons), a data.frame or matrix with (x, y) or (longitude, latitude - in that order!) coordinates, or a vector with cell numbers. It does NOT say that the set of locations can

Re: [R] Converting .grib to excel file

2024-06-26 Thread Richard O'Keefe
know how to reduce the volume or extract some of the > grib file data to send it for you. The file has the volume of 6 Megabyte. > I can send it by email. > The file has 6 met parameters and Date (day/month/year hour:minute). > I want the exported file as excel contains 7 columns (Dat

Re: [R] Converting .grib to excel file

2024-06-25 Thread Richard O'Keefe
Your message referred to an attached file but there was no attachment, I have no account at that service, so could not download a sample for myself. Does the licence for the data even allow you to send some of it in a message? Which parameters are you extracting? When you say "it didn't work", w

Re: [R] Naming output file

2024-06-24 Thread Richard O'Keefe
The subject line says (capitalisation changed) "name output FILE" but I see no attempt in the sample code to create an output FILE. I was expecting to see something like write(, file = paste0("bop",im)) On Mon, 24 Jun 2024 at 23:41, Steven Yen wrote: > > I would like a loop to > > (1) read data

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

2024-06-19 Thread Richard O'Keefe
You can get an external 1TB hard drive for NZD 60 if you shop around. That's USD 37 or GBP 29. How much data do you have and how valuable? You don't need a whole 'nother laptop to backup! If you did, you could get a 2nd-hand laptop adequate for the purpose for NZD 150 (USD 92, GBP 72). Again, how m

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

2024-04-24 Thread Richard O'Keefe
h values continue to work." > > As Peter Dalgaard already pointed out, that is false. > > > x <- 1:4 > > x[-1] > [1] 2 3 4 > > elt(x,-0) > [1] 1 > > Cheers, > Bert > > On Tue, Apr 23, 2024 at 4:55 PM Richard O'Keefe wrote: > > >

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

2024-04-24 Thread Richard O'Keefe
pr 2024 at 13:20, Bert Gunter wrote: > > "This works with any single-index value, and lets all the existing > operations for such values continue to work." > > As Peter Dalgaard already pointed out, that is false. > > > x <- 1:4 > > x[-1] > [1] 2

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

2024-04-23 Thread Richard O'Keefe
" You could have a global setting for whether ALL operations are 0-based or 1-based" NO. You could, but you shouldn't. []IO (index origin) in APL has always let you do this and it has always been a good way to break lots of stuff. A much better approach is to think of "index-from-0" and "inde

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

2024-04-23 Thread Richard O'Keefe
Does it have to use square bracket syntax? elt <- function (x, i) x[i+1] "elt<-" <- function (x, i, value) { x[i+1] <- value; x } > u <- c("A","B","C") > elt(u,0) [1] "A" > elt(u,length(u)-1) [1] "C" > elt(u,0) <- "Z" > u [1] "Z" "B" "C" This works with any single-index value, and lets all the ex

[R] Just for your (a|be)musement.

2024-04-13 Thread Richard O'Keefe
I recently had the chance to read a book explaining how to use ChatGPT with a certain programming language. (I'm not going to describe the book any more than that because I don't want to embarrass whoever wrote it.) They have appendix material showing three queries to ChatGPT and the answers. Pa

Re: [R] Printout and saved results

2024-03-25 Thread Richard O'Keefe
Not clear what you mean by "saved". If you call a function and the result is printed, the result is remembered for a wee while in the variable .Last.value, so you can do > function.with.interesting.result(...) > retained.interesting.result <- .Last.value or even > .Last.value -> retained.intere

Re: [R] as.complex()

2024-03-25 Thread Richard O'Keefe
What is your actual problem that you are trying to solve by comparing imaginary numbers? The reals are an ordered field. The complex numbers are a field but cannot support an ordering that is consistent with the field (or even ring) axioms. The imaginary numbers are not a field or even a ring. To q

Re: [R] an issue about subsetting a vector

2024-03-25 Thread Richard O'Keefe
For questions like this, go to the manual. Visit cran.r-project.org The nav-bar on the left includes "Documentation/Manuals/FAQ/Contributed". Click on Manuals. Look at "An Introduction to R" and click on the HTML link for the current release (this is the first link on the page) Scroll down to see

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

2024-03-02 Thread Richard O'Keefe
On my system, pdftexcmds.sty can be found in /usr/share/texlive/texmf-dist/tex/generic/pdftexcmds/pdftexcmds.sty A quick poking around with 'apt' and 'dpkg-query -L' told me that this comes from the texlive-latex-recommended Ubuntu package. So on my system, if I didn't already have this, sudo apt

Re: [R] Initializing vector and matrices

2024-03-02 Thread Richard O'Keefe
atch with a subscript out of bounds error > but with the extra space it now runs without errors. > > Tim > > > > -Original Message- > From: R-help On Behalf Of Richard O'Keefe > Sent: Thursday, February 29, 2024 5:29 AM > To: Steven Yen > Cc: R-help Mailin

Re: [R] Initializing vector and matrices

2024-02-29 Thread Richard O'Keefe
x <- numeric(0) for (...) { x[length(x)+1] <- ... } works. You can build a matrix by building a vector one element at a time this way, and then reshaping it at the end. That only works if you don't need it to be a matrix at all times. Another approach is to build a list of rows. It's not a ma

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

2024-02-28 Thread Richard O'Keefe
The first vector-oriented programming language I ever learned or used was APL, and APL makes *no* distinction between row vectors and column vectors. It has rank-0 (scalar), rank-1 (vector), rank-2 (matrix), rank-3 ... and so on arrays. A rank-1 array is a rank-1 array is a rank-1 array and ther

Re: [R] Looping

2024-02-18 Thread Richard O'Keefe
f <- function (filename) { data<- read.csv(filename) .. } for (filename in paste0("data", 1:24, ".csv")) f(filename) Depending on what exactly you have in your file system, for (filename in system("ls data*.csv", TRUE)) f(filename) might work. On Mon, 19 Feb 2024 at 16:33, Steven Yen wrote

Re: [R] Basic astronomy package recommendation wanted.

2024-01-30 Thread Richard O'Keefe
tion, which is probably not what you > want, but may do other things you may find helpful. > > > > On Jan 30, 2024, at 5:44 AM, Enrico Schumann > > wrote: > > > > On Tue, 30 Jan 2024, Richard O'Keefe writes: > > > >> Given > >> - UTC ti

Re: [R] Basic astronomy package recommendation wanted.

2024-01-30 Thread Richard O'Keefe
Thank you very much. suncalc looks like just what I want. On Tue, 30 Jan 2024 at 23:44, Enrico Schumann wrote: > > On Tue, 30 Jan 2024, Richard O'Keefe writes: > > > Given > > - UTC timestamp > > - a location (latitude,longitude,elevation) > > I want to

[R] Basic astronomy package recommendation wanted.

2024-01-30 Thread Richard O'Keefe
Given - UTC timestamp - a location (latitude,longitude,elevation) I want to know - the sun angles - the moon angles - the phase of the moon. I looked on CRAN for astronomy, but didn't notice anything that seems to offer what I want. I could try coding these functions myself, but "if you didn'

Re: [R] Advice on starting to analyze smokestack emissions?

2023-12-12 Thread Richard O'Keefe
This https://ncceh.ca/resources/evidence-reviews/crematoria-emissions-and-air-quality-impacts might provide some useful information. On Wed, 13 Dec 2023 at 04:53, Bert Gunter wrote: > > You might also try the R-Sig-ecology list, though I would agree that it's > not clearly related. Still, air po

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

2023-11-10 Thread Richard O'Keefe
e present). There's no half-and-half form. On Mon, 6 Nov 2023 at 22:01, Martin Maechler wrote: > > >>>>> Richard O'Keefe > >>>>> on Mon, 6 Nov 2023 18:37:34 +1300 writes: > > > Thanks to all who replied. On Mon, 6 Nov 2023 at 18

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

2023-11-05 Thread Richard O'Keefe
Thanks to all who replied. On Mon, 6 Nov 2023 at 18:37, Richard O'Keefe wrote: > OK, so the consensus is > (1) One cannot make strptime accept ISO8601-compliant zone designators > (2) The lubridate package can > (3) Or one can hack away with regex. > Lubridate it is, then.

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

2023-11-05 Thread Richard O'Keefe
:35:00+03:00"> ymd_hms(x)[1] "2017-02-28 10:35:00 UTC" > > > > > > > Thanks > > Jim Holtman > *Data Munger Guru* > > > *What is the problem that you are trying to solve?Tell me what you want to > do, not how you want to do it.* > > > On Sun, No

[R] strptime with +03:00 zone designator

2023-11-05 Thread Richard O'Keefe
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 documentation to get it to accept +hh:mm with a colon separator, and everything I tried gave me NA as the answer. Sect

Re: [R] Yamamoto test in BreakPoints package

2023-10-19 Thread Richard O'Keefe
Visit the page at CRAN https://cran.r-project.org/web/packages/BreakPoints/index.html and download BreakPoints_1.2.tar.gz and you will find yamamoto.R in there. Sadly, there are no useful comments in there.

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

2023-10-18 Thread Richard O'Keefe
This seems unnecessarily complex. Or rather, it pushes the complexity into an arcane notation What we really want is something that says "here is a string, here is a pattern, give me all the substrings that match." What we're given is a function that tells us where those substrings are. # greg.ma

Re: [R] if-else that returns vector

2023-10-12 Thread Richard O'Keefe
?ifelse 'ifelse' returns a value with the same shape as 'test' which is filled with elements selected from either 'yes' or 'no' depending on whether the element of 'test' is 'TRUE' or 'FALSE'. This is actually rather startling, because elsewhere in the S (R) language, operands are normal

Re: [R] Problem with compatible library versions

2023-10-12 Thread Richard O'Keefe
program that I write today would still run > without changes in 10 years? > Tim > > -Original Message- > From: R-help On Behalf Of Richard O'Keefe > Sent: Wednesday, October 11, 2023 8:08 AM > To: Uwe Ligges > Cc: r-help@r-project.org > Subject: Re: [R] Proble

Re: [R] Problem with compatible library versions

2023-10-11 Thread Richard O'Keefe
There is a fairly straightforward way to load older versions of packages, and that is to use the 'groundhog' package. As the first sentence of https://groundhogr.com/ puts it: Make your R scripts reproducible by replacing library(pkg) with groundhog.library(pkg, date). pkg can be a vector of

Re: [R] Question about R software and output

2023-10-03 Thread Richard O'Keefe
R is open source software, available from CRAN servers, but also packaged for various Linux distributions. On this machine, running Ubuntu, R was installed using the 'apt' package manager. R is a complete programming language with built-in support for reading and writing over the network. Packag

Re: [R] How to import an excel data file

2023-09-23 Thread Richard O'Keefe
Are you sure that read.csv() can't read your data? [If you depend on extra packages you might want to consider using the 'groundhog' package so that you can be more confident of reproducing your work in a year or two.] You said that your question is how you should write the name of the file in y

Re: [R] Help with plotting and date-times for climate data

2023-09-13 Thread Richard O'Keefe
data I > have (2011 to present). I'm going on a trip to this area, and want to > know how to pack. > > Thanks for your interest. > > -Kevin > > On Thu, 2023-09-14 at 03:07 +1200, Richard O'Keefe wrote: > > I am well aware of the physiological implications &

Re: [R] Help with plotting and date-times for climate data

2023-09-13 Thread Richard O'Keefe
nd max > thresholds. > > All I have done is provide an example where min and max could have a real > world use. I use max(temp) over some interval and then update an > accumulated thermal units variable based on the outcome. That detail is not > evident in the original request. >

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

2023-09-13 Thread Richard O'Keefe
> d <- read.table("data.txt", TRUE) > cor(d[, 3:6]) VAR1 VAR2 VAR3 VAR4 VAR11111 VAR21111 VAR31111 VAR41111 VAR1 to VAR4 are, up to linear scaling, exactly the same variable. Why is that? On Wed, 13 Sept 2023 at 07:38, Loop Vi

Re: [R] Help with plotting and date-times for climate data

2023-09-13 Thread Richard O'Keefe
Off-topic, but what is a "mean temperature max" and what good would it do you to know you if you did? I've been looking at a lot of weather station data and for no question I've ever had (except "would the newspapers get excited about this") was "max" (or min) the answer. Considering the way that

Re: [R] Finding combination of states

2023-09-07 Thread Richard O'Keefe
The Data Colada blog has some articles about the groundhog package. See particular https://datacolada.org/95 and especially https://datacolada.org/100 I now have three reasons for preferring to stick with the core library packages as much as possible. 1) It's just better style to do more with less

Re: [R] Merge and replace data

2023-09-07 Thread Richard O'Keefe
I'm a little confused, because the sample code does something that none of the suggestions does. x1 <- c(116,0,115,137,127,0,0) x2 <- c(0,159,0,0,0,159,127) [You] want : xx <- c(116,115,137,127,159, 127) Assuming that there should have been two copies of 159 in xx, this is xx <- c(x1[x1 != 0], x2[

Re: [R] Problem with filling dataframe's column

2023-06-14 Thread Richard O'Keefe
Consider m <- list(foo=c(1,2),"B'ar"=as.matrix(1:4,2,2),"!*#"=c(FALSE,TRUE)) It is a collection of elements of different types/structures, accessible via string keys (and also by position). Entries can be added: m[["fred"]] <- 47 Entries can be removed: m[["!*#"]] <- NULL How much more

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

2023-04-21 Thread Richard O'Keefe
What does it mean when one column is just blank, neither a number nor NA, just nothing? On Fri, 21 Apr 2023 at 07:08, AbouEl-Makarim Aboueissa < abouelmakarim1...@gmail.com> wrote: > Dear All: the attached file in the .txt format > > > > *Re:* detect and replace outliers by the average > > > >

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

2023-04-21 Thread Richard O'Keefe
This can be seen as three steps: (1) identify outliers (2) replace them with NA (trivial) (3) impute missing values. There are packages for imputing missing data. See https://www.analyticsvidhya.com/blog/2016/03/tutorial-powerful-packages-imputing-missing-values/ Here I just want to address the fi

Re: [R] Matrix scalar operation that saves memory?

2023-04-13 Thread Richard O'Keefe
"wear your disc quite badly"? If you can afford a computer with 512 GB of memory, you can afford to pay $100 for a 2 TB external SSD, use it as scratch space, and throw it away after a month of use. A hard drive is expected to last for more than 40,000 hours of constant use. Are you sure that you

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

2023-04-04 Thread Richard O'Keefe
R *does* search the environment stack. > search() [1] ".GlobalEnv""package:stats" "package:graphics" [4] "package:grDevices" "package:utils" "package:datasets" [7] "package:methods" "Autoloads" "package:base What you seem to be missing is that a package may contain bindi

Re: [R] Simple Stacking of Two Columns

2023-04-04 Thread Richard O'Keefe
Just to repeat: you have NamesWide<-data.frame(Name1=c("Tom","Dick"),Name2=c("Larry","Curly")) and you want NamesLong<-data.frame(Names=c("Tom","Dick","Larry","Curly")) There must be something I am missing, because NamesLong <- data.frame(Names = c(NamesWide$Name1, NamesWide$Name2))

Re: [R] identify the distribution of the data

2023-02-09 Thread Richard O'Keefe
fitdistrplus is a great package. But the documentation for the fitdist function makes something very clear: fitdistr(data, distr, ...) distr [is] A character string "name" naming a distribution for which the corresponding density function dname, the corresponding distribut

Re: [R] overlaying two graphs / plots /lines

2023-02-09 Thread Richard O'Keefe
It's easy enough to do this, the question is "what does it MEAN?" If you overlay two graphs, what comparisons will people naturally make, and what do you want them to make? What transformations on the x axis would make two vertically aligned points about the "same" thing? What transformations on th

Re: [R] Plotmath isn't working for special characters

2023-01-24 Thread Richard O'Keefe
plot(1,1, main=quote(x>=y)) produces the symbol for me. plot(1,1, main=parse(text="x>=y")) also produces the symbol. setting value version R version 4.2.2 Patched (2022-11-10 r83330) os Ubuntu 22.04.1 LTS system x86_64, linux-gnu ui X11 language en_NZ:en collate en_NZ.iso88

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

2023-01-15 Thread Richard O'Keefe
I wonder if the real confusino is not R's scope rules? (begin .) is not Lisp, it's Scheme (a major Lisp dialect), and in Scheme, (begin (define x ...) (define y ...) ...) declares variables x and y that are local to the (begin ...) form, just like Algol 68. That's weirdness 1. Javascript had a si

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

2023-01-10 Thread Richard O'Keefe
I am more than a little puzzled by your question. In the construct {expr1; expr2; expr3} all of the expressions expr1, expr2, and expr3 are evaluated, in that order. That's what curly braces are FOR. When you want some expressions evaluated in a specific order, that's why and when you use curly br

Re: [R] R Certification

2023-01-04 Thread Richard O'Keefe
I note that Java, for example, has changed a LOT and a certificate from, say, 10 years ago, wouldn't impress me much today. The same can be said of C#, and of R. So the question would be, "what VALUE would a certificate about R provide?" Well, for one thing, it would be a certificate of proficien

Re: [R] Pipe operator

2023-01-03 Thread Richard O'Keefe
This is both true and misleading. The shell pipe operation came from functional programming. In fact the shell pipe operation is NOT "flip apply", which is what |> is, but it is functional composition. That is out = let out = command cmd1 | cmd2 = \x.cmd2(cmd1(x)). Pragmatically, the Unix shell

Re: [R] Pipe operator

2023-01-03 Thread Richard O'Keefe
"Does saving of variables speed up processing" no "or save memory" no. The manual is quite explicit: > ?"|>" ... Currently, pipe operations are implemented as syntax transformations. So an expression written as 'x |> f(y)' is parsed as 'f(x, y)'. Strictly speaking, using |> *doesn't* save any var

Re: [R] Pipe operator

2023-01-03 Thread Richard O'Keefe
The simplest and best answer is "fashion". In FSharp, > (|>);; val it: ('a -> ('a -> 'b) -> 'b) The ability to turn f x y into y |> f x makes perfect sense in a programming language where Currying (representing a function of n arguments as a function of 1 argument that returns a function of n-1 arg

Re: [R] Integer division

2022-12-20 Thread Richard O'Keefe
I was surprised that > there is no consensus regarding the definition of such elementary > functions. > > Göran > > On 2022-12-20 03:01, Richard O'Keefe wrote: > > The Fortran '08 standard says << > > One operand of type integer may be divided by anothe

Re: [R] Integer division

2022-12-19 Thread Richard O'Keefe
The Fortran '08 standard says << One operand of type integer may be divided by another operand of type integer. Although the mathematical quotient of two integers is not necessarily an integer, Table 7.2 specifies that an expression involving the division operator with two operands of type integer

Re: [R] Preexisting Work on Data- and Control-Flow Analysis

2022-12-07 Thread Richard O'Keefe
You should probably look at the compiler. One issue with data and control flow analysis in R is that f <- function (x, y) x + y f(ping, pong) may invoke an S3 (see ?S3groupGeneric, Ops) or S4 (see ?Arith) method, which might not have existed when f was analysed. Indeed, f <- function (x, y

Re: [R] Single pdf of all R vignettes request

2022-10-31 Thread Richard O'Keefe
Let's put some numbers on that. The CRAN package repository claims 18770 packages. That excludes packages in other repositories, of course; the total collection of vignettes may not be discoverable. It could be useful to collect documents and vignettes and stuff them into an information retrieval s

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

2022-10-26 Thread Richard O'Keefe
This is explained in books about S and R. The first place to look is of course > ?"if" which says Note that it is a common mistake to forget to put braces ('{ .. }') around your statements, e.g., after 'if(..)' or 'for()'. In particular, you should not have a newline between '}'

Re: [R] cannot print a list with cat

2022-10-26 Thread Richard O'Keefe
\n is for TERMINATING lines. Just like in C, C++, Java, C#, Python, Ruby, Erlang, pretty much everything that uses \n in strings at all. sprintf("gradtol = %e\n", mycontrol$gradtol) makes sense. More generally, sprintf() takes as many arguments as you care to give it, so cat(sprintf("tol = %e\nr

Re: [R] fortune nomination WAS: Re: How long does it take to learn the R programming language?

2022-09-29 Thread Richard O'Keefe
"R longa, vita brevis." On Thu, 29 Sept 2022 at 07:02, Berry, Charles wrote: > Aha! > CCB > > > On Sep 27, 2022, at 6:08 PM, Rolf Turner > wrote: > > > > > > On Mon, 26 Sep 2022 11:14:57 +0800 > > Turritopsis Dohrnii Teo En Ming wrote: > > > >> Subject: How long does it take to learn the R pro

Re: [R] Reading very large text files into R

2022-09-29 Thread Richard O'Keefe
If I had this problem, in the old days I'd've whipped up a tiny AWK script. These days I might use xsv or qsv. BUT first I would want to know why these extra fields are present and what they signify. Are they good data that happen not to be described in the documentation? Do they represent a def

Re: [R] How long does it take to learn the R programming language?

2022-09-28 Thread Richard O'Keefe
How long does it take to learn R? Meaningless question. Who is learning? Are they new to programming? What other programming languages do they know? Are they new to statistics? What other statistics environments do they know? Are they learning by themselves? Do they have a mentor? Fellow students?

Re: [R] Write text file in Fortran format

2022-09-21 Thread Richard O'Keefe
Background: there is a data file whose records, after a header, can be describedby the Fortran format given in the header. YES, you can easily read that file in R, and you don't even need to know anything about Fortran formats to do it. You can read the file as a data frame using read.table using

Re: [R] Mathematical working procedure of imputation methods (medianImpute, knnImpute, and bagImpute) in caret package R

2022-09-20 Thread Richard O'Keefe
?preProcess k-nearest neighbor imputation is carried out by finding the k closest samples (Euclidian distance) in the training set. Imputation via bagging fits a bagged tree model for each predictor (as a function of all the others). This method is simple, accurate and acce

Re: [R] inconsistency in switch statements.....

2022-09-07 Thread Richard O'Keefe
You DON'T need to use backticks. switch() is much older than backticks. Ordinary quotation marks are fine. > switch(as.character(1), "2"="YES", "1"="NO") [1] "NO" On Thu, 8 Sept 2022 at 07:46, akshay kulkarni wrote: > Dear Bert, > Thanks...I went through the doc pages but c

Re: [R] Unicode chars

2022-08-25 Thread Richard O'Keefe
PDFLaTeX does support Latin-1, and this is a Latin-1 character. On Thu, 25 Aug 2022 at 15:35, Jeff Newmiller wrote: > Are you aware that pdfLatex does not support Unicode? You need to use > xeLatex. But I don't use Sweave, so I don't know how you go about making > that choice. > > On August 24,

Re: [R] Need to insert various rows of data from a data frame after particular rows from another dataframe

2022-07-27 Thread Richard O'Keefe
I'm retired, and I had an hour on my hands while tea cooked and my granddaughter did her homework, and I just *love* showing off how helpful I am. Good news: someone finally looked at your data. (That would be me.) Bad news: it's going to be a lot of work to do what you want to, and YOU SHOULDN'T

Re: [R] Does the function "c" have a character limit?

2022-07-13 Thread Richard O'Keefe
Breaking up the *line* doesn't mean breaking up the *command*. For example, x <- c( "FOOBAR", # 1 ... "FOOBAR", # 4999 "UGGLE") works fine, with source(..), with "R -f ...", and other ways. Each *line* is short, but it's still one *command*. I'd probably put that much data in a fil

Re: [R] Please guide

2022-07-11 Thread Richard O'Keefe
he just reply to write the table. So, I > need to know how to write the table for the code mentioned above? > I hope that you got my question now. > > Regards > Chishti > > On Mon, Jul 11, 2022 at 3:05 PM Richard O'Keefe wrote: > >> (1) Your sample code refers to a

Re: [R] Please guide

2022-07-11 Thread Richard O'Keefe
(1) Your sample code refers to a file DY_Table.xlsx but the file you attached to a later message is called Data_oil_agri.xlsx and I find it hard to believe that they are the same file. (2) gmail offered me two different ways to download the file, but neither of them worked. Fortun

Re: [R] A humble request

2022-07-03 Thread Richard O'Keefe
Zubair Chishti < mzchis...@eco.qau.edu.pk> wrote: > Dear Respected Experts and specifically Professor Richard O'Keefe, > Thank you so much for your precious time and generous help. However, the > problem is still there and I am just unable to resolve it due to the lack > of exper

Re: [R] Create a categorical variable using the deciles of data

2022-06-15 Thread Richard O'Keefe
but they too take one approach to solve a problem rather > than "here is a problem" and "these are all possible solutions." I > appreciate seeing alternative solutions. > > Tim > > -Original Message- > From: R-help On Behalf Of Richard O'Kee

[R] How to represent tree-structured values

2022-05-29 Thread Richard O'Keefe
There is a kind of data I run into fairly often which I have never known how to represent in R, and nothing I've tried really satisfies me. Consider for example ... - injuries ... - injuries to limbs ... - injuries to extremities ... - injuries to hands - i

Re: [R] Is there a canonical way to pronounce CRAN?

2022-05-06 Thread Richard O'Keefe
I would like to point out that there is an English word "cran" (one syllable, rhymes with "can" "ban" "than" ...). It means " a measure of fresh herrings, equivalent to 37 1/2 gallons". If you are going to use "CRAN" as the name of something, you are going to have to expect me to pronounce it lik

Re: [R] Symbol/String comparison in R

2022-04-14 Thread Richard O'Keefe
under the impression that > this particular collation was in fact supposed to collate according to the > numerical magnitude of the UTF-8 code points but it does not appear to do > so. > > On April 14, 2022 4:25:17 AM PDT, Richard O'Keefe > wrote: > >To the original

Re: [R] A question about Spatial in Kriging

2022-03-25 Thread Richard O'Keefe
Thank you for the reference to "Spatial Predictive Modeling with R". I look forward to reading it. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-

Re: [R] A question about Spatial in Kriging

2022-03-25 Thread Richard O'Keefe
Start with a good book like "Applied Spatial Data Analysis with R". If you want to do spatial data analysis, then you are going to need measurements at lots of different places in space. On Thu, 24 Mar 2022 at 23:14, Hasliza Rusmili wrote: > Thank you very much. I will ask the question there. >

Re: [R] Is there a Truth Table Generator in R?

2022-03-13 Thread Richard O'Keefe
I too have been wondering what "a truth table generator" meant to the OP. There are web sites like https://web.stanford.edu/class/cs103/tools/truth-table-tool/ where you can type in a formula and it will display a truth table with a column for each variable and a column for the result. The last pr

Re: [R] Convert a character string to variable names

2022-02-14 Thread Richard O'Keefe
th the spirit of the language. On Mon, 14 Feb 2022 at 14:57, Ebert,Timothy Aaron wrote: > But I find things like this website on mutable and immutable objects in > python “ > https://www.geeksforgeeks.org/mutable-vs-immutable-objects-in-python/” > Would this be better titled “Objects ve

Re: [R] SDLC methodology for R and Data science......

2022-02-13 Thread Richard O'Keefe
There are at least two ways to use R. If you have devised a statistical/data science technique and are writing a package to be used by other people, that is normal software development that happens to be using R and the R tool. Lots of attention to documentation and tests. Test-Driven Development

Re: [R] Convert a character string to variable names

2022-02-10 Thread Richard O'Keefe
mming. > > I have never used get(), so I will keep that in mind. I agree that it > makes life much easier to enter the data in the way it will be analyzed. > > > > > -Original Message- > From: Jeff Newmiller > Sent: Tuesday, February 8, 2022 10:10 PM > T

Re: [R] Error Awareness

2021-12-24 Thread Richard O'Keefe
You want to read this: http://adv-r.had.co.nz/Exceptions-Debugging.html It describes all the ways that R can report a problem and all the ways you can catch such a report while still in R. Let me heartily recommend the whole site, or better yet, the book https://www.amazon.com/dp/0815384572/ref=

Re: [R] checkpointing

2021-12-13 Thread Richard O'Keefe
Use VirtualBox. You can take a 'snapshot' of a running virtual machine, either from the GUI or from the CLI (vboxmanage snapshot ...) and restore it later. This requires NO changes to R. Snapshots can be restored on another machine of the same kind with the same system software. VirtualBox is f

Re: [R] checkpointing

2021-12-13 Thread Richard O'Keefe
I used to work on a Prolog implementation that did something similar. At any point you could explicitly save a snapshot of the current state and then from the operating system command line, resume it. This wasn't really for checkpointing. It was so that you could load up a customised environment,

Re: [R] subset data frame problem

2021-12-13 Thread Richard O'Keefe
You want to DELETE rows satisfying the condition P & Q. The subset() function requires an expression saying what you want to RETAIN, so you need subset(PD, !(P & Q)). test <- subset(PD, !(Class == "1st" & Survived == "No")) By de Morgan's laws, !(P & Q) is the same as (!P) | (!Q) so you could als

Re: [R] Question about Rfast colMins and colMaxs

2021-12-02 Thread Richard O'Keefe
What puzzles me is why you are not just using lapply(some.data.frame, min) lapply(some.data.frame, max) or as.vector(lapply(...)) Why go to another package for this? Is it the indices you want? col.min.indices <- function (some.data.frame) { v <- sapply(some.data.frame, function (column)

Re: [R] Large data and space use

2021-11-28 Thread Richard O'Keefe
If you have enough data that running out of memory is a serious problem, then a language like R or Python or Octave or Matlab that offers you NO control over storage may not be the best choice. You might need to consider Julia or even Rust. However, if you have enough data that running out of mem

Re: [R] Date read correctly from CSV, then reformatted incorrectly by R

2021-11-21 Thread Richard O'Keefe
CSV data is very often strangely laid out. For analysis, Buffer Date Reading 100... ... 100... ... and so on is more like what a data frame should be. I get quite annoyed when I finally manage to extract data from a government agency only to find that my tax money has been spent on maki

  1   2   3   >