[R] [R-pkgs] dbparser v1.0.1: DrugBank XML Database Parser
Hello,I am pleased to announce the release of dbparser v1.0.1 on CRAN https://cran.r-project.org/web/packages/dbparser/index.htmlThe new release include: * Check if drugbank database exist before parsing * Add support for international_brands and salts elements * Properly rename some features to have clear names * Reduce datasets size by getting unique rows only * Support reading zip file containing DrugBank xml database * Fix previous version CRAN Note * Improve functions documentation * Refactor unused functions * Remove Count features from drug data set * Fix several typos in documentation and code * Fix consistency issue of CLASS of Data Frames Returned by dbparser As always, contributions and bug reports are welcome on https://dainanahan.github.io/dbparser/index.html Best Regards,Mohammed Ali MSc in Applied Data Science & Big Data mohammed@edu.dsti.institute +20 01000481973 eg.linkedin.com/in/mohammedali85 [[alternative HTML version deleted]] ___ R-packages mailing list r-packa...@r-project.org https://stat.ethz.ch/mailman/listinfo/r-packages __ 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-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Why I can not get work the "tidyverse" and "corrr" libraries
; I need work on libraries "tidyverse" and "corrr". When I cal these, I am getting the following error message. What can be done? Your help is highly appreciated. Greg Error: package or namespace load failed for ‘tidyverse’ in loadNamespace(i, c(lib.loc, .libPaths()), versionCheck = vI[[i]]): namespace ‘rlang’ 0.3.0 is already loaded, but >= 0.3.1 is required In addition: Warning message: package ‘tidyverse’ was built under R version 3.5.3 [[alternative HTML version deleted]] __ 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-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Limiting the scope of RNGkind/set.seed
Elizabeth There is a package (of mine) setRNG on CRAN that may be a helpful example (code/tests/examples/vignette). Most of the package is testing designed to fail if the RNG in R is changed in a way that will affect my other package testing. Martin's function in the previous reply has most of the import parts and adds warning suppression, so you might want to consider small adjustments on a combination of the two. Just to summarize the issues, from memory: 0/ Using a preset default seed in a function's argument makes the function not random by default. If you are doing that then maybe you need to consider carefully whether the function should be using random number generation. 1/ It is good practice to use on.exit() in your function to reset things, so the state remains unaltered if your function fails. 2/ Saving the old seed does not work when it is unset, as it is by default in a new session, so you need to do something that insures it is set. 3/ You may need to save and reset not only the seed but also the RNG kind and the normal.kind, and possibly the kind for some other distributions. (setRNG does not handle other distributions.) It looks like you need to save and reset sample.kind. 4/ You should add the capability to pass all settings to your functions so that you can reproduce things when you want. 5/ I have found it useful to always pass back the settings in objects returned by functions like simulations. That way you always have a record when you discover something you want to reproduce. 6/ If parallel computing is considered then for reproducibility you need to save the number of nodes in the cluster. (I think this point is not as widely known as it should be.) No doubt I have forgotten a few things. Paul Gilbert On 4/17/19 6:00 AM, r-help-requ...@r-project.org wrote: > Date: Tue, 16 Apr 2019 19:22:34 +0200 > From: Martin Maechler > To: Elizabeth Purdom > Cc: Bert Gunter, R-help > > Subject: Re: [R] Limiting the scope of RNGkind/set.seed > Message-ID:<23734.3930.10744.126...@stat.math.ethz.ch> > Content-Type: text/plain; charset="utf-8" > >> Elizabeth Purdom >> on Tue, 16 Apr 2019 09:45:45 -0700 writes: > > Hi Bert, Thanks for your response. What you suggest is > > more or less the fix I suggested in my email (my second > > version of .rcolors). I writing more because I was > > wondering if there was a better way to work with RNG that > > would avoid doing that. It doesn’t feel very friendly for > > my package to be making changes to the user’s global > > environment, even though I am setting them back (and if it > > weren’t for the fact that setting the new R 3.6 argument > > `sample.kind=“Rounding”` creates a warning, I wouldn’t > > have even realized I was affecting the user’s settings, so > > it seems potentially hazardous that packages could be > > changing users settings without them being aware of > > it). So I was wondering if there was a way to more fully > > isolate the command. Thanks, Elizabeth > > Hi Elizabeth, > > there's actually something better -- I think -- that you can do: > > You store .Random.seed before doing an RNGkind() & set.seed() > setting, do all that, and make sure that .Random.seed is > restored when leaving your function. > > This works because the (typically quite long) .Random.seed > stores the full state of the RNG, i.e., all RNGkind() settings > *and* the result of set.seed() , calling r(n, ..) etc. > > If you additionally use on.exit() instead of manually reset > things, you have the additional advantage, that things are also > reset when your functions ends because the user interrupts its > computations, or an error happens, etc. > > So, your function would more elegantly (and robustly!) look like > > .rcolors <- function(seed = 23589) { > if(!exists(".Random.seed", envir = .GlobalEnv)) { > message("calling runif(1)"); runif(1) } > old.R.s <- .Random.seed > ## will reset everything on exiting this function: > on.exit(assign(".Random.seed", old.R.s, envir=.GlobalEnv)) > ## set seed for sample() "back compatibly": > suppressWarnings(RNGversion("3.5.0")) > set.seed(seed) > ## return random permutation of "my colors" > sample(colors()[-c(152:361)]) > } > > BTW, you can look at simulate() methods in standard R, e.g., > >stats:::simulate.lm > > to see the same method use [optionally, with slightly more sophistication] > > > Best, > Martin > > Martin Mächler > ETH Zurich, Switzerland __ 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-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Why I can not get work the "tidyverse" and "corrr" libraries
>From reading > namespace ‘rlang’ 0.3.0 is already loaded, but >= 0.3.1 is required it would seem that you need to upgrade your rlang package... On April 17, 2019 10:19:48 AM PDT, greg holly wrote: >; > >I need work on libraries "tidyverse" and "corrr". When I cal these, I >am >getting the following error message. What can be done? Your help is >highly >appreciated. > >Greg > >Error: package or namespace load failed for ‘tidyverse’ in >loadNamespace(i, >c(lib.loc, .libPaths()), versionCheck = vI[[i]]): > namespace ‘rlang’ 0.3.0 is already loaded, but >= 0.3.1 is required >In addition: Warning message: >package ‘tidyverse’ was built under R version 3.5.3 > > [[alternative HTML version deleted]] > >__ >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-guide.html >and provide commented, minimal, self-contained, reproducible code. -- Sent from my phone. Please excuse my brevity. __ 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-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Why I can not get work the "tidyverse" and "corrr" libraries
On Wed, Apr 17, 2019 at 1:06 PM Jeff Newmiller wrote: > > From reading > > > namespace ‘rlang’ 0.3.0 is already loaded, but >= 0.3.1 is required > > it would seem that you need to upgrade your rlang package... Typically this indicates you need to restart R. Hadley -- http://hadley.nz __ 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-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Limiting the scope of RNGkind/set.seed
Thanks Martin, this seems much better. All of the best, Elizabeth > On Apr 16, 2019, at 10:22 AM, Martin Maechler > wrote: > >> Elizabeth Purdom >>on Tue, 16 Apr 2019 09:45:45 -0700 writes: > >> Hi Bert, Thanks for your response. What you suggest is >> more or less the fix I suggested in my email (my second >> version of .rcolors). I writing more because I was >> wondering if there was a better way to work with RNG that >> would avoid doing that. It doesn’t feel very friendly for >> my package to be making changes to the user’s global >> environment, even though I am setting them back (and if it >> weren’t for the fact that setting the new R 3.6 argument >> `sample.kind=“Rounding”` creates a warning, I wouldn’t >> have even realized I was affecting the user’s settings, so >> it seems potentially hazardous that packages could be >> changing users settings without them being aware of >> it). So I was wondering if there was a way to more fully >> isolate the command. Thanks, Elizabeth > > Hi Elizabeth, > > there's actually something better -- I think -- that you can do: > > You store .Random.seed before doing an RNGkind() & set.seed() > setting, do all that, and make sure that .Random.seed is > restored when leaving your function. > > This works because the (typically quite long) .Random.seed > stores the full state of the RNG, i.e., all RNGkind() settings > *and* the result of set.seed() , calling r(n, ..) etc. > > If you additionally use on.exit() instead of manually reset > things, you have the additional advantage, that things are also > reset when your functions ends because the user interrupts its > computations, or an error happens, etc. > > So, your function would more elegantly (and robustly!) look like > > .rcolors <- function(seed = 23589) { >if(!exists(".Random.seed", envir = .GlobalEnv)) { >message("calling runif(1)"); runif(1) } >old.R.s <- .Random.seed >## will reset everything on exiting this function: >on.exit(assign(".Random.seed", old.R.s, envir=.GlobalEnv)) >## set seed for sample() "back compatibly": >suppressWarnings(RNGversion("3.5.0")) >set.seed(seed) >## return random permutation of "my colors" >sample(colors()[-c(152:361)]) > } > > BTW, you can look at simulate() methods in standard R, e.g., > > stats:::simulate.lm > > to see the same method use [optionally, with slightly more sophistication] > > > Best, > Martin > > Martin Mächler > ETH Zurich, Switzerland __ 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-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Problem to find the Maximum likelihood estimates of generalized normal distribution in R
First I estimated the parameters of exponentiated generalized normal distribution using the dataset (data1: generated from normal distribution). Then I used real dataset (data2) and tried to find the maximum likelihood estimates (MLE) using the AdequacyModel packages. It gives the error message (mentioned right below the code). Why does the same code estimate for first dataset (data1), but it doesn't estimate for the second dataset (data2)? Is my way of plugging the baseline distribution (normal) in generalized class of distributions F(x)= [1-(1-G(x))^beta]^gamma introduced by Cordeiro et al.(2013) in R environment right? Am I defining the cdf and pdf of an generalized normal distribution in R in right way? # First Problem library(AdequacyModel) data1 <- rnorm(100) pdf_exps <- function(par,x){ beta = par[1] gamma= par[2] mean = par[3] sd = par[4] ( beta*gamma* ((1-(1-(pnorm(x,mean,sd)))^beta)^(gamma-1)) * ((1-(pnorm(x,mean,sd)))^(beta-1)) ) * (dnorm(x,mean,sd)) } cdf_exps <- function(par,x){ beta = par[1] gamma= par[2] mean = par[3] sd = par[4] ( 1-(1-(pnorm(x,mean,sd)))^beta)^gamma } set.seed(1) result_1 = goodness.fit(pdf = pdf_exps, cdf = cdf_exps, starts = c(1,1,1,1),data = data1 , method = "BFGS", domain = c(-Inf,Inf), lim_inf = c(0,0,0,0), lim_sup = c(2,2,2,2), S = 250, prop=0.1, N=50) result_1$mle 5.688120 4.413153 1.115777 1.996108 # data2 <-c( 20.56, 20.67, 21.86, 21.88, 18.96, 21.04, 21.69, 20.62, 22.64, 19.44, 25.75, 21.20, 22.03, 25.44, 22.63, 21.86, 22.27, 21.27, 23.47, 23.19, 23.17, 24.54, 22.96, 19.76, 23.36, 22.67, 24.24, 24.21, 20.46, 20.81, 20.17, 23.06, 24.40, 23.97, 22.62, 19.16, 21.15, 21.40, 21.03, 21.77, 21.38, 21.47, 24.45, 22.63, 22.80, 23.58, 20.06, 23.01, 24.64, 18.26, 24.47, 23.99, 26.24, 20.04, 25.72, 25.64, 19.87, 23.35, 22.42, 20.42, 22.13, 25.17, 23.72, 21.28, 20.87, 19.00, 22.04, 20.12, 21.35, 28.57, 26.95, 28.13, 26.85, 25.27, 31.93, 16.75, 19.54, 20.42, 22.76, 20.12, 22.35, 19.16, 20.77, 19.37, 22.37, 17.54, 19.06, 20.30, 20.15, 25.36, 22.12, 21.25, 20.53, 17.06, 18.29, 18.37, 18.93, 17.79, 17.05, 20.31, 22.46, 23.88, 23.68, 23.15, 22.32, 24.02, 23.29, 25.11, 22.81, 26.25, 21.38, 22.52, 26.73, 23.57, 25.84, 24.06, 23.85, 25.09, 23.84, 25.31, 19.69, 26.07, 25.50, 23.69, 26.79, 25.61, 25.06, 24.93, 22.96, 20.69, 23.97, 24.64, 25.93, 23.69, 25.38, 22.68, 23.36, 22.44, 22.57, 19.81, 21.19, 20.39, 21.12, 21.89, 29.97, 27.39, 23.11, 21.75, 20.89, 22.83, 22.02, 20.07, 20.15, 21.24, 19.63, 23.58, 21.65, 25.17, 23.25, 32.52, 22.59, 30.18, 34.42, 21.86, 23.99, 24.81, 21.68, 21.04, 23.12, 20.76, 23.13, 22.35, 22.28, 23.55, 19.85, 26.51, 24.78, 33.73, 30.18, 23.31, 24.51, 25.37, 23.67, 24.28, 25.82, 21.93, 23.38, 23.07, 25.21, 23.25, 22.93, 26.86, 21.26, 25.43, 24.54, 27.79, 23.58, 27.56, 23.76, 22.01, 22.34, 21.07) set.seed(1) result_2 = goodness.fit(pdf = pdf_exps, cdf = cdf_exps, starts = c(1,1,1,1),data = data2 , method = "BFGS", domain = c(-Inf,Inf), lim_inf = c(0,0,0,0), lim_sup = c(2,2,2,2), S = 250, prop=0.1, N=50) result_2$mle Error in optim(par = starts, fn = likelihood, x = data, method = "BFGS", : non-finite finite-difference value [1] JAWAD HUSSAIN ASHRAF __ 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-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] combining data.frames with is.na & match (), two questions
Hello everyone, I'm working through this book, *Humanities Data in R* (Arnold & Tilton), and I'm just having trouble understanding this maneuver. In sum, I'm trying to combine data in two different data.frames. This data.frame is called fruitNutr Fruit Calories 1 banana 100 2 pear 100 3 mango 200 And this data.frame is called fruitData Fruit Color Shape Juice 1 apple red round 1 2 banana yellow oblong 0 3 pear green pear 0.5 4 orange orange round 1 5 kiwi green round 0 So, as you can see, these two data.frames overlap insofar as they both have banana and pear. So, what happens next is the book suggests this: fruitData$calories <- NA As a result, I've created a new column for the fruitData data.frame: Fruit Color Shape Juice Calories 1 apple red round 1N/A 2 banana yellow oblong 0N/A 3 pear green pear 0.5N/A 4 orange orange round 1N/A 5 kiwi green round 0N/A Then: > index <- match (x=fruitData$Fruit, table=fruitNutr$Fruit) > index [1]NA 1 2 NA NA > is.na(index) [1]TRUE FALSEFALSE TRUETRUE > fruitData$Calories [!is.na(index)] <- fruitNutr$Calories[index[!is.na (index)]] > fruitData Fruit Color Shape Juice Calories 1 apple red round 1N/A 2 banana yellow oblong 0 100 3 pear green pear 0.5 100 4 orange orange round 1N/A 5 kiwi green round 0N/A I get what the first part means, that first part being this: fruitData$Calories [!is.na(index)] go into the fruitData data.frame, specifically into the calories column, and only for what's true according to is.na(index). But I just literally can't understand this last part. fruitNutr$Calories[index[!is.na(index)]] Two questions. 1. I just literally don't understand how this code works. It does work, of course, but I don't know what it's doing, specifically this [index[! is.na(index)]] part. Could someone explain it to me like I'm five? I'm new at this... 2. And then: is there any other way to combine these two data.frames so that we get this same result? maybe an easier to understand method? That same result, again, is Fruit Color Shape Juice Calories 1 apple red round 1N/A 2 banana yellow oblong 0 100 3 pear green pear 0.5 100 4 orange orange round 1N/A 5 kiwi green round 0N/A Drake [[alternative HTML version deleted]] __ 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-guide.html and provide commented, minimal, self-contained, reproducible code.