Re: [R] dataRetrieval query error

2020-09-05 Thread Bill Dunlap
Name all your arguments (the vignette gets this wrong), including siteNumber=siteNumbers. Also, the vignette uses 'statCd', not 'statCD'. dataAvailable <- whatNWISdata(siteNumber=siteNumbers, service="all", statCd="all") gives some results. -Bill On Sat, Sep 5, 2020 at 4:44 PM Rich Shepard

Re: [R] dataRetrieval: whatNWISdata() return value type

2020-09-06 Thread Bill Dunlap
https://help.waterdata.usgs.gov/codes-and-parameters/codes - *Time series identifier* - A 5-6 digit number (ts_id) which uniquely identifies a series of data for one parameter at one location at a continuous-recording data site. The ts_id is used by the database for selecting data

Re: [R] Lahman Baseball Data Using R DBI Package

2020-10-08 Thread Bill Dunlap
>% rename(X2B = `2B`, X3B = `3B`) > > library(dplyr) > dbGetQuery(con2,"SELECT * FROM batting WHERE yearID = 2018 AND AB >600 > ORDER BY AB DESC") %>% `colnames<-`(make.names(colnames(.))) > > library(dplyr) > dbGetQuery(con2,"SELECT * FROM batting WHE

Re: [R] package(moments) issue

2020-10-15 Thread Bill Dunlap
moments::anscombe.test(x) does give errors when x has too few values or if all the values in x are the same > moments::anscombe.test(c(1,2,6)) Error in if (pval > 1) pval <- 2 - pval : missing value where TRUE/FALSE needed > moments::anscombe.test(c(2,2,2,2,2,2,2,2)) Error in if (pval > 1) pval

Re: [R] package(moments) issue

2020-10-15 Thread Bill Dunlap
nation behind the > error, I will highly appreciate it. > > Best wishes, > Sania > > On Thu, 15 Oct 2020 at 20:43, Bill Dunlap > wrote: > >> moments::anscombe.test(x) does give errors when x has too few values or >> if all the values in x are the same >> >>

Re: [R] Split

2020-09-22 Thread Bill Dunlap
Another way to make columns out of the stuff before and after the underscore, with NAs if there is no underscore, is utils::strcapture("([^_]*)_(.*)", F1$text, proto=data.frame(Before_=character(), After_=character())) -Bill On Tue, Sep 22, 2020 at 4:25 PM Bert Gunter wrote: > To be clear, I

Re: [R] summarize_all Function

2020-10-01 Thread Bill Dunlap
The warning gives some suggestions. E.g., replace funs(sum,prod) with list(sum=sum,prod=prod). % R CMD Rscript -e 'library(dplyr,warn.conflicts=FALSE); data.frame(X=1:3,Y=c(11,13,17)) %>% summarize_all(funs(sum,prod))' X_sum Y_sum X_prod Y_prod 1 641 6 2431 Warning message:

Re: [R] Lahman Baseball Data Using R DBI Package

2020-10-02 Thread Bill Dunlap
Philip wrote: > The \”2B\” worked. Have no idea why. Can you point me somewhere that can > explain this to me. > > Thanks, > Philip > > *From:* Bill Dunlap > *Sent:* Friday, October 2, 2020 3:54 PM > *To:* Philip > *Cc:* r-help > *Subject:* Re: [R] Lahman Baseball

Re: [R] Lahman Baseball Data Using R DBI Package

2020-10-02 Thread Bill Dunlap
Have you tried putting double quotes around 2B and 3B: "...2B, 3B, ..." -> "...\"2B\",\"3B\",..."? -Bill On Fri, Oct 2, 2020 at 3:49 PM Philip wrote: > I’m trying to pull data from one table (batting) in the Lahman Baseball > database. Notice X2B for doubles and X3B for triples – fourth and

Re: [R] Seasonal adjustment with seas - Error: X-13 has returned a non-zero exist status

2020-09-17 Thread Bill Dunlap
The problem might to due to using an UNC path (//machine//blah/...) instead of the traditional DOS path ("H:/blah/..."). E.g., if my working directory has a UNC path, cmd.exe will not work as expected: > getwd() [1] "server/dept/devel/bill-sandbox" > system("C:\\WINDOWS\\SYSTEM32\\cmd.exe /c

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

2020-12-29 Thread Bill Dunlap
And if you have multiple labels, use lapply with bquote: plot(1:5, sin(101:105)^2, type="n") text(2:4, sin(102:104)^2, labels=lapply(102:104, function(i)bquote(sin(.(i))^2))) -Bill On Tue, Dec 29, 2020 at 8:31 AM Bert Gunter wrote: > Does this do what you want? > > plot(0:1, 0:1) > x <- .25 >

Re: [R] change frequency of wind data correctly

2020-12-07 Thread Bill Dunlap
Instead of using breaks="30 mins" construct the breaks explicitly with seq() so you can control the start point. E.g., > init_day <- as.POSIXct("2018-02-01-00-00", format="%Y-%m-%d-%H-%M", tz="Etc/GMT-1") > fin_day <- as.POSIXct("2018-02-01-02-00", format="%Y-%m-%d-%H-%M", tz="Etc/GMT-1") > mydf

Re: [R] Windows path backward slash

2020-12-24 Thread Bill Dunlap
The "\n" is probably not in the file name. Does omitting it from the call to str_c help? -Bill On Thu, Dec 24, 2020 at 6:20 AM Anbu A wrote: > Hi All, > I am a newbie. This is my first program. > I am trying to read SAS dataset from below path. I added escape "\" along > "\" found in path

Re: [R] How to perform package cleanup when R session is ending?

2020-12-18 Thread Bill Dunlap
inalizer, lib="lib") Loading testFinalizer from /home/bill/packages/lib Installed finalizer for > objects(all=TRUE) character(0) > q("no") cleanup() cleaning On Fri, Dec 18, 2020 at 7:39 AM Bill Dunlap wrote: > Have you tried using reg.finalizer(..., onexit=TRU

Re: [R] How to specify year-month-day for a plot

2020-12-18 Thread Bill Dunlap
Have you tried abline(v=as.Date("2019-04-06"), col="red") -Bill On Fri, Dec 18, 2020 at 9:29 AM Gregory Coats wrote: > I need to be able to draw and label a vertical line, representing the date > of some arbitrary event. The date of the first entry is 2013-11-29. How > would I draw, and

Re: [R] How to specify year-month-day for a plot

2020-12-16 Thread Bill Dunlap
You didn't show the entire call to read.table. If it included the argument header=TRUE then it would make the first entry in each column the name of the column. Use header=FALSE (or omit the header argument) if you don't want the first entry to be considered the column name. -Bill On Wed, Dec

Re: [R] How to specify year-month-day for a plot

2020-12-13 Thread Bill Dunlap
You left out some calls to c(). Note that (2,3,5) is not valid syntax for making a vector of numbers; use c(2,3,5) You also left out a comma and gave different lengths for day and value. You also left out plus signs between the various components of your ggplot expression. Try data <-

Re: [R] How to perform package cleanup when R session is ending?

2020-12-18 Thread Bill Dunlap
Have you tried using reg.finalizer(..., onexit=TRUE)? -BIll On Fri, Dec 18, 2020 at 7:29 AM Jiefei Wang wrote: > Hi, > > I am looking for a way to clean up my package resources before R is ended. > It looks like the .onUnload function would not be helpful as it would not > be called before R

Re: [R] "NaN" answer don't understand why

2020-11-13 Thread Bill Dunlap
fit <- robustgam::robustgam(...) produces a list, with no class attached, so residuals(fit) invokes the default method for residuals(), which essentially returns the 'residuals' component of 'fit'. There is no such component so it returns NULL, an object of length zero. The mean of a length-zero

Re: [R] counting duplicate items that occur in multiple groups

2020-11-17 Thread Bill Dunlap
What should the result be for Data1 <- data.frame(Vendor=c("V1","V2","V3","V4"), Account=c("A1","A2","A2","A2")) ? Must each vendor have only one account? If not, what should the result be for Data2 <- data.frame(Vendor=c("V1","V2","V3","V1","V4","V2"),

Re: [R] Function of "matrix"

2020-10-22 Thread Bill Dunlap
> 10.1/0.1 was successfully calculated Note that 'computed as' is not the same as 'printed as'. Computations are done with 52 binary digits of precision and printing is, by default, done with 7 decimal digits of precision. See FAQ 7.31. > 101 - 10.1/0.1 [1] 1.421085e-14 >

Re: [R] Converting "day of year" to "year", "month" and "day"

2021-01-15 Thread Bill Dunlap
Use one of the POSIXt classes, POSIXct or POSIXlt, instead of the Date class. They have more methods for doing arithmetic. E.g., > dates <- as.POSIXct(tz="UTC", c("2004-03-01", "2005-03-01")) > difftime(dates, trunc(dates, units="year"), units="days") # add 1 if you want -01-01 to be day 1

Re: [R] writing a function to work with dplyr::mutate()

2021-01-19 Thread Bill Dunlap
Your translate... function seems unnecessarily complicated and reusing the name 'var' for both the input and the data.frame containing the input makes it confusing to me. The following replacement, f, uses your algorithm but I think gets the answer you want. f <- function(var, upper, lookup) {

Re: [R] Error when calling (R 4.0.x on Windows) from Python

2021-01-27 Thread Bill Dunlap
Note that in R-3.6.3 commandArgs() does not include the arguments intended to be processed by the shell, "1>", "arguments.txt", etc., but in R-4.0.3 it does include them. It is as though an R shell() command was replaced by a system() command so cmd.exe didn't get a chance to process the command

Re: [R] Error when calling (R 4.0.x on Windows) from Python

2021-01-27 Thread Bill Dunlap
t; print(cmd403) C:/R/R-4.0.3/bin/R.exe --vanilla --quiet -e "commandArgs()" --args "arguments.txt" 1> "log403.txt" 2>&1 >>> status403 = subprocess.call(cmd403) > commandArgs() [1] "C:\\R\\R-4.0.3/bin/x64/Rterm.exe" "--vanilla" [3

Re: [R] Error when calling (R 4.0.x on Windows) from Python

2021-01-27 Thread Bill Dunlap
"[3] \"--vanilla\" " [5] "[4] \"-e\" " "[5] \"commandArgs()\" " [7] "[6] \"SPACE/log.txt\" " "> " [9] "> " > > unlink(logname) > system(p

Re: [R] Error when calling (R 4.0.x on Windows) from Python

2021-01-27 Thread Bill Dunlap
I believe the problem is from svn 77925 in gnuwin/front-ends/rcmdfn.c, which was committed a few days after 3.6.3 was released. Rterm used to put double quotes around a command line argument only if it contained a space, now it double quotes all arguments. It sees shell constructs like "1>" and

Re: [R] Error when calling (R 4.0.x on Windows) from Python

2021-02-02 Thread Bill Dunlap
as > > > > cmd.exe 1>log.txt 2>&1 /C R.exe -f code.R --args "~/file.txt" > > > > (but I haven't tested it). You could also use the slightly more > > efficient > > > > cmd.exe 1>log.txt 2>&1 /C Rterm.exe -f code.R --args "~/

Re: [R] Beginner problem - using mod function to print odd numbers

2021-06-09 Thread Bill Dunlap
Martin wrote Use num[num %% 2 == 1] instead of much slower and ...@#^$ num[ifelse(num %% 2 == 1, TRUE, FALSE)] Read the '[' as 'such that' when the subscript is logical (=="Boolean"==TRUE/FALSE-values). [The original post had a typo/thinko, num<-num+i instead of num<-num+1, which

Re: [R] How to spot/stop making the same mistake

2021-06-23 Thread Bill Dunlap
> a variable that equals 1 for the elements I want to select: > > t = c(1,1,1,0,0) How do you typically make such a variable? If you use something like t <- ifelse(x == "Yes", 1, 0) you should instead use t <- x == "Yes" Naming the variable something like 'isYes' instead of 't' might

Re: [R] How to spot/stop making the same mistake

2021-06-23 Thread Bill Dunlap
Note that !! and !!! are special operators involving "quasiquotation" in the dplyr package. I would use as.logical(x) instead of !!x since its meaning is clear to any user. -Bill On Wed, Jun 23, 2021 at 11:13 AM Jeff Newmiller wrote: > For the record, `!!` is not an operator so it does not

Re: [R] Special characters in cell names

2021-06-23 Thread Bill Dunlap
Use backquotes, `X/Y`, to specify a name, not double quotes. -Bill On Wed, Jun 23, 2021 at 11:58 AM Mahmood Naderan wrote: > Hi > I have a column in my data file which is "X/Y". With '/' I want to > emphasize that values are the ratio of X over Y. > Problem is that in the following command for

Re: [R] Read fst files

2021-06-09 Thread Bill Dunlap
Try using unzip(zipfile, files="desiredFile", exdir=tf<-tempfile()), not unz(zipfile, "desiredFile"), to copy the desired file from the zip file to a temporary location and use read_fst(tf) to read the desired file. -Bill On Wed, Jun 9, 2021 at 11:27 AM Jeff Reichman wrote: > Jan > > Makes

Re: [R] No error message but don't get the 8 graphs

2021-05-10 Thread Bill Dunlap
Also, normalizePath("power.pdf"). On Sun, May 9, 2021 at 5:13 PM Bert Gunter wrote: > ?getwd > > Bert Gunter > > "The trouble with having an open mind is that people keep coming along and > sticking things into it." > -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip ) > > > On

Re: [R] About Pearson correlation functions

2021-05-30 Thread Bill Dunlap
You didn't say how the values differed. If one in the plot is a rounded version of the other then adding the ggpur::ggscatter() argument cor.coeff.args=list(digits=7) will fix things up. -Bill On Sun, May 30, 2021 at 9:18 AM Mahmood Naderan-Tahan < mahmood.nade...@ugent.be> wrote: > Hi > >

Re: [R] How to create a matrix from a list without a for loop

2021-07-09 Thread Bill Dunlap
Try matrix(init_l, nrow=4, ncol=4, dimnames=list(c("X1","X2","X3","X4"),c("X1","X2","X3","X4"))) It doesn't give exactly what your code does, but your code introduces an extra level of "list", which you may not want. -Bill On Fri, Jul 9, 2021 at 10:40 AM Laurent Rhelp wrote: > Dear

Re: [R] List / Matrix to Data Frame

2021-07-01 Thread Bill Dunlap
Does this do what you want? > df <- data.frame(check.names=FALSE, lapply(c(Date="date",netIncome="netIncome",`Gross Profit`="grossProfit"), function(nm)vapply(ISY, "[[", nm, FUN.VALUE=NA_character_))) > str(df) 'data.frame': 36 obs. of 3 variables: $ Date: chr "2020-09-30"

Re: [R] .Rprofile with devtools::install_github() loops

2021-02-10 Thread Bill Dunlap
Installing a package involves running several R subprocesses, each of which is running that .Rprofile. You may be able to stop the infinite recursion by setting an environment variable that subprocesses can check. E.g. replace install_github("xxx/yyy") with if

Re: [R] local maxima positions in a vector with duplicated values

2021-03-26 Thread Bill Dunlap
Using rle() may make it easier - finding the peak values is easier and select from cumsum(lengths) to get the positions of the last values before the peaks, then add 1. I have not tested the following very much. function(x) { rx <- rle(x) cumsum(rx$lengths)[c(diff(diff(rx$values)>0) ==

Re: [R] Colorizing different individuals with fviz

2021-03-29 Thread Bill Dunlap
That error means that fviz_famd_ind has more than one argument that starts with 'col' and you must type a more complete name to disambiguate it. Perhaps col.ind=ifelse(...)? > args(factoextra::fviz_famd_ind) function (X, axes = c(1, 2), geom = c("point", "text"), repel = FALSE, habillage =

Re: [R] "for" loop does not work with my plot_ly command

2021-03-30 Thread Bill Dunlap
Printing the return value of plot_ly and friends works for me in the following examples: # make base plot p0 <- plotly::plot_ly(na.omit(palmerpenguins::penguins), x = ~bill_length_mm, y = ~body_mass_g) # now add things to base plot for(vrbl in list(~species, ~island, ~year)) { tmp <-

Re: [R] Violin plot with mean_sdl

2021-04-01 Thread Bill Dunlap
help(stat_summary) suggests you use the fun.args=list(...) argument to pass arguments to the fun.* functions. Try replacing mult=1 by fun.args=list(mult=1). It is possible that ggplot2::stat_summary changed its behavior since that web page was written or that the web page was always wrong.

Re: [R] local maxima positions in a vector with duplicated values

2021-03-29 Thread Bill Dunlap
Section > Via del Colle Ameno 5 > 60126 Torrette di Ancona, Ancona (AN) > Uff: +39 071 806 7743 > E-mail: stefano.so...@regione.marche.it > ---Oo-oO---- > > > Da: Bill Dunlap [williamwdun...@gmai

Re: [R] seed problem?

2021-03-29 Thread Bill Dunlap
Does this happen if you start R with the --vanilla flag? If so it may be that you have a startup file, .\.Rprofile or %HOME%\.Rprofile that is calling set.seed(n) for a fixed n. -Bill On Mon, Mar 29, 2021 at 12:16 AM Mika Hamari wrote: > > Hi! > > I have Windows 10 on PC and different versions

Re: [R] local maxima positions in a vector with duplicated values

2021-03-29 Thread Bill Dunlap
ette di Ancona, Ancona (AN) > Uff: +39 071 806 7743 > E-mail: stefano.so...@regione.marche.it > ---Oo-oO > > > Da: Bill Dunlap [williamwdun...@gmail.com] > Inviato: venerdì 26 marzo 2021 18.40 > A: Stefano Sofia > Cc: r-help mailing list > Ogg

Re: [R] Failure in predicting parameters

2021-03-14 Thread Bill Dunlap
> rutledge_param <- function(p, x, y) ((p$M / (1 + exp(-1*(p$x-p$m)/p$s))) + > p$B) - y Did you mean that p$x to be just x? As is, this returns numeric(0) for the p that nls.lm gives it because p$x is NULL and NULL-aNumber is numeric(). -Bill On Sun, Mar 14, 2021 at 9:46 AM Luigi Marongiu

Re: [R] library(hms)

2021-03-17 Thread Bill Dunlap
install.packages("hms") A 'library' is a directory (aka folder) that contains installed 'packages'. I.e., one installs packages into a library, but one does not install a library. -Bill On Wed, Mar 17, 2021 at 10:08 AM Gregory Coats via R-help wrote: > > On my MacBook, I do not have, and do

Re: [R] Optimization function producing negative parameter values

2021-03-21 Thread Bill Dunlap
Does optim go out of bounds when you specify hessian=FALSE? hessian=TRUE causes some out-of-bounds evaluations of f. > optim(c(X=1,Y=1), > function(XY){print(unname(XY));(XY[["X"]]+1)^4+(XY[["Y"]]-2)^4}, method= > "L-BFGS-B", lower=c(0.001,0.001), upper=c(1.5,1.5), hessian=TRUE) [1] 1 1 [1]

Re: [R] help

2021-03-16 Thread Bill Dunlap
The length of the mean vector must match the number of rows and columns of the sigma matrix. Once you give 3 entries in the mean vector you will run into the problem that the sigma you are using is not positive (semi-)definite - a variance must be the product of a matrix and its transpose. -Bill

Re: [R] Warning messages while parallel computing

2021-03-04 Thread Bill Dunlap
1 at 11:28 AM Henrik Bengtsson wrote: > > Test with: > > clusterCall(cl, function() { suppressWarnings(source("xx.R")) }) > > If the warnings disappear, then the warnings are produced on the > workers from source():ing the file. > > /Henrik > > On Thu, Mar 4,

Re: [R] Warning messages while parallel computing

2021-03-04 Thread Bill Dunlap
To avoid the warnings from gc(), call parallel::stopCluster(cl) before removing or overwriting cl. -Bill On Thu, Mar 4, 2021 at 1:52 AM Shah Alam wrote: > > Hello everyone, > > I am using the "parallel" R package for parallel computation. > > Code: > ># set number of cores > cl <-

Re: [R] Warning messages while parallel computing

2021-03-04 Thread Bill Dunlap
k there's something in the 'xx.R' script that opens > a connection but doesn't close it. Possibly multiple times. A good > check is to see if the same warnings are produced when calling > source("xx.R") sequentially in a for() loop or an lapply() call. > > Hope this helps, >

Re: [R] evil attributes

2021-04-11 Thread Bill Dunlap
Terry wrote I confess to being puzzled WHY the R core has decided on this definition [of vector] ... I believe that "R core" followed S's definition of "vector". From the beginning (at least when I first saw it in 1981) an S vector was the basic unit of an S object - it had a type and

Re: [R] Bug? Index output of C functions R_qsort_I and R_qsort_int_I is not modified

2021-04-15 Thread Bill Dunlap
R_ext/Utils.h:void R_qsort_int_I(int *iv, int *II, int i, int j); The last 2 arguments are int, not int*. .C() passes pointers to vectors so you cannot call this function directly from .C(). -Bill On Thu, Apr 15, 2021 at 3:15 PM Evangelos Evangelou via R-help < r-help@r-project.org> wrote: >

Re: [R] How to load fasta file with openPrimeR?

2021-02-15 Thread Bill Dunlap
> but if I give these commands to a local file: > ``` > fasta.file <- system.file("extdata", "IMGT_data", "templates", > "stx.fa", package = "openPrimeR") > fasta.file <- system.file("stx.fa", package = "openPrimeR") > ``` > where stx.fa il the file I wanted to open and that is

Re: [R] Working with FactoMineR

2021-02-04 Thread Bill Dunlap
This will happen if you select no points when it asks you to 'click on the graph' (to select the level at which to cut the tree). On Windows you can select no points by right clicking and selecting 'Stop' from the menu that pops up. RStudio may have a different way to select no points. -Bill

Re: [R] Read

2021-02-22 Thread Bill Dunlap
Since the columns in the file are separated by a space character, " ", add the read.table argument sep=" ". -Bill On Mon, Feb 22, 2021 at 2:21 PM Val wrote: > > Hi all, I am trying to read a messy data but facing difficulty. The > data has several columns separated by blank space(s). Each

Re: [R] Read

2021-02-22 Thread Bill Dunlap
1 D53\n60 D62 ", > : > more columns than column names > > On Mon, Feb 22, 2021 at 5:39 PM Bill Dunlap wrote: > > > > Since the columns in the file are separated by a space character, " ", > > add the read.table argument sep="

Re: [R] R versions > 4.0.2 fail to start in Windows 64-bit

2021-04-21 Thread Bill Dunlap
Does this happen when you start R with the --vanilla flag? When you remove or rename ./.RData? -Bill On Tue, Apr 20, 2021 at 8:37 PM N. Jordan Jameson wrote: > I have a 64-bit Windows machine and I've installed R versions 4.0.0 through > 4.0.5 and only versions 4.0.2 and below will

Re: [R] ggplot error of "`data` must be a data frame, or other object coercible by `fortify()`, not an S3 object with class rxlsx"

2021-08-26 Thread Bill Dunlap
The packages "officer" and "readxl" both contain functions named "read_xlsx". It looks like you want the one from readxl so refer to it as readxl::read_xlsx instead of just read_xlsx. -Bill On Thu, Aug 26, 2021 at 12:03 PM Kai Yang via R-help wrote: > Hi all, > I found something, but I don't

Re: [R] What if there's nothing to dispatch on?

2021-09-01 Thread Bill Dunlap
Is this the kind of thing you are looking for? It separates the scoping issue from the method dispatch by defining another S3-generic function, ".foo". > foo <- function(x, ..., data=NULL) with(data, .foo(x, ...)) > .foo <- function(x, ...) UseMethod(".foo") > .foo.default <- function(x, ...)

Re: [R] ISO Code for Namibia ('NA')

2021-09-01 Thread Bill Dunlap
> z <- tibble(Code=c("NA","NZ",NA), Name=c("Namibia","New Zealand","?")) > z # A tibble: 3 x 2 Code Name 1 NANamibia 2 NZNew Zealand 3 ? > subset(z, Code=="NA") # A tibble: 1 x 2 Code Name 1 NANamibia > subset(z, is.na(Code)) # A tibble: 1 x 2 Code Name 1 ? >

Re: [R] 'Double to logical' error

2021-09-07 Thread Bill Dunlap
`single_study_df` must be compatible with existing data. > ℹ Error occurred for column `third_ventricle_mn`. > x Can't convert from to due to loss of precision. > * Locations: 1, 2. > Backtrace: > Run `rlang::last_trace()` to see the full context. > > > > > ---

Re: [R] Calculate daily means from 5-minute interval data

2021-09-05 Thread Bill Dunlap
What is the best way to read (from a text file) timestamps from the fall time change, where there are two 1:15am's? E.g., here is an extract from a US Geological Survey web site giving data on the river through our county on 2020-11-01, when we changed from PDT to PST,

Re: [R] 'Double to logical' error

2021-09-06 Thread Bill Dunlap
> Run `rlang::last_error()` to see where the error occurred What did rlang::last_error() show? -Bill On Mon, Sep 6, 2021 at 9:19 AM John Tully wrote: > Dear colleagues > > > > in conducting a meta-analysis (of MRI data) I am running into the > repeated issue: > > > > Error: Assigned data

Re: [R] What are the pros and cons of the log.p parameter in (p|q)norm and similar?

2021-08-03 Thread Bill Dunlap
In maximum likelihood problems, even when the individual density values are fairly far from zero, their product may underflow to zero. Optimizers have problems when there is a large flat area. > q <- runif(n=1000, -0.1, +0.1) > prod(dnorm(q)) [1] 0 > sum(dnorm(q, log=TRUE)) [1]

Re: [R] split element vector

2021-08-06 Thread Bill Dunlap
unlist(strsplit(vect, "\n")) On Fri, Aug 6, 2021 at 7:13 AM Luigi Marongiu wrote: > Hello, > I have a vector that contains some elements with concatenated values, such > as: > ``` > > vect > [1] "name_1" > [2] "name_2" > [3] "name_3\nsurname_3" > [4] "some other text\netc" > ``` > How can I

Re: [R] Reading File Sizes: very slow!

2021-09-25 Thread Bill Dunlap
On my Windows 10 laptop I see evidence of the operating system caching information about recently accessed files. This makes it hard to say how the speed might be improved. Is there a way to clear this cache? > system.time(L1 <- size.f.pkg(R.home("library"))) user system elapsed 0.48

Re: [R] Rdversion ???

2021-09-28 Thread Bill Dunlap
tools:::prepare2_Rd contains the lines ## FIXME: we no longer make any use of \Rdversion version <- which(sections == "\\Rdversion") if (length(version) > 1L) stopRd(Rd[[version[2L]]], Rdfile, "Only one \\Rdversion declaration is allowed") so I am guessing you

Re: [R] Package installation help: Stuck at "** byte-compile and prepare package for lazy loading"

2021-09-30 Thread Bill Dunlap
I just tried installing forensim on R-devel/Ubuntu 20.04/WSL-2.0 without an X server (hence DISPLAY was not set). Loading tktcl gives a warning that Tk is not available because DISPLAY is not set. The installation hung after the byte-compile message: installing to

Re: [R] Package installation help: Stuck at "** byte-compile and prepare package for lazy loading"

2021-09-30 Thread Bill Dunlap
package tile error reading package index file /home/bill/R-devel/R-build/site-library/tcltk2/tklibs/ttktheme_radiance/pkgIndex.tcl: can't find package tile ... -Bill On Thu, Sep 30, 2021 at 9:00 AM Bill Dunlap wrote: > I just tried installing forensim on R-devel/Ubuntu 20.04/WSL-2.0 without >

Re: [R] Package installation help: Stuck at "** byte-compile and prepare package for lazy loading"

2021-09-30 Thread Bill Dunlap
You can define the environment variable R_DONT_USE_TK (to any value) to avoid this hang caused by code in the tkrplot package. You do not have to have an X server running if R_DONT_USE_TK is set. This will avoid potential hangs while installing the 23 packages that depend on tkrplot.

Re: [R] I'd like to request that my R CRAN package is not tested on Solaris OS

2021-10-22 Thread Bill Dunlap
I agree with Stefan. Try using valgrind (on Linux) to check for memory misuse: R --debugger=valgrind --debugger-args="--leak-check=full --track-origins=yes" ... > yourTests() > q("no") -Bill On Fri, Oct 22, 2021 at 7:30 AM Stefan Evert wrote: > Just to add my personal cent to this: I've

Re: [R] Bug in list.files(full.names=T)

2021-12-20 Thread Bill Dunlap
> > > Why would one ever *add* a final unneeded path separator, > > unless one wanted it? > Good question, but it is common for Windows installer programs to add a terminal backslash to PATH entries. E.g., on my Windows laptop I get > grep(value=TRUE, "$",

Re: [R] Bug in list.files(full.names=T)

2021-12-20 Thread Bill Dunlap
" [15] "C:\\Users\\willi\\AppData\\Local\\GitHubDesktop\\bin" > table(grepl("$", strsplit(Sys.getenv("PATH"), ";")[[1]])) # c. 2:1 against terminal backslash FALSE TRUE 15 8 On Mon, Dec 20, 2021 at 9:30 AM Martin Maechler wrote: >

Re: [R] Using R to convert RDF/XML to

2021-12-31 Thread Bill Dunlap
This is the sort of thing that you should first ask the package maintainer about; there is an error in the rdf method for write_nquads: > rdflib:::write_nquads.rdf function (x, file, ...) { rdf_serialize(rdf, file, "nquads", ...) } I suspect that the first argument to rdf_serialize should be

Re: [R] .Rdata not loading

2021-12-23 Thread Bill Dunlap
And a fourth thing to do: * dput(tail(n=20, readBin(".RData", what=raw(), n=file.size(".RData" This can show if the file got truncated. -Bill On Thu, Dec 23, 2021 at 5:25 PM Bill Dunlap wrote: > Three things you might try using R (and show the results in this emai

Re: [R] .Rdata not loading

2021-12-23 Thread Bill Dunlap
Three things you might try using R (and show the results in this email thread): * load(verbose=TRUE, ".RData") # see how far it gets before stopping * file.info(normalizePath(".RData")) # is this the file you think it is? * dput(readBin(".RData", what=raw(), n=100)) The last will print some hex

Re: [R] Error: if statement: missing value where TRUE/FALSE needed

2022-01-05 Thread Bill Dunlap
And how does one [easily] download those files from sourceforge? -Bill On Wed, Jan 5, 2022 at 10:15 AM Chuck Coleman via R-help < r-help@r-project.org> wrote: > This is a rather complex error, for which I created > https://sourceforge.net/projects/rhelp/files/Metro/ to hold a minimal >

Re: [R] R lattice contourplot: select only specific values

2021-11-17 Thread Bill Dunlap
Try using at=c(1.8, 2.8) to specify the contour levels you want (and omit the cuts= argument). -Bill On Wed, Nov 17, 2021 at 5:41 AM Luigi Marongiu wrote: > I have a dataframe of three variables: x, y, z. The value of z are: > ``` > > unique(df$z) > [1] 1.0 1.2 1.4 1.6 1.8 2.0 2.2 2.6 3.0 2.4

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

2021-11-11 Thread Bill Dunlap
I googled for "ggplot2 boxplots by group" and the first hit was https://www.r-graph-gallery.com/265-grouped-boxplot-with-ggplot2.html which displays lots of variants along with the code to produce them. It has links to ungrouped boxplots and shows how violin plots can better display your data.

Re: [R] read_csv() error I cannot find

2021-11-24 Thread Bill Dunlap
Did the 3 warnings come from three separate calls to read_csv? If so, can you identify which files caused the warnings? E.g., change the likes of lapply(files, function(file) read_csv(file, ...)) to options(warn=1) # report warnings immediately lapply(files, function(file){ cat(file,

Re: [R] tidyverse: read_csv() misses column

2021-11-01 Thread Bill Dunlap
Use the col_type argument to specify your column types. [Why would you expect '2009' to be read as a string instead of a number?]. It looks like an initial zero causes an otherwise numeric looking entry to be considered a string (handy for zip codes in the northeastern US). help(read_csv) says

Re: [R] Is there a hash data structure for R

2021-11-02 Thread Bill Dunlap
Note that an environment carries a hash table with it, while a named list does not. I think that looking up an entry in a list causes a hash table to be created and thrown away. Here are some timings involving setting and getting various numbers of entries in environments and lists. The times

Re: [R] I'd like to request that my R CRAN package is not tested on Solaris OS

2021-10-22 Thread Bill Dunlap
e >> UndefinedBehaviorSanitizer (UBSan). Those have helped me in the past >> to track down mistakes, and even spot things I was not aware of. And >> it's an ease of mind as a developer when these tools and Valgrind >> checks give all OK reports. >> >> The R-hub se

Re: [R] Fwd: Merging multiple csv files to new file

2021-11-03 Thread Bill Dunlap
The error message arises because you are sometimes delimiting character strings using non-ASCII open and close double quotes, '“' and '”', instead of the old-fashioned ones, '"', which have no open or close variants. This is a language syntax error, so R didn't try to compute anything. The

Re: [R] Problem with lm Giving Wrong Results

2021-12-02 Thread Bill Dunlap
On the 'bad' machines, what did you get for summary(fit) summary(k) summary(Z) summary(gm*gsd^Z) ? -Bill On Thu, Dec 2, 2021 at 6:18 AM Labone, Thomas wrote: > In the code below the first and second plots should look pretty much the > same, the only difference being that the first

Re: [R] Degree symbol as axis label superscript [RESOLVED]

2021-11-30 Thread Bill Dunlap
The following makes degree signs appropriately, as shown in ?plotmath: plot(68, 20, xlab=expression(degree*F), ylab=expression(degree*C)) If you want the word "degree" spelled out, put it in quotes. -Bill On Tue, Nov 30, 2021 at 12:31 PM Rich Shepard wrote: > On Tue, 30 Nov 2021, Rich

Re: [R] Question about Rfast colMins and colMaxs

2021-11-30 Thread Bill Dunlap
You can use as.matrix() to convert your data.frame to a matrix, but that loses the speed/space advantages of colMins (as well as causing issues if some columns are not numeric). You could write to the maintainer of the package to ask that data.frames be directly supported. In the meantime you

Re: [R] Plotting confidence intervals with ggplot, in multiple facets.

2021-07-19 Thread Bill Dunlap
ggplot2::labs() interprets expressions as plotmath. E.g., data.frame(X=1:10,Y=(1:10)^2) %>% ggplot(aes(X,Y)) + geom_point() + labs(x = expression(beta), y = expression(beta^2)) -Bill On Mon, Jul 19, 2021 at 4:24 PM Rolf Turner wrote: > > > Thanks to Jeff Newmiller, Rui Barradas

Re: [R] Method Guidance

2022-01-13 Thread Bill Dunlap
Suppose your data were represented as parallel vectors "time" and "type", meaning that at time[i] a type[i] event occurred. You didn't say what you wanted if there were a run of "A" or "B". If you are looking for the time span between the last of a run of one sort of event and the first of a run

Re: [R] Inserting missing seq number

2022-03-30 Thread Bill Dunlap
stats::approx can do the job: > approx(x=df$seq, df$count, xout=1:7, method="constant", f=0) $x [1] 1 2 3 4 5 6 7 $y [1] 4 7 7 3 5 5 2 -Bill On Tue, Mar 29, 2022 at 7:47 PM Jeff Reichman wrote: > R-help > > Is there a R function that will insert missing sequence number(s) and then > fill a

Re: [R] [External] Funky calculations

2022-02-01 Thread Bill Dunlap
The base 2 representation of 0.4 repeats the digit sequence 1001 infinitely, hence must be rounded. The problem occurs in C the same as it does in R. bill@Bill-T490:~$ cat a.c #include int main(int argc, char* argv[]) { double d = 0.4 + 0.3 + 0.2 + 0.1; printf("0.4+0.3+0.2+0.1 ->

Re: [R] [External] Funky calculations

2022-02-02 Thread Bill Dunlap
: %s \n", bar, (bar > 1.0 ? "true" : "false")); > } > > gcc c-check.c -o c-check > ./c-check > foo: 1.00 , foo > 1: false > bar: 1.00 , bar > 1: true > > Again, it was my mistake for not reading the R-FAQ. I had no idea it would >

Re: [R] NAs are removed

2022-01-14 Thread Bill Dunlap
> fraction <- 0/0 > if (fraction < .5) TRUE else FALSE Error in if (fraction < 0.5) TRUE else FALSE : missing value where TRUE/FALSE needed -Bill On Fri, Jan 14, 2022 at 12:55 PM Bert Gunter wrote: > Unlikely. > > > 1/0 > [1] Inf ## not NA > > Bert > > On Fri, Jan 14, 2022 at 12:41 PM Jim

Re: [R] Error with text analysis data

2022-04-13 Thread Bill Dunlap
This sounds like what I think is a bug in stats::model.matrix.default(): a numeric column with all identical entries is fine but a constant character or factor column is not. > d <- data.frame(y=1:5, sex=rep("Female",5)) > d$sexFactor <- factor(d$sex, levels=c("Male","Female")) > d$sexCode <-

Re: [R] Error with text analysis data

2022-04-13 Thread Bill Dunlap
ike summarize(y) or mean(y) if that was the goal. > > Tim > > -Original Message- > From: R-help On Behalf Of Bill Dunlap > Sent: Wednesday, April 13, 2022 9:56 AM > To: Neha gupta > Cc: r-help mailing list > Subject: Re: [R] Error with text analysis data > &

Re: [R] Error with text analysis data

2022-04-13 Thread Bill Dunlap
uggest working until the model works, no errors and no NA > values. The reason is that I can get NA in several ways and I need to > understand why. If I just ignore the NA in my model I may be assuming the > wrong thing. > > > > Tim > > > > *From:* Bill Dunlap >

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

2023-08-17 Thread Bill Dunlap
MKL's results can depend on the number of threads running and perhaps other things. They blame it on the non-associativity of floating point arithmetic. This article gives a way to make results repeatable:

Re: [R] about opening R script Chinese annotation garble problem

2022-04-25 Thread Bill Dunlap
The answer depends on the encoding of the file containing the Chinese characters and on the version of R (since you are using Windows). I copied your subject line into Wordpad and and added some syntax to make a valid R expression s <- "永创 via R-help" I then saved it with the type "Unicode Text

  1   2   >