Re: [R] by function does not separate output from function with, mulliple parts

2023-10-25 Thread Leonard Mada via R-help
Dear John, Printing inside the function is problematic. Your function itself does NOT print the labels. Just as a clarification: F = factor(rep(1:2, 2)) by(data.frame(V = 1:4, F = F), F, function(x) { print(x); return(NULL); } ) #   V F # 1 1 1 # 3 3 1 #   V F # 2 2 2 # 4 4 2 # F: 1 <- this i

Re: [R] Issue from R-devel: subset on table

2023-10-21 Thread Leonard Mada via R-help
Another solution could also be possible - see below. On 10/21/2023 10:38 PM, Leonard Mada wrote: My mistake! It does actually something else, which is incorrect. One could still use (although the code is more difficult to read): subset(tmp <- table(sample(1:10, 100, T)), tmp > 1

Re: [R] Issue from R-devel: subset on table

2023-10-21 Thread Leonard Mada via R-help
My mistake! It does actually something else, which is incorrect. One could still use (although the code is more difficult to read): subset(tmp <- table(sample(1:10, 100, T)), tmp > 10) Sincerely, Leonard On 10/21/2023 10:26 PM, Leonard Mada wrote: Dear List Members, The

[R] Issue from R-devel: subset on table

2023-10-21 Thread Leonard Mada via R-help
Dear List Members, There was recently an issue on R-devel (which I noticed only very late): https://stat.ethz.ch/pipermail/r-devel/2023-October/082943.html It is possible to use subset as well, almost as initially stated: subset(table(sample(1:5, 100, T)), table > 10) # Error in table > 10 : # 

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

2023-10-18 Thread Leonard Mada via R-help
Dear Rui, On 10/18/2023 8:45 PM, Rui Barradas wrote: split_chem_elements <- function(x, rm.digits = TRUE) {   regex <- "(?<=[A-Z])(?![a-z]|$)|(?<=.)(?=[A-Z])|(?<=[a-z])(?=[^a-z])"   if(rm.digits) {     stringr::str_replace_all(mol, regex, "#") |>   strsplit("#|[[:digit:]]") |>   lapply(\

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

2023-10-18 Thread Leonard Mada via R-help
there is anything like is.numeric, but to parse each element of a vector. Sincerely, Leonard On 10/18/2023 6:53 PM, Rui Barradas wrote: Às 15:59 de 18/10/2023, Leonard Mada via R-help escreveu: Dear List members, What is the best way to test for numeric digits? suppressWarnings(as.double(c

[R] Best way to test for numeric digits?

2023-10-18 Thread Leonard Mada via R-help
Dear List members, What is the best way to test for numeric digits? suppressWarnings(as.double(c("Li", "Na", "K",  "2", "Rb", "Ca", "3"))) # [1] NA NA NA  2 NA NA  3 The above requires the use of the suppressWarnings function. Are there any better ways? I was working to extract chemical eleme

Re: [R] Create new data frame with conditional sums

2023-10-16 Thread Leonard Mada via R-help
23 7:41 PM, Leonard Mada wrote: Dear Jason, I do not think that the solution based on aggregate offered by GPT was correct. That quasi-solution only aggregates for every individual level. As I understand, you want the cumulative sum. The idea was proposed by Bert; you need only to sort firs

Re: [R] Create new data frame with conditional sums

2023-10-15 Thread Leonard Mada via R-help
Dear Jason, I do not think that the solution based on aggregate offered by GPT was correct. That quasi-solution only aggregates for every individual level. As I understand, you want the cumulative sum. The idea was proposed by Bert; you need only to sort first based on the cutoff (e.g. usin

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

2023-09-04 Thread Leonard Mada via R-help
es as documented in Writing R Extensions. If your goal is to not use source files this way then the solution is to not use roxygen at all. Just create those files yourself by directly editing them from scratch. On September 3, 2023 7:06:09 PM PDT, Leonard Mada via R-help wrote: Thank you

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

2023-09-03 Thread Leonard Mada via R-help
specified by the > "Writing ..." manual. > > Again, further questions and elaboration should go to the > R-package-devel list, although I think the manual is really the > authoritative resource to follow. > > Cheers, > Bert > > > > On Sun,

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

2023-09-03 Thread Leonard Mada via R-help
Dear R-List Members, I am looking for collaborators to further develop the BioShapes almost-package. I added a brief description below. A.) BioShapes (Almost-) Package The aim of the BioShapes quasi-package is to facilitate the generation of graphical objects resembling biological and chemic

Re: [R] Query on finding root

2023-08-28 Thread Leonard Mada via R-help
Dear R-Users, Just out of curiosity: Which of the 2 methods is the better one? The results seem to differ slightly. fun = function(u){((26104.50*u^0.03399381)/((1-u)^0.107)) - 28353.7} uniroot(fun, c(0,1)) # 0.6048184 curve(fun(x), 0, 1) abline(v=0.3952365, col="red") abline(v=0.6048184,

Re: [R] Numerical stability of: 1/(1 - cos(x)) - 2/x^2

2023-08-18 Thread Leonard Mada via R-help
o the exact value! y <- 1 - x^2/2; 1/(1 - y) - 2/x^2 # 58672303, not 0, nor close to 0; Sincerely, Leonard > > On Fri, Aug 18, 2023 at 4:34 PM Leonard Mada wrote: > > Dear Bert, > > > Values of type 2^(-n) (and its binary complement) are exactly > represented

Re: [R] Numerical stability of: 1/(1 - cos(x)) - 2/x^2

2023-08-18 Thread Leonard Mada via R-help
t numbers (and their arithmetic) > > Cheers, > Bert > > > On Fri, Aug 18, 2023 at 3:25 PM Leonard Mada via R-help > wrote: > > I have added some clarifications below. > > On 8/18/2023 10:20 PM, Leonard Mada wrote: > > [...] > > After mo

Re: [R] Numerical stability of: 1/(1 - cos(x)) - 2/x^2

2023-08-18 Thread Leonard Mada via R-help
I have added some clarifications below. On 8/18/2023 10:20 PM, Leonard Mada wrote: [...] After more careful thinking, I believe that it is a limitation due to floating points: [...] The problem really stems from the representation of 1 - x^2/2 as shown below: x = 1E-4 print(1 - x^2/2

Re: [R] Numerical stability of: 1/(1 - cos(x)) - 2/x^2

2023-08-18 Thread Leonard Mada via R-help
= 1 + cos(x) cos1n(x) = 1 - cos(x) Though, I do not have yet the big picture. Sincerely, Leonard On 8/17/2023 1:57 PM, Martin Maechler wrote: Leonard Mada on Wed, 16 Aug 2023 20:50:52 +0300 writes: > Dear Iris, > Dear Martin, > Thank you very much for your r

Re: [R] Numerical stability of: 1/(1 - cos(x)) - 2/x^2

2023-08-16 Thread Leonard Mada via R-help
ve that there is room for improvement. Sincerely, Leonard On 8/16/2023 9:51 AM, Iris Simmons wrote: > You could rewrite > > 1 - cos(x) > > as > > 2 * sin(x/2)^2 > > and that might give you more precision? > > On Wed, Aug 16, 2023, 01:50 Leonard Mada via R-help &

[R] Numerical stability of: 1/(1 - cos(x)) - 2/x^2

2023-08-15 Thread Leonard Mada via R-help
Dear R-Users, I tried to compute the following limit: x = 1E-3; (-log(1 - cos(x)) - 1/(cos(x)-1)) / 2 - 1/(x^2) + log(x) # 0.4299226 log(2)/2 + 1/12 # 0.4299069 However, the result diverges as x decreases: x = 1E-4 (-log(1 - cos(x)) - 1/(cos(x)-1)) / 2 - 1/(x^2) + log(x) # 0.9543207 # correct: 0

Re: [R] Regex Split?

2023-05-05 Thread Leonard Mada via R-help
t;  [1] "a"    "bc"   ","    "def"  ","    "adef" ","    "x"  ";" > [10] ","    ","    "gh" > > I certainly would *not* claim that it is in any way superior to >

Re: [R] Regex Split?

2023-05-05 Thread Leonard Mada via R-help
as text using standard overkill tools: read.table(text="a bc,def, adef ,,gh", sep=",") V1 V2 V3 V4 V5 1 a bc def adef NA gh The above is a vector of texts. But if you simply want to reassemble your initial string cleaned up a bit, you can use paste to put back com

Re: [R] Regex Split?

2023-05-05 Thread Leonard Mada via R-help
hree!" > > The bug report includes the comment > It may be possible that strsplit is not using the startoffset argument > to pcre_exec > >pcre/pcre/doc/html/pcreapi.html > A non-zero starting offset is useful when searching for another match > in the same s

[R] Regex Split?

2023-05-04 Thread Leonard Mada via R-help
Dear R-Users, I tried the following 3 Regex expressions in R 4.3: strsplit("a bc,def, adef ,,gh", " |(?=,)|(?<=,)(?![ ])", perl=T) # "a"    "bc"   ","    "def"  ","    "" "adef" ","    "," "gh" strsplit("a bc,def, adef ,,gh", " |(?- the first one could also return "", "," (but probably not;

Re: [R] Split String in regex while Keeping Delimiter

2023-04-13 Thread Leonard Mada via R-help
uded in the expanded Regex expression: tokens = strsplit(str, "(?<=[-+\u2010-\u2014])\\s++", perl=TRUE) Sincerely, Leonard On 4/13/2023 9:40 PM, Leonard Mada wrote: Dear Emily, Using a look-behind solves the split problem in this case. (Note: Using Regex is in most/many c

Re: [R] Split String in regex while Keeping Delimiter

2023-04-13 Thread Leonard Mada via R-help
Dear Emily, Using a look-behind solves the split problem in this case. (Note: Using Regex is in most/many cases the simplest solution.) str = c("leucocyten + gramnegatieve staven +++ grampositieve staven ++", "leucocyten – grampositieve coccen +") tokens = strsplit(str, "(?<=[-+])\\s++", perl

Re: [R] Default Generic function for: args(name, default = TRUE)

2023-03-08 Thread Leonard Mada via R-help
(.S3methods(print)) > [1] 206 > > There may be better ways, but this is what came to my mind. > -- Bert > > On Wed, Mar 8, 2023 at 11:09 AM Leonard Mada via R-help > wrote: > > Dear R-Users, > > I want to change the args() function to return by default

Re: [R] Default Generic function for: args(name, default = TRUE)

2023-03-08 Thread Leonard Mada via R-help
quot;.default") name = fn } .Internal(args(name)) } r/ Gregg --- Original Message --- On Wednesday, March 8th, 2023 at 12:09 PM, Leonard Mada via R-help wrote: Dear R-Users, I want to change the args() function to return by default the arguments of the default generic function: arg

[R] Default Generic function for: args(name, default = TRUE)

2023-03-08 Thread Leonard Mada via R-help
Dear R-Users, I want to change the args() function to return by default the arguments of the default generic function: args = function(name, default = TRUE) {     # TODO: && is.function.generic();     if(default) {    fn = match.call()[[2]];    fn = paste0(as.character(fn), ".default"

[R] Generic Function read?

2023-02-28 Thread Leonard Mada via R-help
Dear R-Users, I noticed that *read* is not a generic function. Although it could benefit from the functionality available for generic functions: read = function(file, ...) UseMethod("read") methods(read)  # [1] read.csv read.csv2    read.dcf read.delim read.delim2  read.DIF read.

[R] Covid Mutations: Cumulative?

2023-01-30 Thread Leonard Mada via R-help
Dear R-Users, Did anyone follow more closely the SARS Cov-2 lineages? I have done a quick check of Cov-2 mutations on the list downloaded from NCBI (see GitHub page below); but it seems that the list contains the cumulative mutations only for B.1 => B.1.1, but not after the B.1.1 branch: # B.

Re: [R] Covid-19 Variants & Lineages

2023-01-24 Thread Leonard Mada via R-help
Dear Ivan, Thank you very much. Indeed, I missed the download button. The csv file seems to contain all the mutations in a usable format. Sincerely, Leonard On 1/24/2023 11:29 PM, Ivan Krylov wrote: On Tue, 24 Jan 2023 22:26:34 +0200 Leonard Mada via R-help wrote: The data on the

[R] Covid-19 Variants & Lineages

2023-01-24 Thread Leonard Mada via R-help
Dear R-Users, 1.) Is there a package which gives the full code of a Covid-19 lineage/variant? E.g. Omicron = B.1.1.529, while BA correspond to specific subtypes of Omicron: BA.x: BA.1 = B.1.1.529.1; BA.1.1 = B.1.1.529.1.1; BA.1.1.5 = B.1.1.529.1.1.5; Is there any package to offer such trans

Re: [R] R emulation of FindRoot in Mathematica

2023-01-22 Thread Leonard Mada via R-help
0[1] = 1E-6; x = multiroot(solve.AcidSpecies, x0, H = 4E-8) print(x) # Results: # atp  adp   pi  pcr cr  lactate # 4.977576e-04 3.254998e-06 5.581774e-08 4.142785e-09 5.011807e-10 4.973691e-03 Sincerely, Leonard On 1/23/2023 2:24 AM, Leonard Mada wrote: >

Re: [R] R emulation of FindRoot in Mathematica

2023-01-22 Thread Leonard Mada via R-help
    cr = 0.004,     lactate = 0.005 ) / 3; # tricky to get a positive value !!! x0[1] = 0.001; # still NOT positive; x = multiroot(solve.AcidSpecies, x0, H = 4E-8) On 1/23/2023 12:37 AM, Leonard Mada wrote: > Dear Troels, > > The system that you mentioned needs to be transformed first. The > equa

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

2023-01-12 Thread Leonard Mada via R-help
Dear Akshay, The best response was given by Andrew. "{...}" is not a closure. This is unusual for someone used to C-type languages. But I will try to explain some of the rationale. In the case that "{...}" was a closure, then external variables would need to be explicitly declared before the

[R] Problem with integrate(function(x) x^3 / sin(x), -pi/2, pi/2)

2023-01-07 Thread Leonard Mada via R-help
Dear List-Members, I encounter a problem while trying to integrate the following function: integrate(function(x) x^3 / sin(x), -pi/2, pi/2) # Error in integrate(function(x) x^3/sin(x), -pi/2, pi/2) : #  non-finite function value # the value should be finite: curve(x^3 / sin(x), -pi/2, pi/2) int

Re: [R] extract from a list of lists

2022-12-28 Thread Leonard Mada via R-help
Dear Terry, The following approach may be more suitable: fits <- lapply(argument, function) fits.df = do.call(rbind, fits); It works if all the lists returned by "function" have the same number of elements. Example: fits.df = lapply(seq(3), function(id) { list( beta = rnorm(1)

[R] Hidden Problems with Clustering Algorithms

2022-11-21 Thread Leonard Mada via R-help
Dear R-Users, Hidden Problems with Clustering Algorithms I stumbled recently upon a presentation about hierarchical clustering. Unfortunately, it contains a hidden problem of clustering algorithms. The problem is deeper and I think that it warrants a closer inspection by the statistical commu

Re: [R] Partition vector of strings into lines of preferred width

2022-10-28 Thread Leonard Mada via R-help
paragraphs, I would usually do something like: strwrap(x = , width = 80, indent = 4) On Fri, Oct 28, 2022 at 5:42 PM Leonard Mada via R-help wrote: Dear R-Users, text = " What is the best way to split/cut a vector of strings into lines of preferred width? I have come up with a simple sol

[R] Partition vector of strings into lines of preferred width

2022-10-28 Thread Leonard Mada via R-help
Dear R-Users, text = " What is the best way to split/cut a vector of strings into lines of preferred width? I have come up with a simple solution, albeit naive, as it involves many arithmetic divisions. I have an alternative idea which avoids this problem. But I may miss some existing function

[R] [External Help] Multivariate Polynomials in R

2022-10-02 Thread Leonard Mada via R-help
Dear R Users, I have written some R code for multivariate polynomials in R. I am looking forward for some help in redesigning and improving the code. Although this code was not planned initially to be released as a package, the functionality has become quite versatile over time. I will provi

Re: [R] regexpr: R takes very long with non-existent pattern

2022-05-18 Thread Leonard Mada via R-help
; 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 Wed, May 18, 2022 at 5:08 PM Leonard Mada via R-help > wro

Re: [R] regexpr: R takes very long with non-existent pattern

2022-05-18 Thread Leonard Mada via R-help
else to say, have you tried it again since? Regards, Andrew Simmons On Wed, May 18, 2022 at 5:09 PM Leonard Mada via R-help wrote: Dear R Users, I have run the following command in R: # x = larger vector of strings (1200 Pubmed abstracts); # patt = not defined; npos = regexpr(patt,

[R] regexpr: R takes very long with non-existent pattern

2022-05-18 Thread Leonard Mada via R-help
Dear R Users, I have run the following command in R: # x = larger vector of strings (1200 Pubmed abstracts); # patt = not defined; npos = regexpr(patt, x, perl=TRUE); # Error in regexpr(patt, x, perl = TRUE) : object 'patt' not found The problem: R becomes unresponsive and it takes 1-2 minut

Re: [R] How to convert category (or range/group) into continuous?

2022-01-18 Thread Leonard Mada via R-help
Dear Marna, If you want to extract the middle of those intervals, please find below an improved variant of Luigi's code. Note: - it is more efficient to process the levels of a factor, instead of all the individual strings; - I envision that there are benefits in a large data frame (> 1 mil

Re: [R] Method Guidance

2022-01-14 Thread Leonard Mada via R-help
o: tbl = table(cumEvent); # to be on the safe side (as the cumsum is increasing): id = order(as.numeric(names(tbl))); tbl = tbl[id]; Hope this helps, Leonard On 1/14/2022 3:30 AM, Leonard Mada wrote: Dear Jeff, My answer is a little bit late, but I hope it helps. jrdf = read.table(text=&qu

Re: [R] Method Guidance

2022-01-13 Thread Leonard Mada via R-help
Dear Jeff, My answer is a little bit late, but I hope it helps. jrdf = read.table(text="Time Event_AEvent_B Lag_B 1 1 10 2 0 11 3 0 00 4 1 00 5 0 11 6 0

Re: [R] Sum every n (4) observations by group

2021-12-20 Thread Leonard Mada via R-help
Dear Miluji, something like this could help: sapply(tapply(x$Value, x$ID, cumsum),     function(x) x[seq(4, length(x), by=4)] - c(0, x[head(seq(4, length(x), by=4), -1)])) 1.) Step 1: Compute the cumsum for each ID: tapply(x$Value, x$ID, cumsum) 2.) Step 2: - iterate over the resulting

Re: [R] How to create a proper S4 class?

2021-11-17 Thread Leonard Mada via R-help
person_names The next method implemented is often the [ (single bracket subset) function; this is relatively complicated to get right, but worth exploring. I hope that gets you a little further along the road. Martin Morgan On 11/16/21, 11:34 PM, "R-help on behalf of Leonard Mada via R-help&q

[R] How to create a proper S4 class?

2021-11-16 Thread Leonard Mada via R-help
Dear List-Members, I want to create an S4 class with 2 data slots, as well as a plot and a line method. Unfortunately I lack any experience with S4 classes. I have put together some working code - but I presume that it is not the best way to do it. The actual code is also available on Gith

[R] Dispatching on 2 arguments?

2021-11-06 Thread Leonard Mada via R-help
Dear List-members, I would like to experiment with dispatching on 2 arguments and have a few questions. p1 = data.frame(x=1:3, coeff=1) class(p1) = c("pm", class(p1)); I want to replace variables in a polynomial with either: another polynomial, or another variable (character) or with a spec

Re: [R] names.data.frame?

2021-11-03 Thread Leonard Mada via R-help
uld suggest making your class through the methods > package, with methods::setClass("pm", ...) > See the documentation for setClass for more details, it's the > recommended way to define classes in R. > > On Wed, Nov 3, 2021 at 2:36 PM Leonard Mada via R-help >

[R] names.data.frame?

2021-11-03 Thread Leonard Mada via R-help
Dear List members, Is there a way to access the default names() function? I tried the following: # Multi-variable polynomial p = data.frame(x=1:3, coeff=1) class(p) = c("pm", class(p)); names.pm = function(p) { # .Primitive("names")(p) # does NOT function # .Internal("names")(p) # does NO

Re: [R] How to use ifelse without invoking warnings

2021-10-09 Thread Leonard Mada via R-help
possible to run sapply on the filtered sequence (but I did not want to break anything now). Sincerely, Leonard On 10/9/2021 9:26 PM, Leonard Mada wrote: Dear Ravi, I wrote a small replacement for ifelse() which avoids such unnecessary evaluations (it bothered me a few times as well

Re: [R] How to use ifelse without invoking warnings

2021-10-09 Thread Leonard Mada via R-help
Dear Ravi, I wrote a small replacement for ifelse() which avoids such unnecessary evaluations (it bothered me a few times as well - so I decided to try a small replacement). ### Example: x = 1:10 FUN = list(); FUN[[1]] = function(x, y) x*y; FUN[[2]] = function(x, y) x^2; FUN[[3]] = function

[R] Extracting Comments from Functions/Packages

2021-10-07 Thread Leonard Mada via R-help
Dear R Users, I wrote a minimal parser to extract strings and comments from the function definitions. The string extraction works fine. But there are no comments: a.) Are the comments stripped from the compiled packages? b.) Alternatively: Is the deparse() not suited for this task? b.2.)

Re: [R] Descriptive Statistics: useful hacks

2021-10-05 Thread Leonard Mada via R-help
, Leonard Mada wrote: > Dear R Users, > > > I have started to compile some useful hacks for the generation of nice > descriptive statistics. I hope that these functions & hacks are useful > to the wider R community. I hope that package developers also get some > inspirat

[R] Descriptive Statistics: useful hacks

2021-10-02 Thread Leonard Mada via R-help
Dear R Users, I have started to compile some useful hacks for the generation of nice descriptive statistics. I hope that these functions & hacks are useful to the wider R community. I hope that package developers also get some inspiration from the code or from these ideas. I have started t

Re: [R] Word-Wrapper Library/Package?

2021-09-29 Thread Leonard Mada via R-help
any packages that do such > a thing. > If such a thing exists in another language, there's probably an R > package > with a similar name containing ports of such functions, that might > be your > best bet. I hope this helps. > > On Tue, Sep

Re: [R] Word-Wrapper Library/Package?

2021-09-28 Thread Leonard Mada via R-help
eonard On 9/29/2021 6:30 AM, Andrew Simmons wrote: > I think what you're looking for is 'strwrap', it's in package base. > > On Tue, Sep 28, 2021, 22:26 Leonard Mada via R-help > mailto:r-help@r-project.org>> wrote: > > Dear R-Users, > > &

[R] Word-Wrapper Library/Package?

2021-09-28 Thread Leonard Mada via R-help
Dear R-Users, Does anyone know any package or library that implements functions for word wrapping? I did implement a very rudimentary one (Github link below), but would like to avoid to reinvent the wheel. Considering that word-wrapping is a very common task, it should be available even in b

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

2021-09-26 Thread Leonard Mada via R-help
On 9/27/2021 1:06 AM, Leonard Mada wrote: > > Dear Bill, > > > Does list.files() always sort the results? > > It seems so. The option: full.names = FALSE does not have any effect: > the results seem always sorted. > > > Maybe it is better to process the files i

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

2021-09-26 Thread Leonard Mada via R-help
dir(R.home("library"),recursive=TRUE)) > [1] 12949 > > On Sat, Sep 25, 2021 at 8:12 AM Leonard Mada via R-help > mailto:r-help@r-project.org>> wrote: > > Dear List Members, > > > I tried to compute the file sizes of each installed package and the

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

2021-09-26 Thread Leonard Mada via R-help
.home("library"))) user system elapsed 0.351.101.43 identical(L1,L2) [1] TRUE length(L1) [1] 30 length(dir(R.home("library"),recursive=TRUE)) [1] 12949 On Sat, Sep 25, 2021 at 8:12 AM Leonard Mada via R-help < r-help@r-project.org> wrote: Dear List

[R] Reading File Sizes: very slow!

2021-09-25 Thread Leonard Mada via R-help
Dear List Members, I tried to compute the file sizes of each installed package and the process is terribly slow. It took ~ 10 minutes for 512 packages / 1.6 GB total size of files. 1.) Package Sizes system.time({         x = size.pkg(file=NULL); }) # elapsed time: 509 s !!! # 512 Packages

Re: [R] Installed packages: Bioconductor vs CRAN?

2021-09-24 Thread Leonard Mada via R-help
[working version] On 9/25/2021 2:55 AM, Leonard Mada wrote: Dear List Members, Is there a way to extract if an installed package is from Bioconductor or if it is a regular Cran package? The information seems to be *not* available in: installed.packages() ### [updated] # Basic Info

Re: [R] Installed packages: Bioconductor vs CRAN?

2021-09-24 Thread Leonard Mada via R-help
Dear Bert, Indeed, this seems to work: installed.packages(fields="Repository") I still need to figure out what variants to expect. Sincerely, Leonard On 9/25/2021 3:31 AM, Leonard Mada wrote: Dear Bert, The DESCRIPTION file contains additional useful information, e.g.: 1

Re: [R] Installed packages: Bioconductor vs CRAN?

2021-09-24 Thread Leonard Mada via R-help
n Fri, Sep 24, 2021 at 4:56 PM Leonard Mada via R-help wrote: Dear List Members, Is there a way to extract if an installed package is from Bioconductor or if it is a regular Cran package? The information seems to be *not* available in: installed.packages() Sincerely, Leonard === I

[R] Installed packages: Bioconductor vs CRAN?

2021-09-24 Thread Leonard Mada via R-help
Dear List Members, Is there a way to extract if an installed package is from Bioconductor or if it is a regular Cran package? The information seems to be *not* available in: installed.packages() Sincerely, Leonard === I started to write some utility functions to analyse installed

[R] [Questionnaire] Standardized Options: Justify/Alignment

2021-09-19 Thread Leonard Mada via R-help
Dear R users, I have started to work on an improved version of the format.ftable function. The code and ideas should be reused to improve other R functions (enabling more advanced format of the character output). However, there are a number of open questions. These are focused on standardiz

Re: [R] Improvement: function cut

2021-09-18 Thread Leonard Mada via R-help
4) > data.frame( >     cut(x, breaks1, right = FALSE, i = TRUE), >     cut(x, breaks2, right = FALSE, i = TRUE), >     check.names = FALSE > ) > > > I hope this helps. > > On Fri, Sep 17, 2021 at 6:26 PM Leonard Mada <mailto:leo.m...@syonic.eu>> wrote: > >

Re: [R] Improvement: function cut

2021-09-17 Thread Leonard Mada via R-help
are a lot of ways to introduce NAs... in real projects all analysts should be suspecting this problem. On September 17, 2021 3:01:35 PM PDT, Leonard Mada via R-help wrote: Thank you Andrew. Is there any reason not to make: include.lowest = TRUE the default? Regarding the NA: The user st

Re: [R] Improvement: function cut

2021-09-17 Thread Leonard Mada via R-help
seq.int <http://seq.int>(0, 16, 4) > breaks2 <- seq.int <http://seq.int>(0, 20, 4) > data.frame( >     cut(x, breaks1, right = FALSE, i = TRUE), >     cut(x, breaks2, right = FALSE, i = TRUE), >     check.names = FALSE > ) > > > I hope this helps. > > On

Re: [R] Improvement: function cut

2021-09-17 Thread Leonard Mada via R-help
> [8, 12) > [12, 16) > [16, 20] > > > so you can see where the inconsistent behaviour comes from. You might > be able to get R-core to add argument 'warn', but probably not to > change the default of 'include.lowest'. I hope this helps > > > On

Re: [R] Improvement: function cut

2021-09-17 Thread Leonard Mada via R-help
your own. > Might be worth pitching to R-bugs on the wishlist. > > > > On Fri, Sep 17, 2021, 17:45 Leonard Mada via R-help > mailto:r-help@r-project.org>> wrote: > > Hello List members, > > > the following improvements would be useful for function cut (

[R] Improvement: function cut

2021-09-17 Thread Leonard Mada via R-help
Hello List members, the following improvements would be useful for function cut (and .bincode): 1.) Argument: Include extremes extremes = TRUE if(right == FALSE) {    # include also right for last interval; } else {    # include also left for first interval; } 2.) Argument: warn = TRUE Warn

Re: [R] [R Code] Split long names in format.ftable

2021-09-17 Thread Leonard Mada via R-help
ep=" ") ftable2(ftbl, sep=" | ") ftable2(ftbl, sep=" | ", justify="left") ftable2(ftbl, sep=" | ", justify="cent") # TODO: center vs centre ftable2(ftbl, sep=" | ", justify="left", justify.lvl="c") Sincerely, Leona

Re: [R] [R Code] Split long names in format.ftable

2021-09-15 Thread Leonard Mada via R-help
/blob/master/Stat/Tools.Data.R It makes sense to have such functionality in base R as well: it may be useful in various locations to format character output. Sincerely, Leonard On 9/14/2021 8:18 PM, Leonard Mada wrote: Dear List members, I wrote some code to split long names in

Re: [R] Evaluating lazily 'f<-' ?

2021-09-14 Thread Leonard Mada via R-help
le, > > y <- `names<-`(x, value = c("some names")) > > now y will be equivalent to x if we did > > names(x) <- c("some names") > > except that the first will not update x, it will still have its old names. > > On Mon, Sep 13, 2021 at 4:33 PM

[R] [R Code] Split long names in format.ftable

2021-09-14 Thread Leonard Mada via R-help
Dear List members, I wrote some code to split long names in format.ftable. I hope it will be useful to others as well. Ideally, this code should be implemented natively in R. I will provide in the 2nd part of the mail a concept how to actually implement the code in R. This may be interesti

Re: [R] Fastest way to extract rows of smaller matrix many times by index to make larger matrix? and multiply columsn of matrix by vector

2021-09-14 Thread Leonard Mada via R-help
Hello Nevil, you could test something like: # the Matrix m = matrix(1:1000, ncol=10) m = t(m) # Extract Data idcol = sample(seq(100), 100, TRUE); # now columns for(i in 1:100) {     m2 = m[ , idcol]; } m2 = t(m2); # transpose back It may be faster, although I did not benchmark it. There m

Re: [R] Evaluating lazily 'f<-' ?

2021-09-13 Thread Leonard Mada via R-help
and call directly: 'names<-'(x, value); Leonard > > On Mon, Sep 13, 2021, 16:18 Leonard Mada <mailto:leo.m...@syonic.eu>> wrote: > > Hello, > > > I have found the evaluation: it is described in the section on > subsetting. The for

Re: [R] Evaluating lazily 'f<-' ?

2021-09-13 Thread Leonard Mada via R-help
Hello, I have found the evaluation: it is described in the section on subsetting. The forced evaluation makes sense for subsetting. On 9/13/2021 9:42 PM, Leonard Mada wrote: > > Hello Andrew, > > > I try now to understand the evaluation of the expression: > > e =

Re: [R] Evaluating lazily 'f<-' ?

2021-09-13 Thread Leonard Mada via R-help
t; > > match.which <- function (which) > match.arg(which, c("bottom", "left", "top", "right"), several.ok = TRUE) > > > padding <- function (x, which) > { >     which <- match.which(which) >     # more code > } > >

Re: [R] Evaluating lazily 'f<-' ?

2021-09-13 Thread Leonard Mada via R-help
value) > { >     which <- match.arg(which, c("bottom", "left", "top", "right"), > several.ok = TRUE) >     # code to pad to each side here > } > > Then you could use it like > > df <- data.frame(x=1:5, y = sample(1:5, 5)) > padd

Re: [R] Evaluating lazily 'f<-' ?

2021-09-13 Thread Leonard Mada via R-help
and capture the expression: "right(...)"? 2.) Unexpected 'padding<-' was also called! I did not know this. Is it feature or bug? R 4.0.4 Sincerely, Leonard On 9/13/2021 4:45 PM, Duncan Murdoch wrote: On 13/09/2021 9:38 a.m., Leonard Mada wrote: Hello, I can inc

Re: [R] Evaluating lazily 'f<-' ?

2021-09-13 Thread Leonard Mada via R-help
so depends if I can properly capture the unevaluated expression inside "right<-": 'right<-' = function(x, val) { # x is automatically evaluated when using 'f<-'! # but not when implementing as '%f%' = function(x, y); } Many thanks, Leonard

[R] Evaluating lazily 'f<-' ?

2021-09-13 Thread Leonard Mada via R-help
How can I avoid evaluation? right = function(x, val) {print("Right");}; padding = function(x) {print("Padding");}; df = data.frame(x=1:5, y = sample(1:5, 5)); ### OK '%=%' = function(x, val) {     x = substitute(x); } right(padding(df)) %=% 1; # but ugly ### Does NOT work 'right<-' = function(x

[R] Working with semantic data triplets

2010-11-08 Thread Leonard Mada
Dear R Help List, I have the following data set: eg. 1, date11, f1 1, date12, f2 1, date13, f3 [...] 2, date21, fi 2, date22, fj […] f1 – fn are various levels of a factor variable. Each ID may contain 1 to many entries. These represent basically semantic data (triplets). I want to construc

Re: [R] Categorizing Fonts using Statistical Methods

2008-05-04 Thread Leonard Mada
Hello Johannes, Johannes Hüsing wrote: Leonard Mada [Sun, May 04, 2008 at 07:26:04PM CEST]: > Dear list members, > > Every "modern" OS comes with dozens of useless fonts, so that the > current font drop-down list in most programs is overcrowded with fonts > one ne

[R] Categorizing Fonts using Statistical Methods

2008-05-04 Thread Leonard Mada
d have access to) mathlab, I am rather confined to R. Which is not bad, but I need a lot of help to accomplish this task. Any help is highly appreciated. Sincerely, Leonard Mada __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listin