Re: [R] bu.test

2022-06-26 Thread Greg Minshall
Nick, when i try to read the plain text version of your e-mail, it seems messed up. maybe you'll get an answer even so, but you might think of re-formatting and re-sending. cheers, Greg Nick Wray wrote: > Hello I was trying to run this short code > > data

Re: [R] ggplot2

2022-04-05 Thread Greg Minshall
hi, Richard, > I get these warnings, and the package did not install: ... > 1: In install.packages("ggplot2", dependencies = TRUE) : > installation of package ‘curl’ had non-zero exit status Ivan and Kimmo have both pointed out you need the right development tools. in terms of debugging your p

Re: [R] plain passwords in reminder mail

2022-03-01 Thread Greg Minshall
Eduard, > The list membership reminder mail includes a plain password! this is very typical for, at least, mailman-supported, e-mail lists. the password is of low intrinsic value, as it only allows you to change your membership and options on the list. cheers, Greg _

Re: [R] checkpointing

2021-12-13 Thread Greg Minshall
Duncan, > R functions can call libraries written in other languages, and can > start processes, etc. R doesn't know everything going on in every > function call, and would have a lot of trouble saving it. indeed, that obvious fact hadn't occurred to me. i withdraw my contention. :) cheers, Gr

Re: [R] checkpointing

2021-12-13 Thread Greg Minshall
Jeff, > This sounds like an OS feature, not an R feature... certainly not a > portable R feature. i'm not arguing for it, but this seems to me like something that could be a language feature. cheers, Greg __ R-help@r-project.org mailing list -- To UNS

Re: [R] Translation of the charter

2021-11-02 Thread Greg Minshall
hi, Heinz, > You are right - match seems obviously better, but why not do > > x <- c("a","b","c") > match(x, letters[]) no, really, i wasn't sure of the requirements! cheers, Greg __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see h

Re: [R] Translation of the charter

2021-11-02 Thread Greg Minshall
Heinz, > x <- c("a","b","c") > lettersnum <- 1:length(letters[]) > names(lettersnum) <- letters[] > lettersnum[x] > > lettersnum[x] > a b c > 1 2 3 i'm not sure if the following is obviously better, but one might do > b <- match(a, a) > names(b) <- a > b a b c 1 2 3 cheers, Greg _

Re: [R] Need help in R

2021-10-26 Thread Greg Minshall
Bert, > findprm <- function(n){ >nn <- seq.int(2, n) >i <- 2 >while(i <= floor(sqrt( n))){ > nn <- nn[(nn <= i) | (nn %% i > 0)] > i <- nn[nn > i][1] >} >nn > } +1 -- thanks! __ R-help@r-project.org mailing list -- To UN

Re: [R] assumptions about how things are done

2021-10-10 Thread Greg Minshall
hi, Richard, > ifelse(..., ..., ...) is not a control structure. It is not special > syntax. It is a normal function call, and it evaluates its arguments > and expands them to a common length just like "+" or, more to the > point, just like "&". > > So why do we have people expecting a normal fu

Re: [R] on thread hijacking

2021-09-29 Thread Greg Minshall
Giuseppe, Jeff mentioned "thread hijacking". in case you're not familiar with the term, you could look here http://www.mutt.org/doc/manual/ and search for "hijacking" or "in-reply-to". basically, afaik, when you want to send e-mail to the *same* list, but on a *different* topic, you sh

Re: [R] How to globally convert NaN to NA in dataframe?

2021-09-04 Thread Greg Minshall
Duncan, > x[] <- lapply(...) says "set the values in x to the values in the list > on the RHS", so x retains its class. thanks! cheers, Greg __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-h

Re: [R] How to globally convert NaN to NA in dataframe?

2021-09-02 Thread Greg Minshall
Andrew, > x[] <- lapply(x, function(xx) { > xx[is.nan(xx)] <- NA_real_ > xx > }) > > is different from > > x <- lapply(x, function(xx) { > xx[is.nan(xx)] <- NA_real_ > xx > }) indeed, the two are different -- but some ignorance of mine is exposed. i wonder, can you explain why t

Re: [R] A glitch (???) in tools::texi2pf.

2021-08-31 Thread Greg Minshall
by the way, and "fwiw", the emacs org mode community seems to like using latexmk for moving latex files towards .pdf'ishness: https://mg.readthedocs.io/latexmk.html cheers, Greg __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see h

Re: [R] Find "undirected" duplicates in a tibble

2021-08-21 Thread Greg Minshall
Bert, > Turns out that there's an even faster alternative. hah, but i'm *not* surprised. thanks for sharing the (current) low-price leader! and, thanks, again, to Kimmo for posting such a productive question! cheers, Greg my apply user system elapsed 8.465 0.103 8.578 Bert's

Re: [R] Find "undirected" duplicates in a tibble

2021-08-20 Thread Greg Minshall
Bert, > The efficiency gains are due to vectorization and the use of more > efficient primitives. None of this may matter of course, but it seemed > worth mentioning. thanks very much! the varieties of code, and disparities of performance, are truly wonderful. Rui's point that what works better

Re: [R] Find "undirected" duplicates in a tibble

2021-08-20 Thread Greg Minshall
Eric, > x %>% transmute( a=pmin(Source,Target), b=pmax(Source,Target)) %>% > unique() %>% rename(Source=a, Target=b) ah, very nice. i have trouble remembering, e.g., unique(). fwiw, (hopefully) here's a baser version. x = data.frame(Source=rep(1:3,4), Target=c(rep(1,3),rep(2,3),rep(3,

Re: [R] Find "undirected" duplicates in a tibble

2021-08-20 Thread Greg Minshall
Kimmo, i'll be curious to see other, maybe more elegant, answers. in the meantime, this seems to work. x = data.frame(Source=rep(1:3,4), Target=c(rep(1,3),rep(2,3),rep(3,3),rep(4,3))) y <- apply(x, 1, function(y) return (c(n=min(y), x=max(y res <- data.frame() for (n in unique(

Re: [R] Calculation of Age heaping

2021-08-09 Thread Greg Minshall
Md, if this is what you are looking for: https://en.wikipedia.org/wiki/Whipple%27s_index then, the article says the algorithm is The index score is obtained by summing the number of persons in the age range 23 and 62 inclusive, who report ages ending in 0 and 5, dividing that sum b

Re: [R] problem for strsplit function

2021-07-09 Thread Greg Minshall
Kai, > one more question, how can I know if the function is for column > manipulations or for vector? i still stumble around R code. but, i'd say the following (and look forward to being corrected! :): 1. a column, when extracted from a data frame, *is* a vector. 2. maybe your question is "i

Re: [R] problem for strsplit function

2021-07-07 Thread Greg Minshall
> sub( "\\.[^.]*$", "", fname ) fwiw, i almost always use '[.]' in preference to '.', as it seems to be more likely to get through the various levels of quoting in different contexts. __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and mo

Re: [R] Joining data frames

2021-06-29 Thread Greg Minshall
hi. i would suggest re-formatting your message as plain text (not HTML), and re-sending it. this list strips out HTML content, and the plain text version you sent is close to illegible. cheers, Greg __ R-help@r-project.org mailing list -- To UNSUBSCRI

Re: [R] interactively getting alist of functions for a given package?

2021-06-24 Thread Greg Minshall
Jake and Deepayan, both very nice and useful solutions. thank you. Greg __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting

Re: [R] interactively getting alist of functions for a given package?

2021-06-24 Thread Greg Minshall
Duncan, > Bert gave you an answer that depends on ls(). Whether there's > something like "set" that can return "asset" probably depends on > your front end, and may be customizable using the facilities described > in ?rcompgen. thanks. i am just using command line R on linux. i tried setting `

Re: [R] interactively getting alist of functions for a given package?

2021-06-23 Thread Greg Minshall
Bert, > ?ls and note the "pattern" argument. ... > ls("package:base", pat =".*set.*") awesome -- thanks! cheers, Greg __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the

[R] interactively getting alist of functions for a given package?

2021-06-23 Thread Greg Minshall
hi. at the R prompt, i often hit, e.g., "data.table::", to try to find a routine in a give package. however, some packages have a *lot* of functions (i'm looking at *you*, ggplot2...), so if i know the routine name starts with, e.g., "set", i can filter the returned list of routines by typing "da

Re: [R] most stable way to output text layout

2021-06-12 Thread Greg Minshall
Jeremie, i'm not totally sure i understand your desire. but, does this help? mx <- max(nchar(mat), na.rm=TRUE) apply( mat,1, function(x) { x[is.na(x)] <-"" cat(sprintf("%*s", mx, x), "\n") }) cheers, Greg __ R-he

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

2021-06-08 Thread Greg Minshall
> Two of R's central features as a "data science" language are that many of > its core capabilities are "vectorized" -- can calculate on whole objects > (at the user-visible interpreter level) rather than requiring explicit > loops; and that it can use object indexing in several different modalitie

Re: [R] Need help to fix the max date filter problem in the date input

2021-06-08 Thread Greg Minshall
Biplab, i'm not sure how to help you here, but this list pretty much runs on plain ASCII (or, these days, utf-8) e-mail. for the most part, without attachments. so, simply-formatted text, including code, with some mechanism in the code to initialize any data structures (data frames, matrices, et

Re: [R] Converting data from weekly interval to daily interval

2021-06-08 Thread Greg Minshall
Bhaskar, not your main question, but ... given that you have column names, you might think of : df2[inc,"date"] <- df1[i,"date"]/7 or : df2[inc,]$date <- df1[i,]$date/7 i.e., using your column names instead of numeric indices. then, also, instead of a for loop, possibly you can use R's

Re: [R] Can I use group_map to iteratively process a dataframe?

2021-06-04 Thread Greg Minshall
Madison, by the way, it's sort of hard to follow your example. there's some concept of MWE ==? Minimum Working Example. duckduckgo, or others on the list, can probably point the way. and, by the way :), i'm no expert. in particular, not on magrittr pipes, or on group_*, though i use both in so

Re: [R] Fwd: Create new polygon from a polygon

2021-04-22 Thread Greg Minshall
Javad, you might think of asking in the r-sig-geo e-mail list? : r-sig-...@r-project.org cheers. __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://w

Re: [R] Assigning several lists to variables whose names are contained in other variables

2021-04-09 Thread Greg Minshall
Wolfgang, > result <- assign(paste("subnet_",  val, sep = "") > > result <- my_function(val) i don't understand why you are twice assigning to =result=. also, the first assignment doesn't seem well formatted (t's missing a value?). did you mean something like : assign(paste("subnet_",  val, s

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

2021-03-29 Thread Greg Minshall
Stefano, i notice that my and Bill's (pretty much isomorphic) solutions give a zero-length vector. i don't remember Bert's, but it's probably gives similar results. your code could check for that result, and react accordingly. cheers, Greg __ R-help@

Re: [R] How to average minutes per hour per month in the form of '# hours #minutes'

2021-03-27 Thread Greg Minshall
Eberhard, > My malpractice insurance gives me a discount if I consult up to 22 > hours per week in a 3 months period. i wonder if you might add up the number of hours worked over the (92 (?)) days of November, December, January, divide by that number of days, then divide by seven? that would

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

2021-03-27 Thread Greg Minshall
Stefano, my contribution is similar to Bill Dunlap's: x <- c(1,0,0,0,2,2,3,4,0,1,1,0,5,5,5,0,1) (cumsum(rle(x)$lengths)-(rle(x)$length-1))[which(diff(diff(rle(x)$values)>=0)<0)+1] cumsum(rle(x)$lengths)[which(diff(diff(rle(x)$value)>0)>0)+1] kind of a cute little problem, actually. che

Re: [R] Difficulty using the tryCatch() function

2021-02-08 Thread Greg Minshall
try removing the outermost '{'...'}'. e.g., { warning = ... } should be 'warning = ...'. Adn <- function(x,y) { out <- tryCatch( { x+y }, warning = function(cond) { message("There was a warning.") message("Here is the original warning message:")

Re: [R] values of list of variable names

2018-06-01 Thread Greg Minshall
Christian, does this do it? > eval(lapply(ls(pattern="pr"), function(x) eval(parse(text=x cheers, Greg __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting gui

Re: [R] options other than regex

2018-05-25 Thread Greg Minshall
Evan, are you really looking at numbers, or just at character strings (that, in your case, happen to be numbers)? if just characters, this rather odd combination of strsplit() and Reduce() might do the trick: > x <- '10110111' > print(x) [1] "10110111" > y <- Reduce(function (x,y) { paste(x,

[R] getPairListElement()

2014-06-30 Thread Greg Minshall
usemagick = LOGICAL(getPairListElement(args, "usemagickwand", "rimageread"))[0]; ... } anyway, in the hope this may be of some use to someone. cheers, Greg Minshall /* get the list element named str, or report an error() */ static SEXP getPairListElement(SEXP pair

[R] imlib2, pixmap?

2014-06-15 Thread Greg Minshall
no one has done this, i'll probably do it (at least for my own use, never having produced a "public" package). cheers, Greg Minshall __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the pos

Re: [R] 2 setGeneric's, same name, different method signatures

2013-02-21 Thread Greg Minshall
the world's most minor typo on https://github.com/hadley/devtools/wiki/Rcpp optimisiation helpful page, btw! thanks! __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-pr

Re: [R] 2 setGeneric's, same name, different method signatures

2013-02-21 Thread Greg Minshall
(apologies for not having edited the to/cc list) __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-conta

Re: [R] 2 setGeneric's, same name, different method signatures

2013-02-15 Thread Greg Minshall
William, > and here mention "intra-class name clashes" (I'm not sure what you > mean by this). sorry, i meant, in something like C++, if i have a class Foo and you have a class Bar, then i can invent whatever method names/signatures i want, independent of whatever method names/signatures *you* wa

Re: [R] 2 setGeneric's, same name, different method signatures

2013-02-15 Thread Greg Minshall
Martin, fantastic. thank you *very* much! that clears lots of things up for me. (for the record: i think that setGeneric overwriting a previous is more surprising -- thus violating the principle of least surprise -- than one function overwriting a previous, in that we think of (or, one way to t

Re: [R] 2 setGeneric's, same name, different method signatures

2013-02-14 Thread Greg Minshall
#3 above, how A can specify that "no b2 is allowed!", i'd be curious. cheers, Greg Minshall setClass("A", representation( x="numeric")); setMethod( f="initialize", signature="A", definition=function(.Object) { .O

[R] 2 setGeneric's, same name, different method signatures

2013-02-14 Thread Greg Minshall
e file, i see the method for A's bB has disappeared (as measured by showMethods("bB"), as well as trying bB(A). if i have R re-parse the setGeneric/setMethod A's bB(), then B's bB() disappears. somehow my code, or my model of how things work, is wrong. any idea

[R] network connectivity is *not* symmetric -- library(parallel)

2013-02-14 Thread Greg Minshall
as maybe the internet module, so is probably longer term. i think, though, that doing this would benefit people who now are confused when they can't start up two clusters on the same (currently, master) machine, etc. cheers, Greg Minshall __

Re: [R] an assert() function

2013-02-12 Thread Greg Minshall
Duncan, thanks for the response. stopifnot() looks almost right. it's very useful if assertion failures issue an error message pointing at the source file/line (such as error produces); it might also be nice (but not necessary) to allow the caller to pass in a "higher level" message to be append

[R] an assert() function

2013-02-12 Thread Greg Minshall
hi. i've looked for (and not found) an assert() function. needing one, i created the following (from stop()). i'm posting it in case 1) someone sees a problem with this; and 2) someone else has a need. cheers, Greg ## an assert mechanism... assert <- function (shouldbe, ...) { if (!shoul

[R] macosx 10.8 install of rgl

2012-12-09 Thread Greg Minshall
(without --with-gl-libs, -lGLU is not found, or -lX11 is not found; without --disable-cocoa, osx/osxgui.o is not found [it appears that in this case rgl is somewhat schizophrenic w.r.t. installing Mac-native Cocoa support, which i didn't anyway want