[R] Package gamlss used inside foreach() and %dopar% fails to find an object

Nik Tuzov ntuzov at beacon.partek.com
Mon Mar 12 15:28:00 CET 2018


Hello Mikis:

Thanks a lot, it worked. Could you tell me what the problem was?

Regards,
Nik


----- Original Message -----
From: r-help-request at r-project.org
To: "r-help" 
Sent: Sunday, March 11, 2018 6:00:02 AM
Subject: R-help Digest, Vol 181, Issue 11

Send R-help mailing list submissions to
        r-help at r-project.org

To subscribe or unsubscribe via the World Wide Web, visit
        https://stat.ethz.ch/mailman/listinfo/r-help
or, via email, send a message with subject or body 'help' to
        r-help-request at r-project.org

You can reach the person managing the list at
        r-help-owner at r-project.org

When replying, please edit your Subject line so it is more specific
than "Re: Contents of R-help digest..."


Today's Topics:

   1. . Package gamlss used inside foreach() and %dopar% fails to
      find an object (Nik Tuzov) (Dimitrios Stasinopoulos)
   2. error message from sqldf (Ding, Yuan Chun)
   3. Re: error message from sqldf
      (=?iso-8859-1?Q?Jos=E9_Mar=EDa?= Mateos)

----------------------------------------------------------------------

Message: 1
Date: Sat, 10 Mar 2018 13:34:59 +0000
From: Dimitrios Stasinopoulos <dmh.stasinopoulos at gmail.com>
To: r-help at r-project.org
Cc: Nik ntuzov.com>
Subject: [R] . Package gamlss used inside foreach() and %dopar% fails
        to find an object (Nik Tuzov)
Message-ID:
        <424DC535-4CAF-4DD5-8BD5-EB19BF6F7247 at staff.londonmet.ac.uk>
Content-Type: text/plain; charset="utf-8"

Dear Nik 

Try the following code 


loo_predict.mu <- function(model.obj, input.data) {
  yhat <- foreach(i = 1 : nrow(input.data), .packages="gamlss", .combine = rbind) %dopar% {
    updated.model.obj <- update(model.obj, data = input.data[-i, ])
    predict(updated.model.obj, what = "mu", data = input.data[-i, ],
            newdata = input.data[i,], type = "response")
  }
  return(data.frame(result = yhat[, 1], row.names = NULL))
}

par.run <- loo_predict.mu(model3, input.processed.cut)

The predict command in this case also need the old data.

Thanks
Mikis 



Prof Dimitrios Mikis Stasinopoulos
stasinom at staff.londonmet.ac.uk




        [[alternative HTML version deleted]]




------------------------------

Message: 2
Date: Sat, 10 Mar 2018 21:30:42 +0000
From: "Ding, Yuan Chun" <ycding at coh.org>
To: "r-help at r-project.org" 
Subject: [R] error message from sqldf
Message-ID:
        coh.org>
Content-Type: text/plain; charset="utf-8"

Dear R users,

I got the following error message from running sqldf code in R.   do you know how to fix it?  I read the sqldf package instruction and did not find a solution.

Thank you,

Ding

chr10 <- sqldf("select * from manifest where CHR==10")

UCN3cpg <-  sqldf("select * from chr10 where MAPINFO between 5405573 and 5407594),
overwrite = TRUE")
Error: Table chr10 exists in database, and both overwrite and append are FALSE


>





---------------------------------------------------------------------
-SECURITY/CONFIDENTIALITY WARNING-
This message (and any attachments) are intended solely f...{{dropped:22}}




------------------------------

Message: 3
Date: Sat, 10 Mar 2018 16:53:35 -0500
From: =?iso-8859-1?Q?Jos=E9_Mar=EDa?= Mateos <chema at rinzewind.org>
To: r-help at r-project.org
Subject: Re: [R] error message from sqldf
Message-ID: <20180310215335.GD5049 at equipaje>
Content-Type: text/plain; charset="iso-8859-1"

On Sat, Mar 10, 2018 at 09:30:42PM +0000, Ding, Yuan Chun wrote:
> chr10 <- sqldf("select * from manifest where CHR==10")
> 
> UCN3cpg <-  sqldf("select * from chr10 where MAPINFO between 5405573 and 5407594),
> overwrite = TRUE")
> Error: Table chr10 exists in database, and both overwrite and append are FALSE

Could it be that `chr10` already exists when you try to run your code. 
What about rewriting it as:

chr10 <- sqldf("select * from manifest where CHR==10", overwrite = TRUE)

Also, it seems to me that the second line is not closing the quotes 
properly. Shouldn't this be correct instead?

UCN3cpg <-  sqldf("select * from chr10 where MAPINFO between 5405573 and 5407594",
                  overwrite = TRUE)

Cheers,

-- 
José María (Chema) Mateos
https://rinzewind.org/blog-es || https://rinzewind.org/blog-en




------------------------------

Subject: Digest Footer

_______________________________________________
R-help at 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-contained, reproducible code.


------------------------------

End of R-help Digest, Vol 181, Issue 11



More information about the R-help mailing list