Re: [R] [External] Printout and saved results

2024-03-25 Thread Richard M. Heiberger
dstat4 <- function(data) { Mean<- apply(data, 2, mean, na.rm=TRUE) Std.dev <- apply(data, 2, sd, na.rm=TRUE) Min <- apply(data, 2, min, na.rm=TRUE) Max <- apply(data, 2, max, na.rm=TRUE) Obs <- dim(data)[1] data.frame(Mean, Std.dev, Min, Max, Obs) } ## don't round inside a

Re: [R] [External] dput(..., file = stderr())

2024-03-01 Thread Richard M. Heiberger
I see the same thing in a fresh R session > dput(letters, file = stderr()) c("a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z") Warning message: In dput(letters, file = stderr()) : wrote too few characters >

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

2024-02-29 Thread Richard M. Heiberger
orrect size in advance is very helpful if you will be doing this division more than once. > On Feb 29, 2024, at 18:12, Richard M. Heiberger wrote: > > I decided to do a direct comparison of transpose and sweep. > > > library(microbenchmark) > > NN <- matrix(c(1, 2, 3, 4,

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

2024-02-29 Thread Richard M. Heiberger
I decided to do a direct comparison of transpose and sweep. library(microbenchmark) NN <- matrix(c(1, 2, 3, 4, 5, 6), nrow = 2, byrow = TRUE) # Example matrix lambda <- c(2, 3, 4) # Example vector colNN <- t(NN) microbenchmark( sweep = sweep(NN, 2, lambda, "/"), transpose =

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

2024-02-27 Thread Richard M. Heiberger
> t(t(NN)/lambda) [,1] [,2] [,3] [1,] 0.5 0.667 0.75 [2,] 2.0 1.667 1.50 > R matrices are column-based. MATLAB matrices are row-based. > On Feb 27, 2024, at 14:54, Evan Cooch wrote: > > So, trying to convert a very long, somewhat technical bit of lin alg > MATLAB code to R.

Re: [R] [External] Extracting Plot Arguments

2024-02-23 Thread Richard M. Heiberger
Does the grid.echo function in the gridGraphics package do what you want? Description Convert a scene that was drawn using the graphics package to an identical scene drawn with the grid package. > On Feb 21, 2024, at 22:49, Reed A. Cartwright wrote: > > Hi All, > > I'm building an autograding

Re: [ESS] [External] [R-win] Difficulty installing R packages under Windows 11 / Cygwin

2023-12-02 Thread Richard M. Heiberger via ESS-help
my initial reaction is that you are trying to hard. I haven't paid serious attention to Windows since I switched to Mac about 10 years ago. What I recall is that all the unix utilities (sh, awk, grep, etc) that you need are included in the Rtools collection. Indeed they are exactly the cygwin

Re: [ESS] [External] R Transcript opens in readonly buffer

2023-11-25 Thread Richard M. Heiberger via ESS-help
Yes, that is the designed behavior. A transcript is the history of a previous session. Normally you would not want to change it. What you might want to do is open a new .r file and copy the source code from the transcript into the new file. Pick up the entire section of transcript (input

Re: [R] [External] need help with plotmath and/or plotting unicode characters

2023-06-08 Thread Richard M. Heiberger
Use * instead of ~ XX <- 5 YY <- 10 plot(1:10) mtext(side=3, bquote(N <= .(XX) ~":" ~ .(YY))) mtext(side=1, bquote(N <= .(XX) *":" * .(YY))) > On Jun 7, 2023, at 22:14, Dennis Fisher wrote: > > R 4.2.3 > OS X > > Colleagues > > This should be easy -- but not for me. > > I want to plot text

Re: [R] [External] latticeExtra

2023-06-05 Thread Richard M. Heiberger
This works. > d$zz <- factor(d$z, levels=c("low","med","high")) > d$xx <- as.factor(d$x) > cloud(y~xx+zz, d, panel.3d.cloud=panel.3dbars, col.facet='grey', + xbase=0.4, ybase=0.4, scales=list(arrows=FALSE, col=1), + par.settings = list(axis.line = list(col = "transparent"))) > the

Re: [R] [External] Error in percentage stacked barplot

2023-05-03 Thread Richard M. Heiberger
quot;#BEBEBE", "#6193CE", > "#00508C", "#E94E1B", "#BEBEBE"), legend.position="left") > > Once again, thank you very much. > > Kind regards, > Maria > > > Στις Τρίτη 2 Μαΐου 2023 στις 08:51:16 μ.μ. GMT+1, ο χρήστης R

Re: [R] [External] Error in percentage stacked barplot

2023-05-02 Thread Richard M. Heiberger
## you may need to install HH install.packagess("HH") library(HH) hellisheidi <- read.table(text=" Component Sample1 Sample2 Sample3 CaO455248 SiO2 252218 Al2O3 15

[R] linux, emacs, R on iPhone/iPad

2022-11-21 Thread Richard M. Heiberger
I discovered that the "iSH shell" is available for the iPhone/iPad from the Applications app. this is Alpine linux Once iSH is loaded from the App store, then open it to a shell and download apk add emacs apk add R emacs works well for writing files and sending them to a bigger computer by

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

2022-09-29 Thread Richard M. Heiberger
I think you need the fill=TRUE argument. See ?read.table > On Sep 29, 2022, at 11:14, Enrico Schumann wrote: > > On Thu, 29 Sep 2022, Nick Wray writes: > >> -- Forwarded message - >> From: Nick Wray >> Date: Thu, 29 Sept 2022 at 15:32 >> Subject: Re: [R] Reading very large

Re: [ESS] [External] Re: ESS confused about newest R

2022-07-13 Thread Richard M. Heiberger via ESS-help
The change in date format makes sense. The short term workaround is to set the specific R you want. In general, that ESS code on Windows was designed to find R in any of a number of standard places. The list of what those standard places are is also a variable you can set. The details have

Re: [R] [External] categorizing data

2022-05-29 Thread Richard M. Heiberger
Orig <- read.table(text=" tree shrub grass 32 11 47 23 41 26 49 23 18 ", header=TRUE) New <- Orig for (i in seq(nrow(Orig))) New[i,] <- c(10, 30, 50)[order(unlist(Orig[i,]))] New > On May 29, 2022, at 15:28, Janet Choate wrote: > > Hi R community, > I have a data frame with three

Re: [R] [External] A simple lattice histogram

2022-04-20 Thread Richard M. Heiberger
start here library(latticeExtra) c(histogram(~ card, data=CreditCard), histogram(~ reports, data=CreditCard)) then continue with resizePanels(c(histogram(~ card, data=CreditCard), histogram(~ reports, data=CreditCard), y.same=TRUE), w=c(2,16)) > On Apr 20, 2022, at 11:27, Naresh Gurbuxani

Re: [R] [External] Calculation error found

2022-04-07 Thread Richard M. Heiberger
Probably numerical precision. See FAQ 7.31 which is on your computer. Enter system(paste("open",file.path(base::system.file(), "../../doc/manual/R-FAQ.pdf"))) and the FAQ file will open. x <- 20 y <- 19.99 x-y x == y > On Apr 07, 2022, at 12:20, Sara Bortot wrote: > > Good

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

2022-02-07 Thread Richard M. Heiberger
> x <- c("mtcars$disp", "mtcars$hp", "mtcars$cyl") > x [1] "mtcars$disp" "mtcars$hp" "mtcars$cyl" > eval(parse(text=x)) [1] 6 6 4 6 8 6 8 4 4 6 6 8 8 8 8 8 8 4 4 4 4 8 8 8 8 4 4 4 8 6 8 4 > for (i in x) print(eval(parse(text=i))) [1] 160.0 160.0 108.0 258.0 360.0 225.0 360.0 146.7 140.8 167.6

Re: [R] [External] Funky calculations

2022-02-01 Thread Richard M. Heiberger
ot match. > > I do care what it does in my programs, of course. My goal here was to explain > to someone that the anomaly found was not really an anomaly and that careful > coding may be required in these situations. > > > -Original Message- > From: Richard M. Heiberger

Re: [R] [External] how to plot numeric variable against several categories with lattice bwplot?

2022-01-16 Thread Richard M. Heiberger
My guess, continuing from Rolf, is that you should be using conditioning bwplot(~ y | f2, df, layout=c(3,1)) > On Jan 16, 2022, at 22:22, Rolf Turner wrote: > > xxx <- trellis.par.get("box.umbrella") > xxx$lty <- 1 > trellis.par.set(box.umbrella=xxx) > junk <- rnorm(42) > bwplot(junk)

Re: [R] [External] NAs are removed

2022-01-14 Thread Richard M. Heiberger
this is a related issue. For this example, the ifelse statement is 10 times slower than a much simpler != comparison. > tmp <- sample(1:2, 40, TRUE) > tmp [1] 2 2 2 2 1 2 1 2 1 1 1 1 1 2 1 2 2 1 1 2 1 2 2 2 1 1 1 2 2 1 2 1 1 1 2 1 2 1 2 2 > ifelse(tmp==2, 0, 1) [1] 0 0 0 0 1 0 1 0 1 1 1 1 1

Re: [R] [External] Re: Save a graph file use jpeg(file=file)

2022-01-05 Thread Richard M. Heiberger
you can make the rgl window full screen, and then stretch the graph to fill the window, and then use snapshot 3d From: R-help on behalf of Sorkin, John Sent: Wednesday, January 5, 2022 8:23:34 PM To: Duncan Murdoch ; r-help@r-project.org (r-help@r-project.org)

Re: [R] [External] lattice contourplot: how to change line width?

2021-11-17 Thread Richard M. Heiberger
It didn't work because you left out the ... on the inside. it should be panel.contourplot(..., lty=1, lwd = 3) As Bert pointed out, you don't need to specify the panel function unless you are doing something complex. > On Nov 17, 2021, at 13:06, Bert Gunter wrote: > >>>

Re: [R] [External] ggplot2: multiple box plots, different tibbles/dataframes

2021-11-10 Thread Richard M. Heiberger
I don't understand your question. It looks like the example in ?lattice::panel.bwplot does exactly what you want (modulo using ggplot instead of lattice). Therefore it looks like creating a single column of y from the y in each data.frame, and also a single column of x from the x in each

Re: [R] [External] Error: unexpected symbol in "read.csv(12agosto.csv after installing Monterey

2021-11-08 Thread Richard M. Heiberger
yes, follow David Winsemius' advice. In this example, it looks not to be a mac issue, but a new R user issue. The partial message in the subject says read.csv(12agosto.csv The correct syntax is to quote the name of a file, so it should be read.csv("12agosto.csv") > On Nov 08, 2021, at 23:14,

Re: [R] [External] Rising and falling bar-plots simultaneously

2021-10-17 Thread Richard M. Heiberger
This does what I think you are asking for. If this isn't what you are looking for, please draw by brute force what you want for just the first 6 rows and post the R code. Or draw by hand for just the first 6 rows and post a png. ## install.packages("HH") ## if you don't already have HH

Re: [R] [External] Subset command

2021-10-15 Thread Richard M. Heiberger
the second command doesn't tell R that the variables are in the data.frame mydata. you will need exclude <- with(mydata, prim==-9 | etc) also you will need logical negation ! not arithmetic negation - > -c(TRUE,FALSE) [1] -1 0 > as.logical(-c(TRUE,FALSE)) [1] TRUE

Re: [R] [External] how to do inverse log of every value in every column in data frame

2021-10-14 Thread Richard M. Heiberger
> tmp <- data.frame(a=1:3,b=4:6) > exp(tmp) a b 1 2.718282 54.59815 2 7.389056 148.41316 3 20.085537 403.42879 > 2.718281828^tmp a b 1 2.718282 54.59815 2 7.389056 148.41316 3 20.085537 403.42879 > On Oct 14, 2021, at 13:10, Ana Marija wrote: > >>

Re: [R] [External] Missing text in lattice key legend

2021-10-11 Thread Richard M. Heiberger
looks like a paren outof place. the text is inside the points. it should be parallel to the points in the calling sequence. Get Outlook for iOS From: R-help on behalf of Luigi Marongiu Sent: Monday, October 11, 2021 7:46:36 AM To:

Re: [R] [External] conditional replacement of elements of matrix with another matrix column

2021-09-01 Thread Richard M. Heiberger
> A [,1] [,2] [1,] 12 NA [2,] 12 NA [3,] 12 NA [4,] 13 NA [5,] 13 NA [6,] 13 NA [7,] 14 NA [8,] 14 NA [9,] 14 NA > B [,1] [,2] [1,] 116 [2,] 117 [3,] 118 [4,] 139 [5,] 13 10 [6,] 13 11 [7,] 14 12

Re: [R] [External] Package for "design graphs"

2021-08-18 Thread Richard M. Heiberger
), 2, match(x$to, to)) } DesignGraph(expt1) DesignGraph(expt2) > On Aug 18, 2021, at 10:29, mad...@gmail.com wrote: > > I have attached a photo from our book > > E. Hansen "Introduktion til matematisk statistik" > > the numbers represent the labels of one f

Re: [R] [External] Package for "design graphs"

2021-08-17 Thread Richard M. Heiberger
can you post an example of the graph? From: R-help on behalf of mad...@gmail.com Sent: Tuesday, August 17, 2021 16:02 To: r-help@r-project.org Subject: [External] [R] Package for "design graphs" Hi, in our course littrature a "design graph" of two factors R

Re: [R] [External] Data is not properly written in csv file

2021-06-21 Thread Richard M. Heiberger
copy and paste from pdf usually scrambles tables. this package is probably suffering from that pdf characteristic. > On Jun 20, 2021, at 11:03, Sri Priya wrote: > > Dear R Users, > > I am working on extracting tables from PDF and I am writing that in a csv > file. When I executed the code,

Re: [ESS] [External] ESS Annoying "Feature"

2021-06-16 Thread Richard M. Heiberger via ESS-help
, completions, ...). Best, Lionel On 2/18/21, Richard M. Heiberger via ESS-help wrote: > On Jun 16, 2021, at 11:38, Bassett Jr,Roland L via ESS-help > wrote: > > Greetings to all. At some point, my ESS developed the following feature: > when I am editing an .Rnw file with R run

Re: [R] [External] LHS random number generator

2021-04-12 Thread Richard M. Heiberger
I don't know the LHS package. I don't see it on CRAN as either LHS, or more likely, as lhs (lower case). When you write back to the list, using plain text, not HTML, please state where the LHS package is located. I do see several potential problems. You use a function randomLHS without first

Re: [R] [External] unanticipated axis labels

2021-03-17 Thread Richard M. Heiberger
exactly! a warning when running would be very helpful. Thank you. Rich > On Mar 17, 2021, at 02:41, Deepayan Sarkar wrote: > > On Tue, Mar 16, 2021 at 11:35 PM Richard M. Heiberger wrote: >> >> library(lattice) >> library(latticeExtra) >> >

[R] unanticipated axis labels

2021-03-16 Thread Richard M. Heiberger
library(lattice) library(latticeExtra) barchart(matrix(c(1:6, 5:6)), main="unanticipated left axis labels", ylab="unanticipated inside labels") + latticeExtra::layer(panel.axis("left", half=FALSE, labels=1:8)) barchart(matrix(c(1:6, 5:6)), main="ok 1", ylab="anticipated") +

Re: [R] [External] Re: [External] Re: Help please

2021-03-11 Thread Richard M. Heiberger
The likert() function in library(likert) is not the same as the likert() function in library(HH). The likert function in the likert package creates an object that needs to be plotted. For the likert package you left out the line plot(likert::likert(scrounging)) This plot is not

Re: [R] [External] Re: Help please

2021-03-10 Thread Richard M. Heiberger
> table(scrounging) substr behav air ground tree vine active 1 536 foraging 2 630 inactive 6 113 snoozing 2 137 > likert(t(table(scrounging))) From: R-help on behalf of

Re: [R] [External] Help please

2021-03-10 Thread Richard M. Heiberger
> counts <- with(mtcars, table(gear, vs)) > counts vs gear 0 1 3 12 3 4 2 10 5 4 1 > likert(counts) > If this isn't enough, ask a more specific question. From: R-help on behalf of Richard M. Heiberger Sent: Wednesday,

Re: [R] [External] Help please

2021-03-10 Thread Richard M. Heiberger
install.packages("HH") library(HH) ?likert >From your description, I think your data is set up to work with likert() From: R-help on behalf of Areti Panopoulou Sent: Wednesday, March 10, 2021 13:29 To: r-help@r-project.org Subject: [External] [R] Help

Re: [ESS] [External] Re: ESS M-x R failing in a Windows installation

2021-03-10 Thread Richard M. Heiberger via ESS-help
The relevant question is what version of ess are you using? more specifically which version of ess is included with VIncent Goulet's emacs-26.1? the "bin/x64/Rterm.exe" construction is not in ess-16.10 It is in ess-18.10 the /x64/ wasn't meaningful until R stsarted releasing both 32-bit

Re: [R] [External] Re: mpfr function in Rmpfr crashes R

2021-03-07 Thread Richard M. Heiberger
this is probably a Mac M1. The problem and potential solution is described here: https://stat.ethz.ch/pipermail/r-sig-mac/2021-February/014003.html From: R-help on behalf of Duncan Murdoch Sent: Sunday, March 7, 2021 13:03 To: Roger Bos;

Re: [ESS] [External] Re: [External] Re: [External] Re: emacs 27.1 crashes regularly on Mac M1

2021-03-05 Thread Richard M. Heiberger via ESS-help
lder) until I hear further. Rich ____________ From: Richard M. Heiberger Sent: Friday, March 5, 2021 12:18 To: ess-help@r-project.org; Sparapani, Rodney Subject: Re: [External] Re: [ESS] [External] Re: [External] Re: emacs 27.1 crashes regularly on Mac M1 good idea. i am

Re: [ESS] [External] Re: [External] Re: [External] Re: emacs 27.1 crashes regularly on Mac M1

2021-03-05 Thread Richard M. Heiberger via ESS-help
good idea. i am now downloading a universal build instead of the x86-64 that Vincent Goulet distributed. I will report back in a few days. From: ESS-help on behalf of Sparapani, Rodney via ESS-help Sent: Friday, March 5, 2021 09:17 To:

Re: [ESS] [External] Re: [External] Re: emacs 27.1 crashes regularly on Mac M1

2021-03-04 Thread Richard M. Heiberger via ESS-help
tore.c, > line 192. The current crash does not have an equivalent statement. I will be happy to forward this type of message directly to emacs. To whom should it be sent? Rich ________ From: Richard M. Heiberger Sent: Wednesday, March 3, 2021 12:04 To: ess-

Re: [ESS] [External] Re: [External] Re: emacs 27.1 crashes regularly on Mac M1

2021-03-03 Thread Richard M. Heiberger via ESS-help
i almost never use those menus. my fingets know the emacs key-combinations too well. It comes out of the blue and catches me unawares. The only thing that occurs to me is something similar to Rmpfr error discussed on R-sig-mac list about a week ago. Simon traced it to a rarely used intel

Re: [ESS] [External] Re: emacs 27.1 crashes regularly on Mac M1

2021-03-02 Thread Richard M. Heiberger via ESS-help
Goulet Sent: Tuesday, March 2, 2021 14:51 To: Richard M. Heiberger Cc: ess-h...@stat.math.ethz.ch Subject: [External] Re: emacs 27.1 crashes regularly on Mac M1 Hi Richard, I can't test as I don't have an M1 Mac available. Did you try David Caldwell's "bare" binaries: https://emacsfor

[ESS] emacs 27.1 crashes regularly on Mac M1

2021-03-01 Thread Richard M. Heiberger via ESS-help
I don't know if this is emacs issue or an emacs plus ESS issue. I am using Vincent Goulet's "Emacs Modified for macOS is a distribution of GNU Emacs 27.1 (released August 10, 2020) bundled with a few select packages for R developers and LaTeX users." Process: Emacs-x86_64-10_14

Re: [R] [External] Concatenation?

2021-02-17 Thread Richard M. Heiberger
> paste(c("A","B","C"), c(1,2,3), sep="") [1] "A1" "B2" "C3" in your example paste(site, depth, sep="") From: R-help on behalf of Parkhurst, David Sent: Wednesday, February 17, 2021 4:09 PM To: r-help@r-project.org Subject: [External] [R]

Re: [R] [External] Dimensioning lists.

2021-02-14 Thread Richard M. Heiberger
Use double [[ ]] > xxx[[2,3]] $a [1] "n" $b [1] 20 > From: R-help on behalf of Rolf Turner Sent: Sunday, February 14, 2021 10:35 PM To: "r-help@R-project.org\" "@r-project.org Subject: [External] [R] Dimensioning lists. I have a setting in which

Re: [ESS] unexpected behavior for Emacs-27.1-1-modified-1 for two MacBooks.

2021-01-27 Thread Richard M. Heiberger via ESS-help
ebrew/install/HEAD/install.sh)" /usr/local/bin/brew update /usr/local/bin/brew install aspell /usr/local/bin/brew link --overwrite aspell From: ESS-help on behalf of Richard M. Heiberger via ESS-help Sent: Tuesday, January 26, 2021 8:38 PM T

Re: [ESS] unexpected behavior for Emacs-27.1-1-modified-1 for two MacBooks.

2021-01-26 Thread Richard M. Heiberger via ESS-help
From: Dirk Eddelbuettel Sent: Tuesday, January 26, 2021 7:59 PM To: Stephen Berman Cc: ess-help@r-project.org; Richard M. Heiberger Subject: Re: [ESS] unexpected behavior for Emacs-27.1-1-modified-1 for two MacBooks. On 26 January 2021 at 22:07, Stephen

Re: [ESS] unexpected behavior for Emacs-27.1-1-modified-1 for two MacBooks.

2021-01-26 Thread Richard M. Heiberger via ESS-help
case he recommends hunspell. I will address the spelling problem soon, but not today. Rich From: Stephen Berman Sent: Tuesday, January 26, 2021 4:07 PM To: Richard M. Heiberger via ESS-help Cc: Richard M. Heiberger Subject: Re: unexpected behavior

[ESS] unexpected behavior for Emacs-27.1-1-modified-1 for two MacBooks.

2021-01-26 Thread Richard M. Heiberger via ESS-help
I just downloaded Emacs-27.1-1-modified-1 for two MacBooks. I have been using the previous 25.1.1 successfully on both machines. 1. My new MacBook Air M1, running Big Sur 2. My old MacBook Air mid 2012, running Catalina (it is too old for Big Sur) I have three unexpected behaviors, and they are

Re: [R] [External] Re: [External] Adding a superscript 6 to a number

2020-12-29 Thread Richard M. Heiberger
alization, or specific to this case? > > On December 29, 2020 7:54:22 AM PST, "Richard M. Heiberger" > wrote: > >paste() is the problem. don’t use paste with expression() > > > >On Tue, Dec 29, 2020 at 10:50 Sorkin, John > >wrote: > > > >>

Re: [R] [External] Adding a superscript 6 to a number

2020-12-29 Thread Richard M. Heiberger
paste() is the problem. don’t use paste with expression() On Tue, Dec 29, 2020 at 10:50 Sorkin, John wrote: > Colleagues, > > I would like to create a number (stored in the variable x) to the number > with the exponent of, i.e. the number to the sixth power. The code I have > tried, pasted

Re: [R] [External] RGB -> CYMK, with consistent colors

2020-11-29 Thread Richard M. Heiberger
I had a long discussion on this topic with the Springer production group when my book was in production. Statistical Analysis and Data Display: An Intermediate Course with Examples in R, second edition Richard M. Heiberger and Burt Holland. https://www.springer.com/gp/book/9781493921218 As I now

Re: [R] [External] long integer handling

2020-11-13 Thread Richard M. Heiberger
You need the Rmpfr package. Your calculation of 2^64 is an ordinary double precision number with 53 bits of precision. > library(Rmpfr) Loading required package: gmp Attaching package: ‘gmp’ The following objects are masked from ‘package:base’: %*%, apply, crossprod, matrix, tcrossprod C

Re: [R] [External] Re: how to order variables on correlation plot

2020-11-06 Thread Richard M. Heiberger
My guess is that the "%>% data.frame %>%" step turned something into a character that you thought would be a factor. See this example. Remember that the stringsAFactors argument to data.frame was recently changed. > tmp <- data.frame(A=c("A","F","B","G","C"), B=1:5, CC=6:10) > tmp A B CC 1 A

Re: [R] [External] Re: Package recommendations for outputting table with cell formatting

2020-10-23 Thread Richard M. Heiberger
To John and everyone else, Please add Hmisc::latex to your how-to-make-beautiful-tables-in-r document. We first included latex() in S in 1995, and it is still actively maintained and improved. Rich Here are the first few lines of ?latex Convert an S object to LaTeX, and Related Utilities

Re: [R] [External] openxlsx::read.xlsx can't read data without a header

2020-10-22 Thread Richard M. Heiberger
?openxlsx::read.xlsx The fourth argument by default is TRUE colNames: If ‘TRUE’, the first row of data will be used as column names. You will need to specify it explicitly as colNames=FALSE The other arguments will probably also be useful to you. On Thu, Oct 22, 2020 at 11:56 PM

Re: [R] [External] Function of "matrix"

2020-10-22 Thread Richard M. Heiberger
FAQ 7.31 > 10.1/.1 [1] 101 > print(10.1/.1, digits=17) [1] 100.99 > floor(10.1/.1) [1] 100 > floor(10.1*10) [1] 101 > matrix(0, 2.9, 3.9) [,1] [,2] [,3] [1,]000 [2,]000 > note that the dimension arguments are passed through floor() before they are used.

Re: [R] [External] Re: unable to access index for repository...

2020-10-08 Thread Richard M. Heiberger
I wonder if you are perhaps trying to solve the wrong problem. If you like what the older version of the aod package does, but not the current version, then I think the solution is to propose an option to the aod maintainer that would restore your preferred algorithm into the current version, and

Re: [R] [External] Re: how to replace values in a named vector

2020-09-14 Thread Richard M. Heiberger
I can't understand non-words with that many letters. I think this is what you are looking for: > tmp <- c(A="a",B="b",C="c",D="d") > names(tmp) [1] "A" "B" "C" "D" > tmp A B C D "a" "b" "c" "d" > ## change values of B and C to "x" and "y" > names(tmp) %in% c("B","C") [1] FALSE TRUE

Re: [R] [External] R rounding problem?

2020-09-03 Thread Richard M. Heiberger
FAQ 7.31 On Fri, Sep 4, 2020 at 12:47 AM array chip via R-help wrote: > > Hello, > > I made a mistake today on simple counting in R, that almost got me into > trouble. After trying multiple times, I finally figured out it's rounding > issue in R. > > For exmaple, when I just simply type: > > >

Re: [R] [External] rNOMADS package

2020-08-24 Thread Richard M. Heiberger
incorrect double slash c:// use single slash c:/ On Mon, Aug 24, 2020 at 11:21 Philip wrote: > I am struggling to install a fix for the rNOMADS package which reads > National Weather Service data. I copied the fix (rNOMADS_2.5.0.tar.gz) > from an email to a local drive and then tried to

Re: [R] [External] finding nearest zip codes

2020-08-04 Thread Richard M. Heiberger
verify that you actually have five-digit zip codes stored as characters. New Jersey and Massachusetts have zero as the first digit. When these codes are saved as numbers, they become four-digit codes and will probably cause errors. For example Cambridge, Mass is '02138', and would be reported as

Re: [R] [External] Re: Playing a music file in R

2020-07-23 Thread Richard M. Heiberger
The R command system.file() tells you where the currently running version of R is located on your machine and your operating system. On the Macintosh it shows > system.file() [1] "/Library/Frameworks/R.framework/Resources/library/base" You don't need to worry about the R version number, as R

Re: [R] [External] Character (1a, 1b) to numeric

2020-07-10 Thread Richard M. Heiberger
> xc <- c("1", "1a", "1b", "1c", "2", "2a", "2b", "2c") > xn <- c(1, 1.3, 1.5, 1.7, 2, 2.3, 2.5, 2.7) > testdata <- rep(c("1", "1a", "1b", "1c", "2", "2a", "2b", "2c"), times=1:8) > testdata [1] "1" "1a" "1a" "1b" "1b" "1b" "1c" "1c" "1c" "1c" "2" "2" "2" "2" "2" [16] "2a" "2a" "2a" "2a"

Re: [R] [External] challenging data merging/joining problem

2020-07-05 Thread Richard M. Heiberger
Have you talked directly to the designers of the new database? One would hope that they had a clear migration path in mind. Perhaps they just didn't document it to your satisfaction. Rich On Sun, Jul 5, 2020 at 2:51 PM Christopher W. Ryan wrote: > > I've been conducting relatively simple

Re: [R] [External] Re: R Software Risk Analysis

2020-06-18 Thread Richard M. Heiberger
You should start by reading R: Regulatory Compliance and Validation Issues: A guidance document for the use of R in regulated clinical trial environments. https://www.r-project.org/doc/R-FDA.pdf The official link to that file is at the R home page https://www.r-project.org/ In the left column,

Re: [ESS] [External] Re: R transcript file name suffix

2020-06-01 Thread Richard M. Heiberger via ESS-help
absolutely restore .rt as a valid transcript file name. .st goes back to at least S-Plus and if my memory serves, to S. .rt was constructed by analogy. the .rout and .sout are excessively verbose, rather recent additions. Additions, not replacements. Rich On Mon, Jun 1, 2020 at 4:47 PM Alex

Re: [R] [External] struggling with apply

2020-05-27 Thread Richard M. Heiberger
sapply(1:4, FUN=function(i, x, UB=c(2.5, 5.5, 8.5, 10.5)) {result <- x[,i]; result[result > UB[i]] <- UB[i]; result}, x=somematrix) On Wed, May 27, 2020 at 1:46 PM Michael Ashton wrote: > > Hi - > > I have a matrix of n rows and 4 columns. > > I want to cap the value in each column by a

Re: [R] [External] Help with sub-setting

2020-05-25 Thread Richard M. Heiberger
I think the syntax you are looking for is datasubset <- data[ data$A ==1 & data$B == 1 , ] ) This gives the subset of your original data for variable A with value 1 and variable B with value 1. On Mon, May 25, 2020 at 12:57 PM Burgess, Jamie wrote: > > Dear all, > > I hope this message finds

Re: [R] [External] Re: access for free more than 500 essential Springer Nature textbooks

2020-05-22 Thread Richard M. Heiberger
> > On Sat, May 23, 2020 at 4:29 AM Richard M. Heiberger wrote: > > > > Springer has just made available free access to many books through July. > > This is part of their global program to support educators, students > > and academics > > affected by corona

[R] access for free more than 500 essential Springer Nature textbooks

2020-05-22 Thread Richard M. Heiberger
=hybris-campaign_medium=email_campaign=000_BARZ01_001531_AEXS_AWA_CB02_GL_txt_covid_content=EN_internal_5917_20200522=42010A0550671EDA9BA73AC34F576EF6 My book is Statistical Analysis and Data Display, Richard M. Heiberger, Burt Holland, 2nd ed. 2015 It is supported by the HH package available from

Re: [R] [External] Re: [External] Get a result but an error message as well ?

2020-05-19 Thread Richard M. Heiberger
anks for your response. > > However, how can I correct my R code knowing that I want, as a result, > only one value : the mean of the 500 MSE_OLS values ? > > Just don't transpose the output of replicate? > > Hope this helps, > > Rui Barradas > > > > > > >

Re: [R] [External] Get a result but an error message as well ?

2020-05-19 Thread Richard M. Heiberger
> dim(my.data) [1] 1 500 you have a matrix with a single row and 500 columns. you gave a name to only the first column. Look at the result of replicate(). it is a vector. You transposed it into a one-row matrix. > tmp <- replicate( 500, my.experiment() ) > dim(tmp) NULL > length(tmp) [1]

Re: [ESS] [External] Re: Function to copy command to script?

2020-05-19 Thread Richard M. Heiberger via ESS-help
s type of editing all the time, so I > figured there must already be a function. But maybe not. > > Kevin > > On Tue, May 19, 2020 at 11:27 AM Richard M. Heiberger > wrote: > >> Hi Kevin, >> >> I think Stephen is assuming you do a lot of work in the *R* and

Re: [ESS] [External] Re: Function to copy command to script?

2020-05-19 Thread Richard M. Heiberger via ESS-help
Hi Kevin, I think Stephen is assuming you do a lot of work in the *R* and then want to recover it into a script. For that case I wouldn't bother saving the *R* buffer, but would just copy the relevant lines (including output) and then save it back into the script file with C-u C-u C-y

Re: [R] [External] sort

2020-05-14 Thread Richard M. Heiberger
## the data you gave us DF1 <- read.table(text="name ddate A 2019-10-28 A 2018-01-25 A 2020-01-12 A 2017-10-20 B 2020-11-20 B 2019-10-20 B 2017-05-20 B 2020-01-20 c 2009-10-01 ", header=TRUE, colClasses=c("character", "POSIXct")) DF1 D2 <- split(DF1, DF1$name) D2

Re: [R] Loop inside dplyr::mutate

2020-05-09 Thread Richard M. Heiberger
## I start with sim_data_wide sim_data_wide <- tidyr::spread(sim_data, quarter, pd) ## and calculate wide wide1 <- with(sim_data_wide, cbind(PC_1 = P_1, PC_2 = 1-(1-P_1)*(1-P_2), PC_3 = 1-(1-P_1)*(1-P_2)*(1-P_3), PC_4 =

Re: [R] Error: Cannot use `+.gg()` with a single argument.

2020-05-07 Thread Richard M. Heiberger
It is just like the message suggested. You have a + at the end of each line and the beginning of the next. The one at the end is required. The ones at the beginning are causing the error message. Please put spaces around your assignment arrows. Difficult to read: r<-murders Easy to read:r

Re: [R] [FORGED] Re: paste workable code to R 4.0.0 cause error

2020-04-28 Thread Richard M. Heiberger
I pasted it into Emacs ESS on Macintosh, Emacs ESS on Windows, and Rgui on Windows. All 4.0.0 . It runs fine. On Tue, Apr 28, 2020 at 11:36 PM Rolf Turner wrote: > > The (excellent) MWE that you provided runs just fine for me (in R 4.0.0 > under Ubuntu 18.04) either by sourcing "aaa.R" or by

Re: [R] Rtools required

2020-04-28 Thread Richard M. Heiberger
did you change your path to the new location? On Tue, Apr 28, 2020 at 07:25 Steven wrote: > Dear All > > I updated to R-4.0.0. and also installed the latest Rtools 4.0 (to now > the new default folder c:\rtools40). While compiling a package (binary) > I received the follow marning message

Re: [R] [External Email] Re: arranging multiple lattice graphs on a page

2020-04-02 Thread Richard M. Heiberger
don't forget library(latticeExtra) latticeExtra provides many very useful user-level functions. On Thu, Apr 2, 2020 at 7:52 PM Christopher W. Ryan wrote: > > Thanks, I'll take a look. I also finally came across gridExtra, which allows > me to do it as well. > > --Chris Ryan > > On April 2,

Re: [R] Not seeing the results of a function

2020-03-30 Thread Richard M. Heiberger
You need one more line In your function. addday <- function(stp,mcp,stpos,mcpos){ stpos<-c(stpos,stp) mcpos<-c(mcpos,mcp) days<-c(1:length(stpos)) list(mcpos=mcpos, days=days) } This and the other question I just answered together say that you need to re-read an introduction to R. On Mon,

Re: [R] Program to produce multiple plots

2020-03-30 Thread Richard M. Heiberger
you probably forgot the print() statement. Both lattice and ggplot require a print() in this situation. See the help files. On Mon, Mar 30, 2020 at 10:04 Ashim Kapoor wrote: > Dear David, > > Try this :- > par(mfrow=c(1,2)) > hist(rnorm(100)) > hist(rnorm(100,100,1)) > > Best Regards, > Ashim

Re: [R] How to evaluate impact of factors on parameters

2020-03-18 Thread Richard M. Heiberger
Unfortunately, sending HTML mail scrambled the correct use of dput. Please use "plain text mode" for all R mailing lists. I unscrambled it here df_test <- structure(list(pc.col = structure(c(2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L), .Label =

Re: [R] About the multiprecision computing package in R

2020-03-14 Thread Richard M. Heiberger
Rmpfr product and inner product are not doubling the nominal precision. Small precision inner products are stored as 53-bit numeric. library(Rmpfr) ## double with precBits=53 (5/17) * (5/17) ## 0.08650519 ## base 10 formatHex( (5/17) * (5/17) ) ## +0x1.6253443526171p-4 ## various precisions

Re: [R] Increasing space for main title in a lattice (xyplot()) graphics.

2020-02-12 Thread Richard M. Heiberger
It works as anticipated for me > xyplot(1 ~ 1, + main="The quick brown fox jumped\n over the lazy dog.") > xyplot(1 ~ 1, + main="The quick brown fox jumped over the lazy dog.") Something else you are doing is probably causing the difficulty. Rich On Wed, Feb 12, 2020 at

Re: [R] Converting binary number to in Two´s complement representation

2020-01-25 Thread Richard M. Heiberger
able to obtain the latitude and longitude values with that script? > > Thank you so much brother, > > Paul > > El sáb., 25 de enero de 2020 4:03 p. m., Richard M. Heiberger > escribió: >> >> ## from2Comp uses base R functions only >> from2Comp <- function(

Re: [R] Converting binary number to in Two´s complement representation

2020-01-25 Thread Richard M. Heiberger
t; "11101101110", "11101101111", >> "1110111", "11101110001", >> "11101110010", "11101110011", >> &qu

Re: [R] Converting binary number to in Two´s complement representation

2020-01-24 Thread Richard M. Heiberger
"1111111111110000100", "101", > "110", "111", > "0001000", "0001001", > "

Re: [R] Converting binary number to in Two´s complement representation

2020-01-24 Thread Richard M. Heiberger
tely no related to the > dataset I provided. If I try the function on the dataset, I get values well > over the latitude and longitude boundaries (which should range from -90 to + > 90, and -180 to +180). > > Regards, > > Paul > > El vie., 24 ene. 2020 a las 12:23, Richard M

Re: [R] Converting binary number to in Two´s complement representation

2020-01-24 Thread Richard M. Heiberger
You show the example > fun("10110010") [1] -78 as satisfactory. Where in your posted data set do you find the input string "10110010"? Please post a set of relevant input strings, and the answers you want from them. The rest of the columns are not helpful for this specific exercise. On Fri,

Re: [R] Converting Decimal numbers into Binary

2019-12-27 Thread Richard M. Heiberger
Use the Rmpfr package. it will print numbers in any base from 2 to 62 > library(Rmpfr) > ?Rmpfr > b15 <- mpfr(15, precBits=6) > formatBin(b15) [1] +0b1.11100p+3 > On Fri, Dec 27, 2019 at 10:43 AM Paul Bernal wrote: > > Dear friends, > > Hope you are all doing well. I need to find a way to

Re: [R] R CMD Batch on Windows and use of the ampersand

2019-12-25 Thread Richard M. Heiberger
Hi Erin. I think the easiest way is to use sh, which is included as part of Rtools. >From the CMD command line, enter c:/Rtools/bin/sh -i You are now running a Unix shell, and all the behaviors you expect are there, including ";" and "&" Rich On Wed, Dec 25, 2019 at 12:16 PM Erin Hodgess

  1   2   3   4   5   6   7   8   9   >