Re: [R] Network issue
Hi Stephen, Thanks again for getting back to me, Ivan Krylov responded also and suggested windows binaries and I must confess I was only familiar with installing from files via the package sources (apart from the conventional install.packages method), so the solution was as simple as installing via the binaries. Thanks again, best wishes, James From: stephen sefick Sent: Wednesday 21 February 2024 12:25 To: James Powell Cc: r-help@r-project.org Subject: Re: [R] Network issue CAUTION: This email originated from outside of the organisation. Do not click links or open attachments unless you recognise the sender and know the content is safe. My suggestion is probably overkill. Sorry about that. I don't know much about windows. Have you tried posit package manager? Maybe that is not blocked? I think windows binaries are installable from there? A workaround, that I don't think I would suggest, might be RSelinium to automate the download process since it seems you have web access? Best of luck! Kindest regards, Stephen Sefick On Wed, Feb 21, 2024, 01:09 James Powell mailto:james.pow...@hse.ie>> wrote: Hi Stephen, I didn’t see this suggested previously, but yes I have made repeated attempts to gain access to CRAN via R but to no avail. Mirroring CRAN is a really good idea, but I’m not sure how to get R to recognise the local file locations when the installation files seek access to CRAN via urls. Thanks again for your help. Regards, James From: stephen sefick mailto:ssef...@gmail.com>> Sent: Wednesday 21 February 2024 00:04 To: James Powell mailto:james.pow...@hse.ie>> Cc: r-help@r-project.org<mailto:r-help@r-project.org> Subject: Re: [R] Network issue CAUTION: This email originated from outside of the organisation. Do not click links or open attachments unless you recognise the sender and know the content is safe. As stated in an earlier email, this might be better directed to your IT? You might think about mirroring CRAN locally, but this would be non-trivial. Stephen Sefick On Tue, Feb 20, 2024, 17:26 James Powell mailto:james.pow...@hse.ie>> wrote: Hi Stephen, Thanks very much for getting back to me. My problem is described below. Any help would be greatly appreciated. Thanks, James Hi, Sorry for bothering you because I know that your time is voluntary, but I would really appreciate some help. I work in a hospital in part of Ireland’s national health service, a service which was struck by a massive cyber attack a couple of years ago. Since then their security has been very tight, and I can’t access the internet through my R or R Studio. To install packages I need to download the files through a browser (Chrome by default) and install them from the files, which is very tedious when you consider the amount of dependencies, but I’m happy to do it. This was working fine until yesterday when I had error messages trying to install some packages. See enclosed “S2” for example. It looks like it is trying to download a file as part of the installation, but of course can’t. If you could help with this I would be very grateful. Other examples are jqr, protolite, curl. I came across a different error message when trying to install openssl, although the issue may be the same. For this package it says Warning in file(name, "wb") : cannot open file 'openssl/tests/keys/message.rsa.crypt': Permission denied Error in file(name, "wb") : cannot open the connection I have tried going into the archive of these packages and installing older versions, but no luck with those either. I hope you can help. Best wishes, James From: stephen sefick mailto:ssef...@gmail.com>> Sent: Tuesday 20 February 2024 19:43 To: James Powell mailto:james.pow...@hse.ie>> Cc: r-help@r-project.org<mailto:r-help@r-project.org> Subject: Re: [R] Network issue CAUTION: This email originated from outside of the organisation. Do not click links or open attachments unless you recognise the sender and know the content is safe. Maybe I missed the rest of the post? You are more likely to get help with your problems if you create a minimal reproducible example. Kindest regards, Stephen Sefick On Tue, Feb 20, 2024, 12:24 James Powell mailto:james.pow...@hse.ie>> wrote: Need information and advice on COVID-19? Go to www.hse.ie/coronavirus<https://scanner.topsec.com/?d=2120=show=https%3A%2F%2Fwww.hse.ie%2Fcoronavirus=ceec0a7bd0b1f730294db0447d2a0c1ad2741351> "Tá an fhaisnéis sa ríomhphost seo (ceangaltáin san áireamh) faoi rún. Baineann sé leis an té ar seoladh chuige amháin agus tá sé ar intinn go bhfaighfidh siadsan amháin é agus gurb iadsan amháin a dhéanfaidh breithniú air. Más rud é nach tusa an duine ar leis é, tá cosc iomlán ar aon fhaisnéis atá ann, a úsáid, a chraobhscaoileadh, a scaipeadh, a nochtadh, a fhoilsiú, ná a chóipeáil . Seains gurb iad tuairimí pearsanta an úd
Re: [R] Network issue
Hi Stephen, Thanks very much for getting back to me. My problem is described below. Any help would be greatly appreciated. Thanks, James Hi, Sorry for bothering you because I know that your time is voluntary, but I would really appreciate some help. I work in a hospital in part of Ireland’s national health service, a service which was struck by a massive cyber attack a couple of years ago. Since then their security has been very tight, and I can’t access the internet through my R or R Studio. To install packages I need to download the files through a browser (Chrome by default) and install them from the files, which is very tedious when you consider the amount of dependencies, but I’m happy to do it. This was working fine until yesterday when I had error messages trying to install some packages. See enclosed “S2” for example. It looks like it is trying to download a file as part of the installation, but of course can’t. If you could help with this I would be very grateful. Other examples are jqr, protolite, curl. I came across a different error message when trying to install openssl, although the issue may be the same. For this package it says Warning in file(name, "wb") : cannot open file 'openssl/tests/keys/message.rsa.crypt': Permission denied Error in file(name, "wb") : cannot open the connection I have tried going into the archive of these packages and installing older versions, but no luck with those either. I hope you can help. Best wishes, James From: stephen sefick Sent: Tuesday 20 February 2024 19:43 To: James Powell Cc: r-help@r-project.org Subject: Re: [R] Network issue CAUTION: This email originated from outside of the organisation. Do not click links or open attachments unless you recognise the sender and know the content is safe. Maybe I missed the rest of the post? You are more likely to get help with your problems if you create a minimal reproducible example. Kindest regards, Stephen Sefick On Tue, Feb 20, 2024, 12:24 James Powell mailto:james.pow...@hse.ie>> wrote: Need information and advice on COVID-19? Go to www.hse.ie/coronavirus<https://www.hse.ie/coronavirus> "Tá an fhaisnéis sa ríomhphost seo (ceangaltáin san áireamh) faoi rún. Baineann sé leis an té ar seoladh chuige amháin agus tá sé ar intinn go bhfaighfidh siadsan amháin é agus gurb iadsan amháin a dhéanfaidh breithniú air. Más rud é nach tusa an duine ar leis é, tá cosc iomlán ar aon fhaisnéis atá ann, a úsáid, a chraobhscaoileadh, a scaipeadh, a nochtadh, a fhoilsiú, ná a chóipeáil . Seains gurb iad tuairimí pearsanta an údar atá san ríomhphost agus nach tuairimí FSS iad. Má fuair tú an ríomhphost seo trí dhearmad, bheadh muid buíoch dá gcuirfeá in iúil don Deasc Seirbhísí ECT ar an nguthán ag +353 818 300300 nó ar an ríomhphost chuig service.d...@hse.ie<mailto:service.d...@hse.ie> agus ansin glan an ríomhphost seo ded' chóras." "Information in this email (including attachments) is confidential. It is intended for receipt and consideration only by the intended recipient. If you are not an addressee or intended recipient, any use, dissemination, distribution, disclosure, publication or copying of information contained in this email is strictly prohibited. Opinions expressed in this email may be personal to the author and are not necessarily the opinions of the HSE. If this email has been received by you in error we would be grateful if you could immediately notify the ICT Service Desk by telephone at +353 818 300300 or by email to service.d...@hse.ie<mailto:service.d...@hse.ie> and thereafter delete this e-mail from your system" R version 4.3.1 (2023-06-16 ucrt) -- "Beagle Scouts" Copyright (C) 2023 The R Foundation for Statistical Computing Platform: x86_64-w64-mingw32/x64 (64-bit) R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. Natural language support but running in an English locale R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. > utils:::menuInstallPkgs() --- Please select a CRAN mirror for use in this session --- Warning: failed to download mirrors file (cannot open URL 'https://cran.r-project.org/CRAN_mirrors.csv'); using local file 'C:/PROGRA~1/R/R-43~1.1/doc/CRAN_mirrors.csv' Error in contrib.url(repos, type) : trying to use CRAN without setting a mirror In addition: Warning message: In download.file(url, destfile = f, quiet = TRUE) : URL 'https://cran.r-project.org/CRAN_mirrors.csv': status was 'SSL connect error' > util
Re: [R] Network issue
Hi Ivan, Thanks very much for your response, I'll definitely give that a go. Best wishes, James -Original Message- From: Ivan Krylov Sent: Wednesday 21 February 2024 10:38 To: James Powell Cc: r-help@r-project.org Subject: Re: [R] Network issue CAUTION: This email originated from outside of the organisation. Do not click links or open attachments unless you recognise the sender and know the content is safe. В Wed, 21 Feb 2024 06:09:51 + James Powell пишет: > This was working fine until yesterday when I had error messages trying > to install some packages. See enclosed “S2” for example. It looks like > it is trying to download a file as part of the installation, but of > course can’t. Since you're on Windows and running R-4.3, it should be easier to download and install the binary package, https://scanner.topsec.com/?d=2120=show=https%3A%2F%2Fcran.r-project.org%2Fbin%2Fwindows%2Fcontrib%2F4.3%2Fs2_1.1.6.zip=40c0076a9193368805cc3e637e09c680a3e72586. Installing this package from source involves downloading a few binaries anyway. You could try unpacking the source package, downloading OpenSSL 1.1.1k binaries from https://scanner.topsec.com/?d=2120=show=https%3A%2F%2Fgithub.com%2Frwinlib%2Fopenssl%2Ftree%2Fv1.1.1k=10f7c80b5f4e5dcf0d0f3bd203a067fec29f43a4 into a new subdirectory called windows/ in the package root, just like the https://scanner.topsec.com/?d=2120=show=https%3A%2F%2Fgithub.com%2Fr-spatial%2Fs2%2Fblob%2Fmain%2Ftools%2Fwinlibs.R=fd500ed04f0fa1a24bbd7e7e50df6aa7f4bb654c script tries to do during the installation, then installing the resulting directory as if it was a source package. -- Best regards, Ivan Need information and advice on COVID-19? Go to www.hse.ie/coronavirus<https://www.hse.ie/coronavirus> "Tá an fhaisnéis sa ríomhphost seo (ceangaltáin san áireamh) faoi rún. Baineann sé leis an té ar seoladh chuige amháin agus tá sé ar intinn go bhfaighfidh siadsan amháin é agus gurb iadsan amháin a dhéanfaidh breithniú air. Más rud é nach tusa an duine ar leis é, tá cosc iomlán ar aon fhaisnéis atá ann, a úsáid, a chraobhscaoileadh, a scaipeadh, a nochtadh, a fhoilsiú, ná a chóipeáil . Seains gurb iad tuairimí pearsanta an údar atá san ríomhphost agus nach tuairimí FSS iad. Má fuair tú an ríomhphost seo trí dhearmad, bheadh muid buíoch dá gcuirfeá in iúil don Deasc Seirbhísí ECT ar an nguthán ag +353 818 300300 nó ar an ríomhphost chuig service.d...@hse.ie<mailto:service.d...@hse.ie> agus ansin glan an ríomhphost seo ded' chóras." "Information in this email (including attachments) is confidential. It is intended for receipt and consideration only by the intended recipient. If you are not an addressee or intended recipient, any use, dissemination, distribution, disclosure, publication or copying of information contained in this email is strictly prohibited. Opinions expressed in this email may be personal to the author and are not necessarily the opinions of the HSE. If this email has been received by you in error we would be grateful if you could immediately notify the ICT Service Desk by telephone at +353 818 300300 or by email to service.d...@hse.ie<mailto:service.d...@hse.ie> and thereafter delete this e-mail from your system" __ 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] Network issue
Hi Stephen, I didn’t see this suggested previously, but yes I have made repeated attempts to gain access to CRAN via R but to no avail. Mirroring CRAN is a really good idea, but I’m not sure how to get R to recognise the local file locations when the installation files seek access to CRAN via urls. Thanks again for your help. Regards, James From: stephen sefick Sent: Wednesday 21 February 2024 00:04 To: James Powell Cc: r-help@r-project.org Subject: Re: [R] Network issue CAUTION: This email originated from outside of the organisation. Do not click links or open attachments unless you recognise the sender and know the content is safe. As stated in an earlier email, this might be better directed to your IT? You might think about mirroring CRAN locally, but this would be non-trivial. Stephen Sefick On Tue, Feb 20, 2024, 17:26 James Powell mailto:james.pow...@hse.ie>> wrote: Hi Stephen, Thanks very much for getting back to me. My problem is described below. Any help would be greatly appreciated. Thanks, James Hi, Sorry for bothering you because I know that your time is voluntary, but I would really appreciate some help. I work in a hospital in part of Ireland’s national health service, a service which was struck by a massive cyber attack a couple of years ago. Since then their security has been very tight, and I can’t access the internet through my R or R Studio. To install packages I need to download the files through a browser (Chrome by default) and install them from the files, which is very tedious when you consider the amount of dependencies, but I’m happy to do it. This was working fine until yesterday when I had error messages trying to install some packages. See enclosed “S2” for example. It looks like it is trying to download a file as part of the installation, but of course can’t. If you could help with this I would be very grateful. Other examples are jqr, protolite, curl. I came across a different error message when trying to install openssl, although the issue may be the same. For this package it says Warning in file(name, "wb") : cannot open file 'openssl/tests/keys/message.rsa.crypt': Permission denied Error in file(name, "wb") : cannot open the connection I have tried going into the archive of these packages and installing older versions, but no luck with those either. I hope you can help. Best wishes, James From: stephen sefick mailto:ssef...@gmail.com>> Sent: Tuesday 20 February 2024 19:43 To: James Powell mailto:james.pow...@hse.ie>> Cc: r-help@r-project.org<mailto:r-help@r-project.org> Subject: Re: [R] Network issue CAUTION: This email originated from outside of the organisation. Do not click links or open attachments unless you recognise the sender and know the content is safe. Maybe I missed the rest of the post? You are more likely to get help with your problems if you create a minimal reproducible example. Kindest regards, Stephen Sefick On Tue, Feb 20, 2024, 12:24 James Powell mailto:james.pow...@hse.ie>> wrote: Need information and advice on COVID-19? Go to www.hse.ie/coronavirus<https://scanner.topsec.com/?d=2120=show=https%3A%2F%2Fwww.hse.ie%2Fcoronavirus=ceec0a7bd0b1f730294db0447d2a0c1ad2741351> "Tá an fhaisnéis sa ríomhphost seo (ceangaltáin san áireamh) faoi rún. Baineann sé leis an té ar seoladh chuige amháin agus tá sé ar intinn go bhfaighfidh siadsan amháin é agus gurb iadsan amháin a dhéanfaidh breithniú air. Más rud é nach tusa an duine ar leis é, tá cosc iomlán ar aon fhaisnéis atá ann, a úsáid, a chraobhscaoileadh, a scaipeadh, a nochtadh, a fhoilsiú, ná a chóipeáil . Seains gurb iad tuairimí pearsanta an údar atá san ríomhphost agus nach tuairimí FSS iad. Má fuair tú an ríomhphost seo trí dhearmad, bheadh muid buíoch dá gcuirfeá in iúil don Deasc Seirbhísí ECT ar an nguthán ag +353 818 300300 nó ar an ríomhphost chuig service.d...@hse.ie<mailto:service.d...@hse.ie> agus ansin glan an ríomhphost seo ded' chóras." "Information in this email (including attachments) is confidential. It is intended for receipt and consideration only by the intended recipient. If you are not an addressee or intended recipient, any use, dissemination, distribution, disclosure, publication or copying of information contained in this email is strictly prohibited. Opinions expressed in this email may be personal to the author and are not necessarily the opinions of the HSE. If this email has been received by you in error we would be grateful if you could immediately notify the ICT Service Desk by telephone at +353 818 300300 or by email to service.d...@hse.ie<mailto:service.d...@hse.ie> and thereafter delete this e-mail from your system" Need information and advice on COVID-19? Go to www.hse.ie/coronavirus<https://www.hse.ie/coronavirus> __
[R] Network issue
R version 4.3.1 (2023-06-16 ucrt) -- "Beagle Scouts" Copyright (C) 2023 The R Foundation for Statistical Computing Platform: x86_64-w64-mingw32/x64 (64-bit) R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. Natural language support but running in an English locale R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. > utils:::menuInstallPkgs() --- Please select a CRAN mirror for use in this session --- Warning: failed to download mirrors file (cannot open URL 'https://cran.r-project.org/CRAN_mirrors.csv'); using local file 'C:/PROGRA~1/R/R-43~1.1/doc/CRAN_mirrors.csv' Error in contrib.url(repos, type) : trying to use CRAN without setting a mirror In addition: Warning message: In download.file(url, destfile = f, quiet = TRUE) : URL 'https://cran.r-project.org/CRAN_mirrors.csv': status was 'SSL connect error' > utils:::menuInstallLocal() Warning in file(name, "wb") : cannot open file 'openssl/tests/keys/message.rsa.crypt': Permission denied Error in file(name, "wb") : cannot open the connection Warning message: In install.packages(files[tarballs], .libPaths()[1L], repos = NULL, : installation of package ‘C:/Users/jpowell/DOWNLO~1/openssl_2.1.1 (1).tar.gz’ had non-zero exit status > utils:::menuInstallLocal() * installing *source* package 's2' ... ** package 's2' successfully unpacked and MD5 sums checked ** using staged installation ** libs using C compiler: 'gcc.exe (GCC) 12.2.0' using C++ compiler: 'G__~1.EXE (GCC) 12.2.0' using C++11 g++ -std=gnu++11 -I"C:/PROGRA~1/R/R-43~1.1/include" -DNDEBUG -DS2_USE_EXACTFLOAT -D_USE_MATH_DEFINES -DNDEBUG -DIS_LITTLE_ENDIAN -DOMIT_STRPTIME -I../windows/openssl-1.1.1k/include -I../src -I'C:/Users/jpowell/AppData/Local/R/win-library/4.3/Rcpp/include' -I'C:/Users/jpowell/AppData/Local/R/win-library/4.3/wk/include' -I"C:/rtools43/x86_64-w64-mingw32.static.posix/include" -O2 -Wall -mfpmath=sse -msse2 -mstackrealign -c RcppExports.cpp -o RcppExports.o g++ -std=gnu++11 -I"C:/PROGRA~1/R/R-43~1.1/include" -DNDEBUG -DS2_USE_EXACTFLOAT -D_USE_MATH_DEFINES -DNDEBUG -DIS_LITTLE_ENDIAN -DOMIT_STRPTIME -I../windows/openssl-1.1.1k/include -I../src -I'C:/Users/jpowell/AppData/Local/R/win-library/4.3/Rcpp/include' -I'C:/Users/jpowell/AppData/Local/R/win-library/4.3/wk/include' -I"C:/rtools43/x86_64-w64-mingw32.static.posix/include" -O2 -Wall -mfpmath=sse -msse2 -mstackrealign -c cpp-compat.cpp -o cpp-compat.o g++ -std=gnu++11 -I"C:/PROGRA~1/R/R-43~1.1/include" -DNDEBUG -DS2_USE_EXACTFLOAT -D_USE_MATH_DEFINES -DNDEBUG -DIS_LITTLE_ENDIAN -DOMIT_STRPTIME -I../windows/openssl-1.1.1k/include -I../src -I'C:/Users/jpowell/AppData/Local/R/win-library/4.3/Rcpp/include' -I'C:/Users/jpowell/AppData/Local/R/win-library/4.3/wk/include' -I"C:/rtools43/x86_64-w64-mingw32.static.posix/include" -O2 -Wall -mfpmath=sse -msse2 -mstackrealign -c init.cpp -o init.o g+ In file included from ../src/s2/s2cap.h:26, from ../src/s2/s2convex_hull_query.h:25, from s2geography/accessors-geog.h:4, from s2geography.h:4, from geography.h:7, from geography-operator.h:7, from s2-accessors.cpp:2: ../src/s2/encoded_uint_vector.h: In function 'void s2coding::EncodeUintWithLength(T, int, Encoder*)': ../src/s2/base/logging.h:169:47: warning: comparison of integer expressions of different signedness: 'size_t' {aka 'long long unsigned int'} and 'int' [-Wsign-compare] 169 | #define S2_DCHECK_GE(val1, val2) S2_DCHECK_OP(>=, val1, val2) | ^ ../src/s2/base/logging.h:151:22: note: in definition of macro 'S2_DCHECK' 151 | while (false && (condition)) S2NullStream() | ^ ../src/s2/base/logging.h:169:34: note: in expansion of macro 'S2_DCHECK_OP' 169 | #define S2_DCHECK_GE(val1, val2) S2_DCHECK_OP(>=, val1, val2) | ^~~~ ../src/s2/encoded_uint_vector.h:134:3: note: in expansion of macro 'S2_DCHECK_GE' 134 | S2_DCHECK_GE(encoder->avail(), length); | ^~~~ ../src/s2/encoded_uint_vector.h: In instantiation of 'T s2coding::EncodedUintVector::operator[](int) const [with T = long long unsigned int]': ../src/s2/encoded_string_vector.h:146:47: required from here ../src/s2/encoded_uint_vector.h:246:25: warning: comparison of integer expressions of different signedness: 'int' and 'const uint32' {aka 'const unsigned int'} [-Wsign-compare] 246 | S2_DCHECK(i >= 0 && i < size_); | ~~^~~
Re: [ESS] emacs theme for polymode with noweb files
I personally like Dracula mode, although Nord seems pretty nice as well. -Original Message- From: ESS-help On Behalf Of LaurentEss via ESS-help Sent: Sunday, December 3, 2023 5:48 PM To: ess-help@r-project.org Subject: [ESS] emacs theme for polymode with noweb files Dear ESS-list, I tried many dark color themes to do literate programming with polymode (.rnw file) but there are always some drawbacks : the color of the beginning and the end of the chunks (<<>>= and @) are unreadable, the color of the text when I want to see the available buffers (C-x C-b) is unreadable, etc... May you please tell me the name of a color theme which works fine with polymode for noweb files ? I tried to find an answer on the web without success. Thank you Best regards Laurent __ ESS-help@r-project.org mailing list https://urldefense.com/v3/__https://stat.ethz.ch/mailman/listinfo/ess-help__;!!K-Hz7m0Vt54!gWi-4Lf2EFA200jJeoyljWW_zLsT8fkksrjlPXcyVPFURleqdeRFHJ_N-cul_9WQjYfsrmp8F4D7fPjzwNhhnyDud3g$ __ ESS-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/ess-help
Re: [R] Different TFIDF settings in test set prevent testing model
Thank you Bert and Ivan, I was building the SVM model in hopes of applying it to future cases and hoped that the model would be able to deal with new words it hadn't encountered during training. But I tried Bert's suggestion by converting all of the data to tokens, creating a DTM, transforming the whole thing with TFI DF, and then separating it 75%/25%. But when I began to train the SVM on the training data, R said it needed 26GB for a vector and crashed. I tried again, it crashed again.I don't know why this would happen. I'd just trained 4 SVM models using my previous method without any memory trouble on my 8GB CPU.I unsuccessfully tried to remove the new words from the new test data. Should I try that? Is there a way to stop my system from crashing with the new method? Thank you for any ideas. Here is the code I used when I separated the data after converting to tokens and applying TFI DF: url <- "D:/test/M2.csv" data <- read_csv(url) text_corpus <- Corpus(VectorSource(data$Text)) tokenize_document <- function(doc) { doc_tokens <- unlist(tokenize_words(doc)) doc_bigrams <- unlist(tokenize_ngrams(doc, n = 2)) doc_trigrams <- unlist(tokenize_ngrams(doc, n = 3)) all_tokens <- c(doc_tokens, doc_bigrams, doc_trigrams) return(all_tokens) } all_tokens <- lapply(text_corpus, tokenize_document) text_dtm <- DocumentTermMatrix(Corpus(VectorSource(all_tokens))) text_tfidf <- weightTfIdf(text_dtm) processed_data <- data.frame(M2 = data$M2, text_tfidf = as.matrix(text_tfidf)) indexes <- createDataPartition(processed_data$M2, p = 0.75, list = FALSE) trainData <- processed_data[indexes,] testData <- processed_data[-indexes,] ctrl <- trainControl(method = "repeatedcv", number = 5, repeats = 2, classProbs = TRUE) model_svmRadial <- train(M2 ~ ., data = trainData, method = "svmRadial", trControl = ctrl) ____ From: Ivan Krylov Sent: Saturday, August 12, 2023 12:49 AM To: James C Schopf Cc: r-help@r-project.org Subject: Re: [R] Different TFIDF settings in test set prevent testing model � Fri, 11 Aug 2023 10:20:27 + James C Schopf �: > > train_text_dtm <- > > DocumentTermMatrix(Corpus(VectorSource(all_train_tokens))) > > test_text_dtm <- > > DocumentTermMatrix(Corpus(VectorSource(all_test_tokens))) I understand the need to prepare the test dataset separately (e.g. in order to be able to work with text that don't exist at the time when model is trained), but since the model has no representation for tokens it (well, the tokeniser) hasn't seen during the training process, you have to ensure that test_text_dtm references exactly the same tokens as train_text_dtm, in the same order of the columns. Also, it probably makes sense to reuse the term frequency learned on the training document set; otherwise you may be importance-weighting different tokens than ones your SVM has learned as important if your test set has a significantly different distribution from that of the training set. Bert is probably right: with the API given by the tm package, it's seems easiest to tokenise and weight document-term matrices first, then split them into the train and test subsets. It may be worth asking the maintainer about applying previously "learned" transformations to new corpora. -- Best regards, Ivan [[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.
[R] Different TFIDF settings in test set prevent testing model
Hello, I'd be very grateful for your help. I randomly separated a .csv file with 1287 documents 75%/25% into 2 csv files, one for training an algorithm and the other for testing the algorithm. I applied similar preprocessing, including TFIDF transformation, to both sets, but R won't let me make predictions on the test set due to a different TFIDF matrix. I get the error message: Error: variable 'text_tfidf' was fitted with type "nmatrix.67503" but type "nmatrix.27118" was supplied I'd greatly appreciate a suggestion to overcome this problem. Thanks! Here's my R codes: > library(tidyverse) > library(tidytext) > library(caret) > library(kernlab) > library(tokenizers) > library(tm) > library(e1071) ***LOAD TRAINING SET/959 rows with text in column1 and yes/no in column2 (labelled M2) > url <- "D:/test/M2_75.csv" > d <- read_csv(url) ***CREATE TEXT CORPUS FROM TEXT COLUMN > train_text_corpus <- Corpus(VectorSource(d$Text)) ***DEFINE TOKENS FOR EACH DOCUMENT IN CORPUS AND COMBINE THEM > tokenize_document <- function(doc) { + doc_tokens <- unlist(tokenize_words(doc)) + doc_bigrams <- unlist(tokenize_ngrams(doc, n = 2)) + doc_trigrams <- unlist(tokenize_ngrams(doc, n = 3)) + all_tokens <- c(doc_tokens, doc_bigrams, doc_trigrams) + return(all_tokens) + } ***APPLY TOKENS TO DOCUMENTS > all_train_tokens <- lapply(train_text_corpus, tokenize_document) ***CREATE A DTM FROM THE TOKENS > train_text_dtm <- DocumentTermMatrix(Corpus(VectorSource(all_train_tokens))) ***TRANSFORM THE DTM INTO A TF-IDF MATRIX > train_text_tfidf <- weightTfIdf(train_text_dtm) ***CREATE A NEW DATA FRAME WITH M2 COLUMN FROM ORIGINAL DATA > trainData <- data.frame(M2 = d$M2) ***ADD NEW TFIDF transformed TEXT COLUMN NEXT TO DATA FRAME > trainData$text_tfidf <- I(as.matrix(train_text_tfidf)) ***DEFINE THE ML MODEL > ctrl <- trainControl(method = "repeatedcv", number = 5, repeats = 2, > classProbs = TRUE) ***TRAIN SVM > model_svmRadial <- train(M2 ~ ., data = trainData, method = "svmRadial", > trControl = ctrl) ***SAVE SVM > saveRDS(model_svmRadial, file = "D:/SML/model_M23_svmRadial_UP.RDS") R code on my test set, which didn't work at last step: ***LOAD TEST SET/ 309 rows with text in column1 and yes/no in column2 (labelled M2) > url <- "D:/test/M2_25.csv" > d <- read_csv(url) ***CREATE TEXT CORPUS FROM TEXT COLUMN > test_text_corpus <- Corpus(VectorSource(d$Text)) ***DEFINE TOKENS FOR EACH DOCUMENT IN CORPUS AND COMBINE THEM > tokenize_document <- function(doc) { doc_tokens <- unlist(tokenize_words(doc)) doc_bigrams <- unlist(tokenize_ngrams(doc, n = 2)) doc_trigrams <- unlist(tokenize_ngrams(doc, n = 3)) all_tokens <- c(doc_tokens, doc_bigrams, doc_trigrams) return(all_tokens) } ***APPLY TOKEN TO DOCUMENTS > all_test_tokens <- lapply(test_text_corpus, tokenize_document) ***CREATE A DTM FROM THE TOKENS > test_text_dtm <- DocumentTermMatrix(Corpus(VectorSource(all_test_tokens))) ***TRANSFORM THE DTM INTO A TF-IDF MATRIX > test_text_tfidf <- weightTfIdf(test_text_dtm) ***CREATE A NEW DATA WITH M2 COLUMN FROM ORIGINAL TEST DATA > testData <- data.frame(M2 = d$M2) ***ADD NEW TFIDF transformed TEXT COLUMN NEXT TO TEST DATA > testData$text_tfidf <- I(as.matrix(test_text_tfidf)) ***LOAD OLD MODEL model_svmRadial <- readRDS("D:/SML/model_M2_75_svmRadial.RDS") ***MAKE PREDICTIONS predictions <- predict(model_svmRadial, newdata = testData) This last line produces the error message: Error: variable 'text_tfidf' was fitted with type "nmatrix.67503" but type "nmatrix.27118" was supplied Please help. Thanks! [[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.
[R] Help sourcing datasets (.csv)
Dear Sir or Madam I’m trying to compile a collection of datasets that require use of the following hypothesis tests. Are there datasets within the R library that I can get access to? Kind regards James Carrigan Hypothesis Testing t.test(X,Y) — performs a two sample t-test between X and Y t.test(X,Y,paired=TRUE) — performs a paired t-test between X and Y prop.test(x = c(a, b), n = c(n1, n2)) — performs a 2-sample test for equality of proportions with continuity correction Sent from my iPad Sent from my iPhone __ 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] useR 2023 regional events
With the support of the R Foundation Conference Committee, we are happy to announce the promotion of regional R events to connect our R community and bridge us till useR! 2024. On July 21st we hold an event in Basel, with all ticket sales for the Basel event being directly donated to the R Foundation. Similar events are being planned in Shanghai and San Francisco this summer. Basel event link (call for abstracts is currently open): https://user-regional-2023.gitlab.io/basel/ We also wanted to help promote events beyond those organised in collaboration with the R Foundation and R User Group (RUGs), so are hosting this dashboard of R events this summer which will also include the Shanghai and San Francisco events when they are launched: https://user-regional-2023.gitlab.io/user-regional-2023.io/ [[alternative HTML version deleted]] ___ r-annou...@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-announce __ 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] Install Rmpi on Linux on a HPC
Hi, Recently, I have had a hard time installing and running the package on an HPC. The HPC sysadmin installed Rmpi package without any error. However, when he tried a simple R script with only one line: library(Rmpi) the job caused "Segmentation Fault" error. Currently, we have no clue to solve this problem. I am writing this email to ask for help. System info uname -a Linux ito-1 3.10.0-514.26.2.el7.x86_64 #1 SMP Fri Jun 30 05:26:04 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux Thank you Best regards -- --- Li [[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.
[R] pseudoreplication
Greetings R Community The ASReml-R package will analyze data from experiments with pseudoreplications. Dealing with Pseudo-Replication in Linear Mixed Models https://www.vsni.co.uk/case-studies/dealing-with-pseudo-replication-in-linear-mixed-models Will the ‘lme4’ package return an equivalent analysis of data from experiments with pseudoreplications? Thank you for your assistance. [[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.
[R] Replacing certain rows with values from a different column
I have two columns in a larger data set that list countries in one column and, in some cases, individual provinces within a country or oversea territories in another. I have country population in a second data set that I’m planning to use to calculate per capita rates in the first data set. My issue: I need to match my two data sets. Here are some examples: First data set: Province <- c("Australian Capital Territory", "New South Wales", "Northern Territory", "Queensland", "South Australia", "Tasmania", "Victoria", "Western Australia", "", "", "", "Faroe Islands", "Greenland") Country <- c("Australia", "Australia", "Australia", "Australia", "Australia", "Australia", "Australia", "Australia", "Austria", "Azerbaijan", "Denmark", "Denmark", "Denmark") firstdf <- data.frame(Province, Country) Second data set: Country <- c("Australia", "Austria", "Azerbaijan", "Denmark", "Faroe Islands", "Greenland") seconddf <- data.frame(Country) In this example, I need to aggregate sum Australia while keeping Faroe Islands and Greenland separate from Denmark. What I’d like to do is create a column that looks like this: firstdf$nation <- c("Australia", "Australia", "Australia", "Australia", "Australia", "Australia", "Australia", "Australia", "Austria", "Azerbaijan", "Denmark", “Faroe Islands", “Greenland”) Is there a way to do this or am I stuck doing this by hand? Thanks for any help on this vexing issue. Jim Milks [[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.
[R] calculating area of ellipse
In doing meta-analysis of diagnostic accuracy I produce ellipses of confidence and prediction intervals in two dimensions. How can I calculate the area of the ellipse in ggplot2 or base R? thank you James Meyer __ 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] COVID-19 datasets...
Sure. COVID-19 Data Repository by the Center for Systems Science and Engineering (CSSE) at Johns Hopkins University is available here: https://github.com/CSSEGISandData/COVID-19 All in csv fiormat. > On May 4, 2020, at 11:31 AM, Bernard McGarvey > wrote: > > Just curious does anyone know of a website that has data available in a > format that R can download and analyze? > > Thanks > > > Bernard McGarvey > > > Director, Fort Myers Beach Lions Foundation, Inc. > > > Retired (Lilly Engineering Fellow). > > __ > 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. > James Spottiswoode Applied Mathematics & Statistics (310) 270 6220 jamesspottiswoode Skype ja...@jsasoc.com [[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.
[R] How to parallelize a process called by a socket connection
Hi R Experts, I’m using R version 3.4.3 running under Linux on an AWS EC2 instance. I have an R code listening on a port for a socket connection which passes incoming data to a function the results of which are then passed back to the calling machine. Here’s the function that listens for a socket connection: # define server function server <- function() { while(TRUE){ con <- socketConnection(host="localhost", port = server_port, blocking=TRUE, server=TRUE, open="r+", timeout = 1) data <- readLines(con, 1L, skipNul = T, ok = T) response <- check(data) if (!is.null(response)) writeLines(response, con) } } The server function expects to receive a character string which is then passed to the function check(). check() is a large, complex routine which does text analysis and many other things and returns a JSON string to be passed back to the calling machine. This all works perfectly except that while check() spends ~50ms doing its stuff no more requests can be received and processed. Therefore if a new request comes in sooner than ~50ms after the last one, it is not processed. I would therefore like to parallelize this so that the box can be running more than one check() process simulatanously. I’m familar with several of the paralyzing R packages but I cannot see how to integrate them with the socket connection side of things. Currently I have a kludge which is a round-robin approach to solving the problem. I have 4 versions of the whole R code listening on 4 different ports, say P1, P2, P3, P4, and the calling machine issues calls in sequence to ports P1,P2,P3,P4,P1… etc. This mitigates, but doesn’t solve, the problem. Any advice would be greatly appreciated! Thanks. James __ 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] File names for mac newby
OSX is based on BSD UNIX so paths use the forward slash as separator, e.g. temps <- read.table("c:/Users/DFP/Documents/ah/house/HouseTemps.txt",header=T,row.names=1) Best James > On Jan 21, 2020, at 9:20 AM, David wrote: > > I moved to a mac a few months ago after years in windows, and I'm still > learning basics. I'm wanting to create a data frame based on a text file > called HouseTemps.txt. That's a file within one called house which is within > one called ah. That may further be in one called Documents. I tried > various lines like: > > temps <- > read.table("c:\\Users\\DFP\\Documents\\ah\\house\\HouseTemps.txt",header=T,row.names=1) > > based on my windows DOS experience, but nothing I try works. So my question > is, what do complete file names look like in a mac? > > I tried Apple support, but they couldn't help me with R. > > __ > 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. > [[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.
[R] R package for meta-analysis from z scores
Hello, I have a set of Z scores from an N=2 studies and I need to run a meta-analysis across the two Z scores for many N variables. I do not have effect sizes and SEs. I realize there are many different meta analysis packages in R, but I only have Z scores and it seems to me this is limiting. I am using the metap package because this very conveniently accepts directly p values which I can get from my Z scores. I have applied what is called in metap package the sumlog Fisher’s method Chi square (2 df). I have three questions: 1. Is this the same as a fixed effect meta-analysis without weights? 2. Is there any way to do a random effects meta-analysis starting only with Z scores? 3. Is there a way to get the I2 heterogeneity across studies from this or from other packages? It looks like I need the estimates for this. Is there another package that can easily get this using as input Z scores or P values? Data library(metap) zscores = cbind(c(4, 2, 0.1),c(5, 2.5, 0.1)) pvalues = apply(zscores, 1:2, function(x) 2*(pnorm( abs(x) , lower.tail=F))) meta = apply(pvalues, MARGIN=1, FUN=sumlog) Thank you much [[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] Global curve fitting/shared parameters with nls() alternatives
Dear Bert Thanks for getting back to me. Yes that is exactly the sort of problem I am trying to solve. I am aware of the option of hard coding the experimental groups as you suggested, but was hoping for an easy out of the box approach as I have many groups! Thanks James On Tue, 5 Nov 2019 at 20:28, Bert Gunter wrote: > A simplified example of what you wish to do might help to clarify here. > > Here's my guess. Feel free to dismiss if I'm off base. > > Suppose your model is: > y = exp(a*x) + b > > and you wish the b to be constant but the a to vary across expts. Then can > you not combine the data from both into single x, y vectors, add a variable > expt that takes the value 1 for expt1 and 2 for expt 2 and fit the single > model: > > y = (expt ==1)*(exp(a1*x) + b) + (expt == 2)* (exp(a2*x) + b) > > This would obtain separate estimates of a1 and a2 but a single estimate of > b . > > There are probably better ways to do this, but I've done hardly any > nonlinear model fitting (so warning!) and can only offer this brute force > approach; so wait for someone to suggest something better before trying it. > > Cheers, > Bert > > > On Tue, Nov 5, 2019 at 9:12 AM James Wagstaff > wrote: > >> Hello >> I am trying to determine least-squares estimates of the parameters of a >> nonlinear model, where I expect some parameters to remain constant across >> experiments, and for others to vary. I believe this is typically referred >> to as global curve fitting, or the presence of shared/nested parameters. >> The "[]" syntax in the stats::nls() function is an extremely convenient >> solution ( >> >> https://r.789695.n4.nabble.com/How-to-do-global-curve-fitting-in-R-td4712052.html >> ), >> but in my case I seem to need the Levenberg-Marquardt/Marquardt solvers >> such as nlsr::nlxb() and minpack.lm::nlsLM. I can not find any >> examples/documentation explaining a similar syntax for these tools. Is >> anyone aware of a nls-like tool with this functionality, or an alternative >> approach? >> Best wishes >> James Wagstaff >> >> [[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. >> > -- James Wagstaff +447910113349 [[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.
[R] Global curve fitting/shared parameters with nls() alternatives
Hello I am trying to determine least-squares estimates of the parameters of a nonlinear model, where I expect some parameters to remain constant across experiments, and for others to vary. I believe this is typically referred to as global curve fitting, or the presence of shared/nested parameters. The "[]" syntax in the stats::nls() function is an extremely convenient solution ( https://r.789695.n4.nabble.com/How-to-do-global-curve-fitting-in-R-td4712052.html), but in my case I seem to need the Levenberg-Marquardt/Marquardt solvers such as nlsr::nlxb() and minpack.lm::nlsLM. I can not find any examples/documentation explaining a similar syntax for these tools. Is anyone aware of a nls-like tool with this functionality, or an alternative approach? Best wishes James Wagstaff [[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] Parameters optimization in r
Hi, I’ve often come across this problem and have found genetic algorithms (GA) to be extremely useful. I wrote my first GA code in the 80’s and have extensive experience with the method. The package rgenoud is a very full featured GA implementation. Just code up your parameters as arguments to the function giving your method, random forests or whatever, then define a target variable for performance or fitness such as AUC or R^2, whatever is appropriate, and let the GA climb to the top of the fitness landscape. If you have a large problem you may want to speed things up by using parallel processes across cores or machines. Rgenoud handles that well. Good luck! James > On Oct 11, 2019, at 4:21 PM, javed khan wrote: > > Hi > > I will appreciate if someone provide the link to some tutorials/videos > where parameters running are performed in R. For instance, if we have to > perform predictions/classification using random forest or other algorithm, > how different optimization algorithms tune the parameters of random forest > such as numbers of trees etc. > > Best regards > > [[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. > __ 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] Large mixed & crossed-effect model looking at educational spending on crime rates with error messages
I posted my question at Stack Overflow, where it didn’t get much of a response, and I was pointed in this direction by Ben Bolker. I’m happy to send the whole dataset to anyone who wants but thought that it would be presumptuous to include an enormous dput() here. I’m looking at the effects of education spending per school district on crime rate (FBI crime data/UCR) within the cities and towns those school districts serve over a fifteen year period. The DV now has 203,410 observations of city/town crime data over those fifteen years. (I use that figure with some reticence, because there are so many moving parts and things to account for, but having employed over 100 datasets and hours passing through the code again, I think that figure is correct.) Cities are technically crossed with school district, in that one city might attend multiple school districts. This means that one city could have multiple values for expenditure per student. School districts, however, also overlap with counties. As if things weren’t complicated enough, cities are mostly nested within county (though there are cities that exist in two counties, but it’s not often, and it’s usually by a small amount). Given that each city/town has a distinct PLACE_ID, my understanding is that this could be represented as (1|PLACE_ID) + (1|STATE/COUNTY_ID) or (1|STATE/COUNTY_ID/PLACE_ID). I’m pretty familiar with mixed-effect models, and I’ve looked through clear and informative posts such as this one: https://stats.stackexchange.com/questions/228800/crossed-vs-nested-random-effects-how-do-they-differ-and-how-are-they-specified. I believe things would remain sane to include school district (full_district_id) as another crossed effect, as below: glmer.total <- glmer(CRIME_TOTAL ~ 1 + (year|PLACE_ID) + (1|STATE/COUNTY_ID) + (year|full_district_id), family = "poisson", control = glmerControl(optimizer = "nloptwrap", calc.derivs = FALSE), REML = FALSE, total.years, na.action = "na.omit") Variables (not included in this model, to keep things null and simple) are centered and logged: pop per city, pop.dens per city, year, unemployment rate per county, proportion children living in poverty per school district, per capita income per county, difference in those who voted democrat in presidential elections per county, log enforcement per city/town, centered expenditure per student/ 1000 (per school district). PLACE_ID corresponds to cities and towns, COUNTY_ID to counties, full_district_id to school districts, and state. First, if I try to run the full model, using UCSD’s supercomputer, I get the error that the job was killed, presumably because it got to a point where it consumed too much ram (I think 125mb). I then tried to create a small subsection of data with arrange(STATE, COUNTY_ID, PLACE_ID) and then slicing by the first ten states (up through Delaware), so that I have 26,599 values. If I run this null model with the above code, I get the following error: ``` Error in getOptfun(optimizer) : optimizer function must use (at least) formal parameters ‘fn’, ‘par’, ‘lower’, ‘control’ ``` Then I tried with the optimx, with these configurations: control = glmerControl(optimizer = "optimx”, optCtrl = list(method = "nlminb”, maxit=1, iter.max=1, eval.max=1, lower = c(0,0,0), upper = c(Inf,10,1))) and I received the following warning…since this is a null model, there aren’t any variables to really rescale.\ ``` Warning messages: 1: In nlminb(start = par, objective = ufn, gradient = ugr, lower = lower, : unrecognized control elements named ‘lower’, ‘upper’ ignored 2: In nlminb(start = par, objective = ufn, gradient = ugr, lower = lower, : unrecognized control elements named ‘lower’, ‘upper’ ignored 3: In checkConv(attr(opt, "derivs"), opt$par, ctrl = control$checkConv, : Model failed to converge with max|grad| = 0.00102386 (tol = 0.001, component 1) 4: In checkConv(attr(opt, "derivs"), opt$par, ctrl = control$checkConv, : Model is nearly unidentifiable: very large eigenvalue - Rescale variables? ``` I then tried more values (to 92,486, through Missouri). First, I tried the optimizer nloptr, and then I tried the optimix. I still received the same above errors. I’ve checked and rechecked everything, so I wanted to solicit advice, either for where I might be going wrong, or for what I could do to resolve these error messages. I’ve provided a brief snippet of the data below (randomly pulling a number of cities within counties of Arkansas, Arizona, and Alabama, as a dput. Thanks! 231, 206, 935, 1070, 974, 1108, 1244, 1095, 1131, 1151, 1420, 1316, 1321, 1414, 1484), full_district_id = c("0100240", "0100240", "0100240", "0100240", "0100240", "0100240", "0100240", "0100240", "0100240", "0100240", "0100240", "0100240", "0100240", "0100240", "0100240", "0100240", "0100240", "0100240", "0100240", "0100240", "0100240", "0100240", "0100240", "0100240", "0100240", "0100240", "0100240",
Re: [R] Problem parallelizing across cores
> On Aug 28, 2019, at 4:44 PM, James Spottiswoode wrote: > > Hi Bert, > > Thanks for your advice. Actually i’ve already done this and have checked out > doParallel and future packages. The trouble with doParallel is that it forks > R processes which spend a lot of time loading data and packages whereas my > function runs in 100ms so the parallelization doesn’t help. The future > package keeps it’s children running but I haven’t figured out how to get it > to work in my application. > > Best — James > > >> On Aug 28, 2019, at 3:39 PM, Bert Gunter > <mailto:bgunter.4...@gmail.com>> wrote: >> >> >> I would suggest that that you search on "parallel computing" at the >> Rseek.org <http://rseek.org/> site. This brought up what seemed to be many >> relevant hits including, of course, the High Performance and parallel >> Computing Cran task view. >> >> Cheers, >> Bert >> >> 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, Aug 28, 2019 at 3:18 PM James Spottiswoode >> mailto:james.spottiswo...@gmail.com>> wrote: >> Hi All, >> >> I have a piece of well optimized R code for doing text analysis running >> under Linux on an AWS instance. The code first loads a number of packages >> and some needed data and the actual analysis is done by a function called, >> say, f(string). I would like to parallelize calling this function across >> the 8 cores of the instance to increase throughput. I have looked at the >> packages doParallel and future but am not clear how to do this. Any method >> that brings up an R instance when the function is called will not work for >> me as the time to load the packages and data is comparable to the execution >> time of the function leading to no speed up. Therefore I need to keep a >> number of instances of the R code running continuously so that the data >> loading only occurs once when the R processes are first started and >> thereafter the function f(string) is ready to run in each instance. I hope >> I have put this clearly. >> >> I’d much appreciate any suggestions. Thanks in advance, >> >> James Spottiswoode >> >> >> -- >> >> [[alternative HTML version deleted]] >> >> __ >> R-help@r-project.org <mailto:R-help@r-project.org> mailing list -- To >> UNSUBSCRIBE and more, see >> https://stat.ethz.ch/mailman/listinfo/r-help >> <https://stat.ethz.ch/mailman/listinfo/r-help> >> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html >> <http://www.r-project.org/posting-guide.html> >> and provide commented, minimal, self-contained, reproducible code. > > James Spottiswoode > Applied Mathematics & Statistics > (310) 270 6220 > jamesspottiswoode Skype > ja...@jsasoc.com <mailto:ja...@jsasoc.com> James Spottiswoode Applied Mathematics & Statistics (310) 270 6220 jamesspottiswoode Skype ja...@jsasoc.com [[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.
[R] Problem parallelizing across cores
Hi All, I have a piece of well optimized R code for doing text analysis running under Linux on an AWS instance. The code first loads a number of packages and some needed data and the actual analysis is done by a function called, say, f(string). I would like to parallelize calling this function across the 8 cores of the instance to increase throughput. I have looked at the packages doParallel and future but am not clear how to do this. Any method that brings up an R instance when the function is called will not work for me as the time to load the packages and data is comparable to the execution time of the function leading to no speed up. Therefore I need to keep a number of instances of the R code running continuously so that the data loading only occurs once when the R processes are first started and thereafter the function f(string) is ready to run in each instance. I hope I have put this clearly. I’d much appreciate any suggestions. Thanks in advance, James Spottiswoode -- [[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.
[R] Application Sizing
Given an "R" application's source code, how does one measure the number of bytes taken by just the compiled application, not including the CRAN libraries? [[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.
[R] Fwd: Custom legend in ggplot - stat_summary shape and geom_bar fill
Hi Everyone, I am spending far to much time on this problem. Every post I read gets me closer to a solution, but I am still not quite there. I am trying to create a bar plot similar to the one below: <http://r.789695.n4.nabble.com/file/t124289/Desired_Output.png> My code is as follows: q92 <- function(x) {quantile(x,probs=0.92,na.rm = TRUE)} ggplot(River_Df, aes(x= reorder(Name, ECOLI, FUN = q92, order=TRUE), y=ECOLI))+ geom_bar(stat="summary",fun.y="median",aes(colour = "Median"), fill="#2eb82e")+ stat_summary(fun.y=q92, geom ="point",size=3, shape=18,aes(colour ="95th Percentile"),show_guide = FALSE)+ theme(axis.text.x = element_text(angle = 90, hjust = 1))+ xlab(paste("Monitored River Sites ",format(min(River_Df$Time),"%Y"),"-",format(max(River_Df$Time),"%Y"),sep=""))+ ylab("E. coli (cfu/100mL)") As you can see, I end up with two legend items, '95th Percentile' and 'Median'. However, I would like the '95th Percentile' item to be a darkred diamond with no background. Any ideas how to do this? The dataset is attached below: Datafile.csv <http://r.789695.n4.nabble.com/file/t124289/Datafile.csv> Thanks in advance for your help. James [[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.
[R] [R-pkgs] New package: collateral 0.4.2 on CRAN
Hi everyone, Collateral is now available on CRAN. If you've used purrr's side effect capturing functions before, you'll love collateral: it provides you with map variants that automatically wrap your mapped function in safely() or quietly() and provide nicely printed output, allowing you to quickly see which elements of a list returned results, and which returned errors, warnings or messages. The package also provides helpers to let you summarise your results and filter or aggregate the captured side effects. If you haven't used a list-column workflow before, I've included a vignette with collateral to get you started: https://rensa.co/collateral/articles/collateral.html If you'd like to contribute to collateral, you can find it on GitHub: https://github.com/rensa/collateral Thanks very much! <https://rensa.co/collateral/articles/collateral.html> -- = James Goldie: PhD Student, Climate Change Research Centre Email: j.gol...@unsw.edu.au, m...@rensa.co Tel: +61 421 747 208 Skype: james-goldie Web: https://rensa.co [[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.
Re: [R] Best Optimization Routines
Thanks Paul. Appreciate the help. I'll give this a shot. Ryan James D: 713.395.1794 M: 214.843.7301 -Original Message- From: Paul Smith [mailto:phh...@gmail.com] Sent: Thursday, February 15, 2018 7:12 AM To: Ryan James/E North America Business Division/SKI Cc: r-help@r-project.org Subject: Re: [R] Best Optimization Routines On Tue, Feb 13, 2018 at 7:55 PM, JamesRyan(Ryan James)/E North America Business Division <rja...@sk.com> wrote: > I have a set of data, the production of oil from a well. And an equation to > predict that forecast. > > The equation requires 5 input variables which are real numbers with upper and > lower bounds, 1 input variable which must be an integer and 1 input variable > which can be 1 of 2 string variables. > > What is the best optimization routine (I am using nlminb) to use in R to > determine the best set of inputs and how to I handle the integer and string > inputs when optimizing? > > I have attached a plot of what I am trying to accomplish as well as my sample > code. If I understand correctly your problem, your equation is linear, and you have continuous and integer variables (the string input can be coded as a binary integer variable). Thus, you can use a package to deal with mixed integer programming: http://blog.revolutionanalytics.com/2016/12/mixed-integer-programming-in-r-with-the-ompr-package.html Hope this helps you, Paul __ 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] Best Optimization Routines
I have a set of data, the production of oil from a well. And an equation to predict that forecast. The equation requires 5 input variables which are real numbers with upper and lower bounds, 1 input variable which must be an integer and 1 input variable which can be 1 of 2 string variables. What is the best optimization routine (I am using nlminb) to use in R to determine the best set of inputs and how to I handle the integer and string inputs when optimizing? I have attached a plot of what I am trying to accomplish as well as my sample code. Thanks, Ryan Rplot.pdf Description: Rplot.pdf __ 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] Error in loadNamespace
Thanks David!, that fixed the problem. Best regards, James On Thu, Dec 7, 2017 at 1:19 PM, David Winsemius <dwinsem...@comcast.net> wrote: > > > On Dec 7, 2017, at 10:47 AM, James Henson <jfhens...@gmail.com> wrote: > > > > Hello R Community, > > > > I inadvertently updated packages via R Studio when a package was open. > Now > > when R Studio is opened the message below appears in the console panel. > > > > Error in loadNamespace(name) : there is no package called ‘yaml’ > > > > Error in loadNamespace(name) : there is no package called ‘yaml’ > > > > When running R code, so far the only function that has not worked is > > datatable () in the ‘DT’ package. Removing the ‘DT’ package and > > reinstalling it had no effect. A possible fix is to update R from an > older > > version, which was not running when I made the mistake. Is this a good > > idea? > > There is a package on CRAN named "yaml". Have your tried installing it? > > > > Thanks for your help. > > > > James F. Henson > > > > [[alternative HTML version deleted]] > > Rhelp is a plain text mailing list. > > > > > __ > > 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. > > David Winsemius > Alameda, CA, USA > > 'Any technology distinguishable from magic is insufficiently advanced.' > -Gehm's Corollary to Clarke's Third Law > > > > > > [[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.
[R] Error in loadNamespace
Hello R Community, I inadvertently updated packages via R Studio when a package was open. Now when R Studio is opened the message below appears in the console panel. Error in loadNamespace(name) : there is no package called ‘yaml’ Error in loadNamespace(name) : there is no package called ‘yaml’ When running R code, so far the only function that has not worked is datatable () in the ‘DT’ package. Removing the ‘DT’ package and reinstalling it had no effect. A possible fix is to update R from an older version, which was not running when I made the mistake. Is this a good idea? Thanks for your help. James F. Henson [[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.
[R] tidyquant error downloading symbols for Index
Hi R Helpers, I recently tried to take advantage of the ability to download all the tickers in the S 500 using the functionality of tidyquant, but it threw an error. For summary, the set of commands that I ran was library(tidyquant) tq_index_options() tq_index("SP500") sessionInfo() R feedback including error message and sessionInfo are provided below. Guidance would be appreciated. --John J. Sparks, Ph.D. > library(tidyquant) Loading required package: lubridate Attaching package: lubridate The following object is masked from package:base: date Loading required package: PerformanceAnalytics Loading required package: xts Loading required package: zoo Attaching package: zoo The following objects are masked from package:base: as.Date, as.Date.numeric Package PerformanceAnalytics (1.4.3541) loaded. Copyright (c) 2004-2014 Peter Carl and Brian G. Peterson, GPL-2 | GPL-3 http://r-forge.r-project.org/projects/returnanalytics/ Attaching package: PerformanceAnalytics The following object is masked from package:graphics: legend Loading required package: quantmod Loading required package: TTR Version 0.4-0 included new data defaults. See ?getSymbols. Learn from a quantmod author: https://www.datacamp.com/courses/importing-and-managing-financial-data-in-r Loading required package: tidyverse Loading tidyverse: ggplot2 Loading tidyverse: tibble Loading tidyverse: tidyr Loading tidyverse: readr Loading tidyverse: purrr Loading tidyverse: dplyr Conflicts with tidy packages - as.difftime(): lubridate, base date():lubridate, base filter(): dplyr, stats first(): dplyr, xts intersect(): lubridate, base lag(): dplyr, stats last():dplyr, xts setdiff(): lubridate, base union(): lubridate, base Attaching package: tidyquant The following object is masked from package:dplyr: as_tibble The following object is masked from package:tibble: as_tibble There were 14 warnings (use warnings() to see them) > tq_index_options() [1] "RUSSELL1000" "RUSSELL2000" "RUSSELL3000" "DOW" "DOWGLOBAL" [6] "SP400" "SP500" "SP600" "SP1000" > tq_index("SP500") Getting holdings for SP500 # A tibble: 0 x 0 Warning message: In tq_index("SP500") : Error at SP500 during download. Error: .onLoad failed in loadNamespace() for 'rJava', details: call: fun(libname, pkgname) error: No CurrentVersion entry in Software/JavaSoft registry! Try re-installing Java and make sure R and Java have matching architectures. > sessionInfo() R version 3.3.2 (2016-10-31) Platform: x86_64-w64-mingw32/x64 (64-bit) Running under: Windows 7 x64 (build 7601) Service Pack 1 locale: [1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United States.1252 [3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C [5] LC_TIME=English_United States.1252 attached base packages: [1] stats graphics grDevices utils datasets methods base other attached packages: [1] tidyquant_0.5.3 dplyr_0.7.2 [3] purrr_0.2.3 readr_1.1.1 [5] tidyr_0.6.3 tibble_1.3.3 [7] ggplot2_2.2.1 tidyverse_1.1.1 [9] quantmod_0.4-10 TTR_0.23-2 [11] PerformanceAnalytics_1.4.3541 xts_0.10-0 [13] zoo_1.8-0 lubridate_1.6.0 loaded via a namespace (and not attached): [1] Rcpp_0.12.12 cellranger_1.1.0 plyr_1.8.4 bindr_0.1 [5] forcats_0.2.0tools_3.3.2 jsonlite_1.5 nlme_3.1-131 [9] gtable_0.2.0 lattice_0.20-35 pkgconfig_2.0.1 rlang_0.1.1 [13] psych_1.7.5 curl_2.8.1 parallel_3.3.2 haven_1.1.0 [17] bindrcpp_0.2 xml2_1.1.1 httr_1.2.1 stringr_1.2.0 [21] hms_0.3 grid_3.3.2 glue_1.1.1 R6_2.2.2 [25] Quandl_2.8.0 readxl_1.0.0 foreign_0.8-69 modelr_0.1.1 [29] reshape2_1.4.2 magrittr_1.5 scales_0.4.1 rvest_0.3.2 [33] assertthat_0.2.0 mnormt_1.5-5 colorspace_1.3-2 stringi_1.1.5 [37] lazyeval_0.2.0 munsell_0.4.3broom_0.4.2 __ 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] Looping Through QuantMod Objects
Dear R Helpers, I have run into a problem trying to perform a number of actions on a set of quantmod data objects through a loop and I am hoping that this is an easy problem for someone else as opposed to very difficult for me. The example task is to get the first three objects of the quarterly balance sheet for a number of companies from the getFinancials object and put them together into a single file. I can do this one by one, but if I try to build a loop and use the get function then the results are not anticipated and leave me baffled. If I do it one at a time all is good. require(quantmod) getFinancials("AAPL") getFinancials("IBM") getFinancials("MSFT") items=c("Cash & Equivalents","Short Term Investments","Cash and Short Term Investments") HoldQuart<-AAPL.f$BS$Q CashHold<-subset(HoldQuart,rownames(HoldQuart) %in% items) CashT<-t(CashHold) Cashdf<-data.frame(CashT) Cashdf$tic<-"AAPL" AAPL.c<-Cashdf HoldQuart<-IBM.f$BS$Q CashHold<-subset(HoldQuart,rownames(HoldQuart) %in% items) CashT<-t(CashHold) Cashdf<-data.frame(CashT) Cashdf$tic<-"IBM" IBM.c<-Cashdf HoldQuart<-MSFT.f$BS$Q CashHold<-subset(HoldQuart,rownames(HoldQuart) %in% items) CashT<-t(CashHold) Cashdf<-data.frame(CashT) Cashdf$tic<-"MSFT" MSFT.c<-Cashdf BigCash<-rbind(AAPL.c, IBM.c, MSFT.c) #setwd<-("C:/Users/HP USER/Documents") #write.csv(BigCash,file="CashList.csv") When I try to process through this using a loop, however, things go south pretty quickly. tickerlist<-ls(pattern="^[A-Z]+\\.f") for( i in 1:1) { test<-get(paste0(tickerlist[i],"$BS$Q")) } Error in get(paste0(tickerlist[i], "$BS$Q")) : object 'AAPL.f$BS$Q' not found So I tried to break it up into smaller steps, but the resulting matrix seems to have lost its structure (see below). If someone could help me out, I sure would appreciate. Thanks. --John Sparks tickerlist<-ls(pattern="^[A-Z]+\\.f") for( i in 1:1) { HoldFin<-get(tickerlist[i]) BSQ<-as.matrix(paste0(HoldFin,"$BS$Q")) } BSQ [1,] "list(Q = c(52896, NA, 52896, 32305, 20591, 3718, 2776, NA, NA, NA, NA, 38799, 14097, NA, NA, -165, 14684, 11029, NA, NA, 11029, NA, NA, NA, 11029, NA, 11029, 11029, NA, NA, NA, NA, 5261.69, 2.1, NA, 0.57, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 2.1, 78351, NA, 78351, 48175, 30176, 3946, 2871, NA, NA, NA, NA, 54992, 23359, NA, NA, 122, 24180, 17891, NA, NA, 17891, NA, NA, NA, 17891, NA, 17891, 17891, NA, NA, NA, NA, 5327.99, 3.36, NA, 0.57, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 3.36, \n46852, NA, 46852, 29039, 17813, 3482, 2570, NA, NA, NA, NA, 35091, 11761, NA, NA, -159, 12188, 9014, NA, NA, 9014, NA, NA, NA, 9014, NA, 9014, 9014, NA, NA, NA, NA, 5393.33, 1.67, NA, 0.57, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 1.67, 42358, NA, 42358, 26252, 16106, 3441, 2560, NA, NA, NA, NA, 32253, 10105, NA, NA, -263, 10469, 7796, NA, NA, 7796, NA, NA, NA, 7796, NA, 7796, 7796, NA, NA, NA, NA, 5472.78, 1.42, NA, 0.57, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 1.42, 50557, NA, 50557, \n30636, 19921, 3423, 2511, NA, NA, NA, NA, 36570, 13987, NA, NA, -510, 14142, 10516, NA, NA, 10516, NA, NA, NA, 10516, NA, 10516, 10516, NA, NA, NA, NA, 5540.89, 1.9, NA, 0.52, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 1.9), A = c(215639, NA, 215639, 131376, 84263, 14194, 10045, NA, NA, NA, NA, 155615, 60024, NA, NA, -1195, 61372, 45687, NA, NA, 45687, NA, NA, NA, 45687, NA, 45687, 45687, NA, NA, NA, NA, 5500.28, 8.31, NA, 2.18, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 8.31, 233715, NA, \n233715, 140089, 93626, 14329, 8067, NA, NA, NA, NA, 162485, 71230, NA, NA, -903, 72515, 53394, NA, NA, 53394, NA, NA, NA, 53394, NA, 53394, 53394, NA, NA, NA, NA, 5793.07, 9.22, NA, 1.98, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 9.22, 182795, NA, 182795, 112258, 70537, 11993, 6041, NA, NA, NA, NA, 130292, 52503, NA, NA, -311, 53483, 39510, NA, NA, 39510, NA, NA, NA, 39510, NA, 39510, 39510, NA, NA, NA, 0, 6122.66, 6.45, NA, 1.81, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 6.45, 170910, \nNA, 170910, 106606, 64304, 10830, 4475, NA, NA, NA, NA, 121911, 48999, NA, NA, -24, 50155, 37037, NA, NA, 37037, NA, NA, NA, 37037, NA, 37037, 37037, NA, NA, NA, 0, 6521.5, 5.68, NA, 1.63, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 5.68))$BS$Q" [2,] "list(Q = c(NA, 59501, 67101, 11579, NA, 20612, 2910, NA, 11367, 101990, 65124, -37961, 5473, 2617, 189740, 7549, 334532, 28573, 21665, 9992, 3999, 9113, 73342, 84531, NA, 84531, 98522, 28226, NA, 14351, 200450, NA, NA, 33579, NA, 100925, NA, -902, 134082, 334532, NA, 5205.81, NA, 51093, 60452, 14057, NA, 27977, 2712, NA, 12191, 103332, 62759, -36249, 5423, 2848, 185638, 7390, 331141, 38510, 21895, 10493, 3499, 9733, 84130, 73557, NA, 73557, 87549, 26948, NA, 14116, 198751, NA, NA, 32144, NA, 11, \nNA, -1567, 132390, 331141, NA, 5255.42, NA, 58554, 67155, 15754, NA, 29299, 2132, NA, 8283, 106869, 61245, -34235, 5414, 3206, 170430, 8757, 321686, 37294, 20951, 8105, 3500, 9156, 79006, 75427, NA, 75427, 87032, 26019, NA, 12985,
[R] Bayes Factor
Hello R Community; Just posted a question about Bayes Factor. But, just answered my own question. What is needed is to convert a 'dplyr' data frame into a standard data frame. competition2 <- data.frame(competition), where 'competition' is a 'dplyr' data frame with the following class structure. [1] "tbl_df" "tbl" "data.frame". Best regards, James __ 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] Bayes Factor
Hello R Community, Subject: Bayes Factor A Bayesian ANOVA of the form: competitionBayesOut <- anovaBF(biomass ~ clipping, data = competition) Returns the following Error message: Error in (function (classes, fdef, mtable) : unable to find an inherited method for function ‘compare’ for signature ‘"BFlinearModel", "missing", "tbl_df"’ My guess the problem is in the ‘class’, which is: [1] “tbl_df” “tbl” “data.frame” The data was imported via the ‘readr’ package through R Studio, and then saved as a RData file. My code is below, and the data is attached as a text file. Thanks for your assistance. Best regards, James # Plots for Interpreting One-Way ANOVA library(digest) library(DT) datatable(competition) # Characterize the data. class(competition) str(competition) competition$clipping <- as.factor(competition$clipping) competition$biomass <- as.numeric(competition$biomass) str(competition) # tapply(competition$biomass, competition$clipping, mean) tapply(competition$biomass, competition$clipping, sd) # Bayesian Procedure for ANOVA # Calculate Bayes Factors library(BayesFactor) competitionBayesOut <- anovaBF(biomass ~ clipping, data = competition) # Run mcmc iterations mcmcOut2 <- posterior(competitionBayesOut, iterations = 1) # boxplot of the posteriors for the groups boxplot(as.matrix(mcmcOut2[,2:6])) # Show the HDIs summary(mcmcOut2) # Calculate the Bayes Factor competitionBayesOut # Pairwise "post hoc" tests library(rjags) library(BEST) # competitionare 'r5' vs. 'control' plot(BESTmcmc(competition[competition$clpping=="r5",2], competition[competition$clipping=="control",2])) # plot(BESTmcmc(competition[competition$clpping=="r10",2], competition[competition$clipping=="control",2])) # competitionare 'n10' vs. 'control' plot(BESTmcmc(competition[competition$clipping=="n10",2], competition[competition$clipping=="control",2])) # competitionare 'n50' vs. 'control' plot(BESTmcmc(competition[competition$clipping=="n50",2], competition[competition$clipping=="control",2])) clippingbiomass n25 551 n25 457 n25 450 n25 731 n25 499 n25 632 n50 595 n50 580 n50 508 n50 583 n50 633 n50 517 r5 639 r5 615 r5 511 r5 573 r5 648 r5 677 control 417 control 449 control 517 control 438 control 415 control 555 r10 563 r10 631 r10 522 r10 613 r10 656 r10 679 __ 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: [ESS] knitr tutorial for ESS
Vincent Goulet has an installer that sets everything up for you, that you can get here. https://vigou3.github.io/emacs-modified-windows/ It does all the syntax highlighting, plus has polymode support which is nice for Rmd files. I can't help with any key combinations to build output. I just set up the yaml section to define the output, and use the rmarkdown package (the render function) to do everything. On Jun 8, 2017 9:35 PM, "Vince Forgetta"wrote: Hi, I would like to use ESS to work with Rmarkdown. Specifically, I would like to: 1. Enable syntax highlighting of Rmd files. 2. convert Rmd document to HTML or PDF. Is there a tutorial anywhere on how to do this in Windows? I am already quite comfortable with ESS, but I cannot find documentation on the ESS website that describes how to use it with knitr. Thanks, Vince [[alternative HTML version deleted]] __ ESS-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/ess-help [[alternative HTML version deleted]] __ ESS-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/ess-help
Re: [R] Setting .Rprofile for RStudio on a Windows 7 x64bit
Bruce, Do you think that you could post the final solution to the problem? That way it would be stored with this thread and the next person who has the same problem would be able to locate the FINAL solution. --JJS On Mon, April 17, 2017 12:47 pm, BR_email wrote: > TO _ALL_: > THANK YOU. THANK YOU. THANK YOU. > After hours, and hours, and hours, and ... , and hours: Success. > To all who helped, thanks. > My quest was minor, but major for me, as I learn from the path of one, > whether big or small begets another. > > I never look down at anyone, except to help him/her up. > > With gratitude, > Bruce > > Bruce Ratner, Ph.D. > The Significant Statistician⢠> (516) 791-3544 > Statistical Predictive Analtyics -- www.DMSTAT1.com > Machine-Learning Data Mining and Modeling -- www.GenIQ.net > > > Peter Dalgaard wrote: >>> On 17 Apr 2017, at 19:01 , BR_emailwrote: >>> >>> Berend: Something looks good, but RStudio still Rprofile still doees >>> not affect the launch. >>> source(echo=TRUE, "C:/Users/BruceRatner/Documents/.Rprofile.site") options(prompt="R> ") set.seed(12345) rm(list=ls()) >>> R> >>> >>> >>> Bruce Ratner, Ph.D. >>> The Significant Statistician⢠>>> (516) 791-3544 >>> Statistical Predictive Analtyics -- www.DMSTAT1.com >>> Machine-Learning Data Mining and Modeling -- www.GenIQ.net >>> >>> Berend Hasselman wrote: source(echo=TRUE, ""C:/Users/BruceRatner/Documents/.Rprofile.site") >> According to the gospel of St.Henrik, that filename is wrong, and >> possibly the directory too. >> >> So try his suggestions. What is the output (show us!) of >> >> normalizePath("./.Rprofile") >> normalizePath("~/.Rprofile") >> >> Assuming that the former is >> >> "C:/Users/BruceRatner/Documents/.Rprofile" >> >> you could try renaming the .Rprofile.site file to that. If need be, use >> file.rename, as in >> >> file.rename(from="C:/Users/BruceRatner/Documents/.Rprofile.site", >> to="C:/Users/BruceRatner/Documents/.Rprofile") >> >> (and restart, obviously). >> >> [I wouldn't set the seed in a .Rprofile file, nor would I use rm() >> there, but that is a different kettle of fish.] >> > > __ > 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-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] Windows server 2012
Hello I'm investigating installing R in a virtual machine environment. Does anyone have experience running R on windows server 2012? Regards James AstraZeneca UK Limited is a company incorporated in Engl...{{dropped:16}} __ 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] Marg.fct function
Greetings Peter and Jeff, Thanks for this information. Will try these type of analyses in SAS. Sure they are doable in R, but developing a procedure is difficult. Alan Agresti gives a cookbook SAS method in An Introduction to Categorical Analysis. Thanks, James On Sun, Feb 5, 2017 at 3:47 PM, Jeff Newmiller <jdnew...@dcn.davis.ca.us> wrote: > It is not part of "R". You can dig through all of the packages that the > author mentions, or send an email to the author. > -- > Sent from my phone. Please excuse my brevity. > > On February 5, 2017 11:44:40 AM PST, James Henson <jfhens...@gmail.com> wrote: >>Greetings R Community, >> >>An attempt to reproduce the results from code in the source below >>fails. R cannot find the function ‘Marg.fct’. An Internet search for >>the ‘Marg.fct’ function was not fruitful. I appreciate your help. >>Best regards, James F. Henson. >> >>R (and S-PLUS) Manual to Accompany Agresti’s Categorical Data Analysis >>(2002) 2nd edition Laura A. Thompson, 2009© >> >>http://www.stat.ufl.edu/~aa/cda/Thompson_manual.pdf page 181 >> >>The code is: >> >># Code from Manual to Accompany Agresti’s Categorical Data Analysis >>(2002) 2nd edition Laura A. Thompson, 2009 >> >>y <- c(144, 33, 84, 126, 2, 4, 14, 29, 0, 2, 6, 25, 0, 0, 1, 5) >> >>ZF <- Z <- matrix(1,16,1) >> >># >> >>M1 <- Marg.fct(1,rep(4,2)) # used to get m1+, etc >> >>Error: could not find function "Marg.fct" >> >> >> >>M2 <- Marg.fct(2,rep(4,2)) # used to get m+1, etc >> >># >> >>C.matrix <- matrix(c( >> >> 1, 0, 0, 0, -1, 0, 0, 0, # y1+ = y+1 >> >> 0, 1, 0, 0, 0, -1, 0, 0, # y2+ = y+2 >> >> 0, 0, 1, 0, 0, 0, -1, 0), # y3+ = y+3 >> >> 3,8,byrow=T) >> >>h.fct <- function(m) { # constraint function >> >> marg <- rbind(M1%*%m, M2%*%m) # y1+, y2+, y3+, y4+, y+1, y+2, y+3, y+4 >> >> C.matrix%*%marg # y1+ = y+1, y2+ = y+2, etc >> >>} >> >># >> >>a <- mph.fit(y=y,Z=Z,ZF=ZF,h.fct=h.fct) >> >>mph.summary(a) >> >>__ >>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-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] Marg.fct function
Greetings R Community, An attempt to reproduce the results from code in the source below fails. R cannot find the function ‘Marg.fct’. An Internet search for the ‘Marg.fct’ function was not fruitful. I appreciate your help. Best regards, James F. Henson. R (and S-PLUS) Manual to Accompany Agresti’s Categorical Data Analysis (2002) 2nd edition Laura A. Thompson, 2009© http://www.stat.ufl.edu/~aa/cda/Thompson_manual.pdf page 181 The code is: # Code from Manual to Accompany Agresti’s Categorical Data Analysis (2002) 2nd edition Laura A. Thompson, 2009 y <- c(144, 33, 84, 126, 2, 4, 14, 29, 0, 2, 6, 25, 0, 0, 1, 5) ZF <- Z <- matrix(1,16,1) # M1 <- Marg.fct(1,rep(4,2)) # used to get m1+, etc Error: could not find function "Marg.fct" M2 <- Marg.fct(2,rep(4,2)) # used to get m+1, etc # C.matrix <- matrix(c( 1, 0, 0, 0, -1, 0, 0, 0, # y1+ = y+1 0, 1, 0, 0, 0, -1, 0, 0, # y2+ = y+2 0, 0, 1, 0, 0, 0, -1, 0), # y3+ = y+3 3,8,byrow=T) h.fct <- function(m) { # constraint function marg <- rbind(M1%*%m, M2%*%m) # y1+, y2+, y3+, y4+, y+1, y+2, y+3, y+4 C.matrix%*%marg # y1+ = y+1, y2+ = y+2, etc } # a <- mph.fit(y=y,Z=Z,ZF=ZF,h.fct=h.fct) mph.summary(a) __ 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] cforest Single Tree Output for Categorical Variable
Hello R Helpers, I am building a random forest using the cforest method in the party package. I then want to have a look at the characteristics of a few of the trees. I get the output for one of the trees by executing pt <- party:::prettytree(cforest@ensemble[[3]], names(cforest@data@get("input"))) pt The first splitting variable is a categorical variable (here named cat, which contains value 0 through 9 and is a factor), but the output does not specify which values went into which part of the tree: 1) cat == {}; criterion = 1, statistic = 32.792 Can anyone help me to get the detail on this splitting variable to appear in the output? I regret that I cannot send a reproducible example because the data is proprietary. I will try to work up an example with a public data set that has the same problem. Any help would be much appreciated. Best wishes, --John J. Sparks, Ph.D. __ 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] confidence intervals for orthogonal contrasts
Richard, Thanks, Have not previously used the HH package, but looks as if it contains many useful tools. Will check out your book also. Best regards, James On Thu, Dec 1, 2016 at 10:18 PM, Richard M. Heiberger <r...@temple.edu> wrote: > James, > > Please look at the maiz example, the last example in ?MMC > help("MMC", package="HH") > where I show how to construct and calculate a set of orthogonal contrasts > for a factor in an analysis of variance setting. mmc and mmcplot use glht > in the multcomp package for the underlying calculations. > > If yo don't have HH, you can get it with > install.packages("HH") > > See the references in ?MMC to my book and paper. The second edition > of the book is now available. > > Rich > > On Thu, Dec 1, 2016 at 4:17 PM, James Henson <jfhens...@gmail.com> wrote: >> Hi R users, >> Is there a way to calculate a confidence interval for each contrast in >> a set of orthogonal contrasts? The ‘multcomp’ package will calculate >> a CIs at the 95% family-wise confidence level. But, these confidence >> intervals are extremely wide. >> Thanks for your help. >> Best regards, >> James >> >> __ >> 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-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] confidence intervals for orthogonal contrasts
Hi R users, Is there a way to calculate a confidence interval for each contrast in a set of orthogonal contrasts? The ‘multcomp’ package will calculate a CIs at the 95% family-wise confidence level. But, these confidence intervals are extremely wide. Thanks for your help. Best regards, James __ 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] Is this foreach behaviour correct?
I'm still not clear about whether this is a bug in foreach. Should c.Date be invoked by foreach with .combine='c'? On 11/06/2016 07:02 PM, William Dunlap wrote: Note that in the OP's example c.Date is never invoked. c.Date is called if .combine calls c rather than if .combine is c: > library(zoo) > trace(c.Date, quote(print(sys.call( Tracing function "c.Date" in package "base" [1] "c.Date" > foreach(i=1:10003, .combine=c) %do% { as.Date(i) } [1] 1 10001 10002 10003 > foreach(i=1:10003, .combine=function(...)c(...)) %do% { as.Date(i) } Tracing c.Date(...) on entry eval(expr, envir, enclos) Tracing c.Date(...) on entry eval(expr, envir, enclos) Tracing c.Date(...) on entry eval(expr, envir, enclos) [1] "1997-05-19" "1997-05-20" "1997-05-21" "1997-05-22" Bill Dunlap TIBCO Software wdunlap tibco.com<http://tibco.com> On Sun, Nov 6, 2016 at 2:20 PM, Duncan Murdoch <murdoch.dun...@gmail.com<mailto:murdoch.dun...@gmail.com>> wrote: On 06/11/2016 5:02 PM, Jim Lemon wrote: hi James, I think you have to have a starting date ("origin") for as.Date to convert numbers to dates. That's true with the function in the base package, but the zoo package also has an as.Date() function, which defaults the origin to "1970-01-01". If James is using zoo his code would be okay. If he's not, he would have got an error, so I think he must have been. Duncan Murdoch Jim On Sun, Nov 6, 2016 at 12:10 PM, James Hirschorn <james.hirsch...@hotmail.com<mailto:james.hirsch...@hotmail.com>> wrote: This seemed odd so I wanted to check: > x <- foreach(i=1:10100, .combine='c') %do% { as.Date(i) } yields a numeric vector for x: > class(x) [1] "numeric" Should it not be a vector of Date? __ R-help@r-project.org<mailto: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-help@r-project.org<mailto: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-help@r-project.org<mailto: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. [[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] Is this foreach behaviour correct?
Yes, I should have put > library(foreach) > library(zoo) at the top. On 11/06/2016 05:20 PM, Duncan Murdoch wrote: > On 06/11/2016 5:02 PM, Jim Lemon wrote: >> hi James, >> I think you have to have a starting date ("origin") for as.Date to >> convert numbers to dates. > > That's true with the function in the base package, but the zoo package > also has an as.Date() function, which defaults the origin to > "1970-01-01". If James is using zoo his code would be okay. If he's > not, he would have got an error, so I think he must have been. > > Duncan Murdoch > >> >> Jim >> >> On Sun, Nov 6, 2016 at 12:10 PM, James Hirschorn >> <james.hirsch...@hotmail.com> wrote: >>> This seemed odd so I wanted to check: >>> >>> > x <- foreach(i=1:10100, .combine='c') %do% { as.Date(i) } >>> >>> yields a numeric vector for x: >>> >>> > class(x) >>> [1] "numeric" >>> >>> Should it not be a vector of Date? >>> >>> __ >>> 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-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-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] isssues with predict.coxph, offset, type = "expected", and newdata
Thanks Terry, Re: the second case (predicting from a null model with a newdata= argument), I agree that it looks a bit over the top for such a straight forward computation, so maybe it is more a wish than anything else. In this one instance, this computation is embedded in a wider multi-state simulation in Epi::simLexis() where transition hazards are modeled as functions of covariates via Cox proportional hazards, and a subset of transitions happen not to depend on any covariate, thus the null model(s). There are ways to circumvent this special case within Epi::simLexis(), so even in this one example I wouldn't consider it high priority at all. But maybe it would be nice to have. On Sat, Oct 1, 2016 at 10:44 PM, Therneau, Terry M., Ph.D.wrote: > I'm off on vacation and checking email only intermittently. > Wrt the offset issue, I expect that you are correct. This is not a case that > I had ever envisioned, and so was not on my "list" when writing the code and > certainly has no test case. That does not mean that it shouldn't work, just > that I am not shocked to see it. I will look into this. > > For the second case of a NULL model I am less sympathetic. This is, in > theory, just reading off values from a Nelson hazard estimate at specific > time points; using a coxph call to do so is a case of swatting a fly with a > hammer. A bit more background might make me more excited about extending > the code to this case. > > Terry Therneau __ 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] isssues with predict.coxph, offset, type = "expected", and newdata?
Hi, It seems there might be two issues with predict.coxph(), and I'd appreciate confirmation before submitting a bug report to the package author. (1) predict() seems to produce incorrect predictions when using type = "expected" from a Cox model with an offset and specifying a new data for prediction (see Example 1 below). (2) predict() produces an error for a call with a null model and a newdata= argument (see Example 2 below). Please note that I didn't check these cases with additional complications, like strata(), cluster(), etc. SessionInfo() at the bottom of this email (notice I'm using survival 2.39-5, the current version in CRAN). Thanks, David -- Example 1 > library("survival") > data(lung) > > # simulate a three-fold genetic effect (worsening) > set.seed(123) > lung$gene.eff <- sample(log(c(1, 3)), size=nrow(lung), replace=TRUE, > prob=c(0.5, 0.5)) > > # fix the gene effect, do not estimate it > m1 <- coxph(Surv(time, status) ~ age + sex + offset(gene.eff), data = lung) > > # two hypothetical individuals differing only on gene.eff > nd <- expand.grid(time=180, status=1, age=65, sex=1, gene.eff=log(c(1,3))) > > p1.lp <- predict(m1, newdata = nd, type = "lp") > p1.rsk <- predict(m1, newdata = nd, type = "risk") > p1.exp <- predict(m1, newdata = nd, type = "expected") > > # output from type "lp" (linear predictor) and "risk" are ok, > # but not from type "expected" > all.equal(3, exp(p1.lp[2]-p1.lp[1]), check.names = FALSE) [1] TRUE > all.equal(3, p1.rsk[2]/p1.rsk[1], check.names = FALSE) [1] TRUE > all.equal(3, p1.exp[2]/p1.exp[1], check.names = FALSE) [1] "Mean relative difference: 0.667" > > # notice that predict() produces the same expected number of > # events for both hypothetical individuals > print(p1.exp) [1] 0.1882663 0.1882663 Example 2 > # null model > m0 <- coxph(Surv(time, status) ~ 1, data = lung) > > # time points at which we want predictions > nd <- data.frame(time=seq(from=0, to=360, by=30), status=rep(1, 13)) > > # predictions are produced for types "lp" and "risk", but not "expected" > p0.lp <- predict(m0, type="lp", newdata = nd) > p0.rsk <- predict(m0, type="risk", newdata = nd) > p0.exp <- predict(m0, type="expected", newdata = nd) Error in newx %*% object$coef : requires numeric/complex matrix/vector arguments > Session Info: > sessionInfo() R version 3.3.1 (2016-06-21) Platform: i386-w64-mingw32/i386 (32-bit) Running under: Windows 7 (build 7601) Service Pack 1 locale: [1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United States.1252LC_MONETARY=English_United States.1252 [4] LC_NUMERIC=C LC_TIME=English_United States.1252 attached base packages: [1] stats graphics grDevices utils datasets methods base other attached packages: [1] survival_2.39-5 loaded via a namespace (and not attached): [1] Matrix_1.2-6tools_3.3.1 splines_3.3.1 grid_3.3.1 lattice_0.20-33 __ 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] yuen function of the WRS2 package
Thanks, The 'droplevels' statement works. Best regards, James Henson On Tue, Aug 30, 2016 at 5:34 PM, William Dunlap <wdun...@tibco.com> wrote: > yuen does not work when there unused levels in the factors given to it. > >> yuen(GoalsGame ~ League, tr=0.2, data = SpainGer) > Call: > yuen(formula = GoalsGame ~ League, data = SpainGer, tr = 0.2) > > Test statistic: NaN (df = NA), p-value = NA > > Trimmed mean difference: NaN > 95 percent confidence interval: > NaN NaN > >> yuen(GoalsGame ~ League, tr=0.2, data = droplevels(SpainGer)) > Call: > yuen(formula = GoalsGame ~ League, data = droplevels(SpainGer), > tr = 0.2) > > Test statistic: 0.8394 (df = 16.17), p-value = 0.4135 > > Trimmed mean difference: -0.11494 > 95 percent confidence interval: > -0.405 0.1751 > > Complain to WSR2's maintainer. >> maintainer("WRS2") > [1] "Patrick Mair <m...@fas.harvard.edu>" > > > > Bill Dunlap > TIBCO Software > wdunlap tibco.com > > On Tue, Aug 30, 2016 at 2:07 PM, James Henson <jfhens...@gmail.com> wrote: >> >> Greetings R community, >> Here is a small but perplexing problem with the ‘yuen’ function in the >> ‘WRS2’ package. >> I begin with the ‘eurosoccer’ data frame from the ‘WRS2’ package. >> Then make a subset that contains only two Leagues Spain and Germany >> (subset data frame is ‘SpainGer’). The ‘yuen’ function cannot read >> the data in subset data frame ‘SpainGer’. My code is below. >> Thanks you for your help. >> James F. Henson >> >> >> # Examples from 'Robust Statistical Methods on R Using the WRS2 Package’ >> # Robust t-test, and ANOVA (pages5-13) >> library(WRS2) >> data("eurosoccer") >> class(eurosoccer) >> print(eurosoccer) >> library("digest") >> library("DT") >> datatable(eurosoccer) >> str(eurosoccer) >> # make a subset with only Spain and Germany >> SpainGer <- subset (eurosoccer, subset = League =="Spain" | League == >> "Germany") >> print(SpainGer) >> class(SpainGer) >> str(SpainGer) >> # The 'yuen' function can not read the data in the subset data.frame >> "SpainGer" >> yuen(GoalsGame ~ League, tr=0.2, data = SpainGer) >> # the 'yuen' function works on the orginioal data.frame >> yuen(GoalsGame ~ League, tr=0.2, data = eurosoccer) >> # the 'aov' function reads the data in the subset data.frame "SpainGer" >> Goals.fit <- aov(GoalsGame ~ League, data = SpainGer) >> summary(Goals.fit) >> >> __ >> 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-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] yuen function of the WRS2 package
Greetings R community, Here is a small but perplexing problem with the ‘yuen’ function in the ‘WRS2’ package. I begin with the ‘eurosoccer’ data frame from the ‘WRS2’ package. Then make a subset that contains only two Leagues Spain and Germany (subset data frame is ‘SpainGer’). The ‘yuen’ function cannot read the data in subset data frame ‘SpainGer’. My code is below. Thanks you for your help. James F. Henson # Examples from 'Robust Statistical Methods on R Using the WRS2 Package’ # Robust t-test, and ANOVA (pages5-13) library(WRS2) data("eurosoccer") class(eurosoccer) print(eurosoccer) library("digest") library("DT") datatable(eurosoccer) str(eurosoccer) # make a subset with only Spain and Germany SpainGer <- subset (eurosoccer, subset = League =="Spain" | League == "Germany") print(SpainGer) class(SpainGer) str(SpainGer) # The 'yuen' function can not read the data in the subset data.frame "SpainGer" yuen(GoalsGame ~ League, tr=0.2, data = SpainGer) # the 'yuen' function works on the orginioal data.frame yuen(GoalsGame ~ League, tr=0.2, data = eurosoccer) # the 'aov' function reads the data in the subset data.frame "SpainGer" Goals.fit <- aov(GoalsGame ~ League, data = SpainGer) summary(Goals.fit) __ 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] [R-pkgs] new package clubSandwich: Cluster-Robust (Sandwich) Variance Estimators with Small-Sample Corrections
Dear R users: I'm happy to announce the first CRAN release of the clubSandwich package: https://cran.r-project.org/web/packages/clubSandwich clubSandwich provides several variants of the cluster-robust variance estimator for ordinary and weighted least squares linear regression models, including the bias-reduced linearization estimator of Bell and McCaffrey (2002). The package includes functions for estimating the variance-covariance matrix and for testing single- and multiple-contrast hypotheses based on Wald test statistics. The hypothesis tests incorporate small-sample corrections that lead to more accurate rejection rates when the number of clusters is small or the design is unbalanced/leveraged. Tests of single regression coefficients use Satterthwaite or saddle-point corrections. Tests of multiple-contrast hypotheses use an approximation to Hotelling's T-squared distribution. Methods are provided for a variety of fitted models, including lm(), plm() (from package 'plm'), gls() and lme() (from 'nlme'), robu() (from 'robumeta'), and rma.uni() and rma.mv() (from 'metafor'). The package includes two vignettes that demonstrate its use for estimation of panel data models and meta-regression models. Bug reports, suggestions, and feature requests are welcome at https://github.com/jepusto/clubSandwich Cheers, James ___ James Pustejovsky Assistant Professor, Quantitative Methods Program Educational Psychology Department The University of Texas at Austin http://jepusto.github.io/ [[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] Anybody know the cause of this?
Just upgraded to R 3.3.1; when I updated the packages on CRAN, I got a BUNCH of warning messages like the ones below: 2016-07-01 14:44:19.840 R[369:3724] IMKClient Stall detected, *please Report* your user scenario attaching a spindump (or sysdiagnose) that captures the problem - (imkxpc_windowLevelWithReply:) block performed very slowly (2.40 secs). starting httpd help server ... done > spindump() Error: could not find function "spindump" In addition: Warning message: In library() : library ‘/Users/jimplante/Library/R/3.3/library’ contains no packages 2016-07-01 14:47:32.774 R[369:3724] IMKClient Stall detected, *please Report* your user scenario attaching a spindump (or sysdiagnose) that captures the problem - (imkxpc_attributesForCharacterIndex:reply:) block performed very slowly (1.42 secs). > This is not interfering with any of my work, but I’m curious to know what it’s warning me about. Two more questions: 1) What’s a spindump; and 2) What’s a sysdiagnose? And finally, how would I get either one of those, and to whom would I send them? Thanks, Jim __ 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] Rpart plot produces no text
I am using R Studio and am able to fit a tree with RPlot, however, the tree in the viewer has no text (see image attached). Jim Thompson This e-mail message is for the sole use of the intended recipient and may contain information that is confidential, proprietary or privileged. Any unauthorized review, use, distribution, copying or disclosure is strictly prohibited. If you are not the intended recipient, or the employee or agent responsible for delivering it to the intended recipient, please notify sender of the delivery error by replying to this message and then delete it from your system. Receipt by anyone other than the intended recipient is not a waiver of confidentiality or privilege. __ 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] Whether statistical background is must to learn R language
Greetings Prasad, Here are some tutorials on statistics using R.Statistics and Actuarial Science – Carl James Schwarz http://people.stat.sfu.ca/~cschwarz/CourseNotes/ Statistics and Actuarial Science – Carl James Schwarz - Programs http://people.stat.sfu.ca/~cschwarz/Stat-650/Notes/MyPrograms/ Design Analysis and Interpretation of Experiments http://www.unh.edu/halelab/BIOL933/ Great YouTube channel of R tutorials by Mike Marin, https://www.youtube.com/user/marinstatlectures Best regards, James On Tue, May 31, 2016 at 8:04 AM, PIKAL Petr <petr.pi...@precheza.cz> wrote: > Hi > > Well, it seems to me like cooking. > > You does not have to be educated cook to be able prepare some food in your > kitchen, but knowledge of some recipes can lead to tasty results > > Regards > Petr > >> -Original Message- >> From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Prasad >> Kale >> Sent: Tuesday, May 31, 2016 9:23 AM >> To: R-help@r-project.org >> Subject: [R] Whether statistical background is must to learn R language >> >> Hi, >> >> I am very new to R and just started learning R. But i am not from statistical >> background so can i learn R or to learn R statistical background is must. >> >> Please guide. >> >> Thanks in Advance >> Prasad >> >> [[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. > > > Tento e-mail a jakékoliv k němu připojené dokumenty jsou důvěrné a jsou > určeny pouze jeho adresátům. > Jestliže jste obdržel(a) tento e-mail omylem, informujte laskavě neprodleně > jeho odesílatele. Obsah tohoto emailu i s přílohami a jeho kopie vymažte ze > svého systému. > Nejste-li zamýšleným adresátem tohoto emailu, nejste oprávněni tento email > jakkoliv užívat, rozšiřovat, kopírovat či zveřejňovat. > Odesílatel e-mailu neodpovídá za eventuální škodu způsobenou modifikacemi či > zpožděním přenosu e-mailu. > > V případě, že je tento e-mail součástí obchodního jednání: > - vyhrazuje si odesílatel právo ukončit kdykoliv jednání o uzavření smlouvy, > a to z jakéhokoliv důvodu i bez uvedení důvodu. > - a obsahuje-li nabídku, je adresát oprávněn nabídku bezodkladně přijmout; > Odesílatel tohoto e-mailu (nabídky) vylučuje přijetí nabídky ze strany > příjemce s dodatkem či odchylkou. > - trvá odesílatel na tom, že příslušná smlouva je uzavřena teprve výslovným > dosažením shody na všech jejích náležitostech. > - odesílatel tohoto emailu informuje, že není oprávněn uzavírat za společnost > žádné smlouvy s výjimkou případů, kdy k tomu byl písemně zmocněn nebo písemně > pověřen a takové pověření nebo plná moc byly adresátovi tohoto emailu > případně osobě, kterou adresát zastupuje, předloženy nebo jejich existence je > adresátovi či osobě jím zastoupené známá. > > This e-mail and any documents attached to it may be confidential and are > intended only for its intended recipients. > If you received this e-mail by mistake, please immediately inform its sender. > Delete the contents of this e-mail with all attachments and its copies from > your system. > If you are not the intended recipient of this e-mail, you are not authorized > to use, disseminate, copy or disclose this e-mail in any manner. > The sender of this e-mail shall not be liable for any possible damage caused > by modifications of the e-mail or by delay with transfer of the email. > > In case that this e-mail forms part of business dealings: > - the sender reserves the right to end negotiations about entering into a > contract in any time, for any reason, and without stating any reasoning. > - if the e-mail contains an offer, the recipient is entitled to immediately > accept such offer; The sender of this e-mail (offer) excludes any acceptance > of the offer on the part of the recipient containing any amendment or > variation. > - the sender insists on that the respective contract is concluded only upon > an express mutual agreement on all its aspects. > - the sender of this e-mail informs that he/she is not authorized to enter > into any contracts on behalf of the company except for cases in which he/she > is expressly authorized to do so in writing, and such authorization or power > of attorney is submitted to the recipient or the person represented by the > recipient, or the existence of such authorization is known to the re
Re: [R] mixed models
Greetings David, I am new to R and neglected to check vigorously for missing values. Apologize for posting without checking and finding the one NA. I appreciate your help. Thanks. James F. Henson On Fri, May 27, 2016 at 1:49 PM, David Winsemius <dwinsem...@comcast.net> wrote: > >> On May 27, 2016, at 10:07 AM, James Henson <jfhens...@gmail.com> wrote: >> >> Greetings Jeff, >> You are correct that the unequal number of levels is not the problem. >> I revised the data frame so that the number of levels was equal and >> the same error message occurred. The code is below, and the >> Eboni2.txt file is attached. This problem baffles me. I appreciate >> any help. >> Best regards, >> James >> Eboni2 <- read.csv("Eboni2.csv", header = TRUE) >> >> library("nlme") >> >> str(Eboni2) >> >> head(Eboni2) >> >> model1 <- lme(preDawn ~ Irrigation, random=~season_order|treeNo, data=Eboni2) > > I downloaded the attached file to your first posting that was called a "csv" > file but it was tab-separated (as could be clearly seen with the str output, > so would only load properly with read.delim rather than read.csv. Running > then with the lme call, it produced this message > >> model1 <- lme(preDawn ~ Irrigation, random=~season_order|treeNo, data=Eboni2) > Error in na.fail.default(list(season_order = c(5L, 5L, 5L, 5L, 5L, 5L, : > missing values in object > > And looking at the str result made it clear that there were many NA's in the > file. > >> head(Eboni2) > number Location Season season_order Month treeID treeNo preDawn midday > 1 1 UCC November5 Nov UCCLO 1 60 1.41.3 > 2 2 UCC November5 Nov UCCLO 2 72 1.21.3 > 3 3 UCC November5 Nov UCCLO 3 78 1.11.2 > 4 4 UCC November5 Nov UCCLO 4 79 1.12.1 > 5 5 UCC November5 Nov UCCLO 5 80 1.41.3 > 6 6 UCC November5 Nov UCCLO 6 81 0.61.8 > Irrigation PnetGsE WUE d15N d13C Nper Cper include2 > 1 N9 0.2907004 3.766207 2.389672 NA NA NANA no > 2 N 11 0.3262582 3.120574 3.524993 NA NA NANA no > 3 N8 0.2870957 1.693821 4.723050 3.00 -27.44 2.12 52.12 yes > 4 N 10 0.2475180 1.839343 5.436724 3.61 -29.50 1.42 51.97 yes > 5 N 13 0.3009228 3.082278 4.217660 NA NA NANA no > 6 N 17 0.3487337 2.534550 6.707304 2.79 -30.50 1.49 49.94 yes > > And even more importantly, there was one NA in your outcome variable: >> sum( is.na(Eboni2$Irrigation)) > [1] 0 >> sum( is.na(Eboni2$preDawn)) > [1] 1 > > So after restricting to complete.cases, I then formed the hypothesis that you > reversed the order of the variables in the formula for the random parameter: > >> table(Eboni2$season_order) > > 1 2 3 4 5 > 83 83 83 83 83 >> length( Eboni2$treeNo) > [1] 415 > > So it seemed unreasonable to have a "grouping" on variable with only one item > per group. > >> model1 <- lme(preDawn ~ Irrigation, random=~treeNo|season_order, >> data=Eboni2[ complete.cases( Eboni2[ , >> c('preDawn','Irrigation','season_order','treeNo')]), ] ) >> model1 > Linear mixed-effects model fit by REML > Data: Eboni2[complete.cases(Eboni2[, c("preDawn", "Irrigation", > "season_order", "treeNo")]), ] > Log-restricted-likelihood: -183.4708 > Fixed: preDawn ~ Irrigation > (Intercept) IrrigationY > 1.04520145 -0.06037706 > > Random effects: > Formula: ~treeNo | season_order > Structure: General positive-definite, Log-Cholesky parametrization > StdDev Corr > (Intercept) 0.140239324 (Intr) > treeNo 0.003766019 -0.725 > Residual0.365678898 > > Number of Observations: 414 > Number of Groups: 5 > > (Warning, I'm not a frequent user of this package or any of the mixed effects > packages.) > > > > Just to correct some misinformation that appeared earlier: You can attach > "csv" or "tsv" files as long as you name them with an .txt extension so the > mail clients and servers consider them to be MIME-text. > > -- > David. > > >> On Wed, May 25, 2016 at 6:23 PM, Jeff Newmiller >> <jdnew...@dcn.davis.ca.us> wrote: >>> Please keep the mailing list in the loop by using reply-all. >>> >>> I don't think there is a requirement that the number of levels is
Re: [R] mixed models
Greetings Jeff, You are correct that the unequal number of levels is not the problem. I revised the data frame so that the number of levels was equal and the same error message occurred. The code is below, and the Eboni2.txt file is attached. This problem baffles me. I appreciate any help. Best regards, James Eboni2 <- read.csv("Eboni2.csv", header = TRUE) library("nlme") str(Eboni2) head(Eboni2) model1 <- lme(preDawn ~ Irrigation, random=~season_order|treeNo, data=Eboni2) On Wed, May 25, 2016 at 6:23 PM, Jeff Newmiller <jdnew...@dcn.davis.ca.us> wrote: > Please keep the mailing list in the loop by using reply-all. > > I don't think there is a requirement that the number of levels is equal, but > there may be problems if you don't have the minimum number of records > corresponding to each combination of levels specified in your model. > > You can change the csv extension to txt and attach for the mailing list. Or, > better yet, you can use the dput function to embed the data directly in your > sample code. > > Also, please learn to post plain text email to avoid corruption of R code by > the HTML formatting. > -- > Sent from my phone. Please excuse my brevity. > > On May 25, 2016 2:26:54 PM PDT, James Henson <jfhens...@gmail.com> wrote: >> >> Good afternoon Jeff, >> The sample sizes for levels of the factor "Irrigation" are not equal. If >> 'nlme' requires equal sample sizes this may be the problem. The same data >> frame runs in 'lme4' without a problem. >> >> Best regards, >> James >> >> >> On Wed, May 25, 2016 at 3:41 PM, James Henson <jfhens...@gmail.com> wrote: >>> >>> Good afternoon Jeff, >>> >>> When working with this data frame, I just open the .csv file in R Studio. >>> But, we should not send .csv file to R_help. What should I send? >>> >>> Best regards, >>> James >>> >>> On Wed, May 25, 2016 at 2:52 PM, Jeff Newmiller >>> <jdnew...@dcn.davis.ca.us> wrote: >>>> >>>> You forgot to show the commands to us that you used to read the data in >>>> with (your example is not "reproducible"). This step can make all the >>>> difference in the world as to whether your analysis commands will work or >>>> not. >>>> -- >>>> Sent from my phone. Please excuse my brevity. >>>> >>>> On May 25, 2016 11:59:06 AM PDT, James Henson <jfhens...@gmail.com> >>>> wrote: >>>>> >>>>> Greetings R community, >>>>> >>>>> My aim is to analyze a mixed-effects model with temporal >>>>> pseudo-replication >>>>> (repeated measures on the same experimental unit) using ‘nlme’. >>>>> However, >>>>> my code returns the error message “Error in na.fail.default’, even >>>>> though >>>>> the data frame does not contain missing values. My code is below, and >>>>> the >>>>> data file is attached as ‘Eboni2.txt. >>>>> >>>>> library("nlme") >>>>> >>>>> str(Eboni2) >>>>> >>>>> head(Eboni2) >>>>> >>>>> model1 <- lme(preDawn ~ Irrigation, random=~season_order|treeNo, >>>>> data=Eboni2) >>>>> >>>>> I am genuinely confused. Hope someone can help. >>>>> >>>>> Best regards, >>>>> >>>>> James F. Henson >>>>> >>>>> >>>>> >>>>> 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-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] mixed models
Greetings R community, My aim is to analyze a mixed-effects model with temporal pseudo-replication (repeated measures on the same experimental unit) using ‘nlme’. However, my code returns the error message “Error in na.fail.default’, even though the data frame does not contain missing values. My code is below, and the data file is attached as ‘Eboni2.txt. library("nlme") str(Eboni2) head(Eboni2) model1 <- lme(preDawn ~ Irrigation, random=~season_order|treeNo, data=Eboni2) I am genuinely confused. Hope someone can help. Best regards, James F. Henson number LocationSeason season_orderMonth treeID treeNo preDawn midday Irrigation PnetGs E WUE d15Nd13CNper Cperinclude2 1 UCC November5 Nov UCCLO 1 60 1.4 1.3 N 9 0.290700373 3.766207481 2.38967185 no 2 UCC November5 Nov UCCLO 2 72 1.2 1.3 N 11 0.326258186 3.120573618 3.524992949 no 3 UCC November5 Nov UCCLO 3 78 1.1 1.2 N 8 0.287095701 1.693820753 4.723049937 3 -27.44 2.1252.12 yes 4 UCC November5 Nov UCCLO 4 79 1.1 2.1 N 10 0.247517983 1.83934285 5.436724317 3.61-29.5 1.4251.97 yes 5 UCC November5 Nov UCCLO 5 80 1.4 1.3 N 13 0.300922817 3.082277827 4.217660032 no 6 UCC November5 Nov UCCLO 6 81 0.6 1.8 N 17 0.348733689 2.534550345 6.70730413 2.79-30.5 1.4949.94 yes 7 UCC November5 Nov UCCLO 7 82 0.9 1.2 N 12 0.272690759 1.809851748 6.630377328 2.43-29.4 1.5553.12 yes 8 UCC November5 Nov UCCLO 8 83 1.4 1.1 N 11 0.269862804 1.919849835 5.729614785 2.85-28.37 1.7853.52 yes 9 UCC November5 Nov UCCLO 9 84 0.8 1 N 16 0.32333 2.394825767 6.68107059 2.43-30.1 1.5452.88 yes 10 UCC November5 Nov UCCLO 1062 0.9 1.2 N 17 0.29488545 1.429058721 11.89594224 1.51 -31.96 1.6152.94 yes 11 UCC November5 Nov UCCLO 1163 1.3 2 N 14 0.241601092 3.29815495 4.244797535 no 12 UCC November5 Nov UCCLO 1264 1.2 1.3 N 11 0.261040739 1.610353496 6.83079835 2.62 -28.94 1.4651.9yes 13 UCC November5 Nov UCCLO 1365 1.2 1.3 N 13 0.238863129 2.221057396 5.853068012 1.13 -28.81 2.0851.43 yes 14 UCC November5 Nov UCCLO 1466 1.1 1.5 N 9 0.309603194 2.859756011 3.14712163 no 15 UCC November5 Nov UCCLO 1567 1.1 1.3 N 18 0.383441504 2.949059627 6.103640576 1.51 -30.14 1.6552.04 yes 16 UCC November5 Nov UCCLO 1668 1.3 2.7 N 13 0.269711187 1.430856375 9.085468137 1.99 -29.09 1.8751.21 yes 17 UCC November5 Nov UCCLO 1769 0.8 1.4 N 13 0.245685997 3.808576972 3.41334837 no 18 UCC November5 Nov UCCLO 1870 1.6 1.8 N 11 0.271419599 2.305398713 4.771408926 2.94 -29.22 1.9351.46 yes 19 UCC November5 Nov UCCLO 1971 1 1.5 N 18 0.338103566 2.303586185 7.813903435 2.93 -30.27 1.9251.51 yes 20 UCC November5 Nov UCCLO 2073 1.1 1.2 N 11 0.27096196 3.230604699 3.404935307 no 21 UCC November5 Nov UCCLO 2174 1.2 1.5 N 10 0.294348983 3.319661403 3.012355414 no 22 UCC November5 Nov UCCLO 2275 1.5 1.9 N 12 0.230438536 2.935053987 4.088510825 1.74 -29.49 1.6450.28 yes 23 UCC November5 Nov UCCLO 2376 1.1 1.4 N 14 0.264963659 3.689609021
[R] Reduce does not work with data.table?
Reduce is failing when applied to a list of elements of class data.table. Perhaps this is a bug? Example: library(data.table) dt1 <- data.table(x = 1:3, y = 4:6) dt2 <- data.table(x = 4:6, y = 1:3) dt3 <- data.table(x = 0:-2, y = 0:-2) # This works fine dt1 + dt2 + dt2 #x y # 1: 5 5 # 2: 6 6 # 3: 7 7 # But: dt_list <- list(dt1, dt2, dt3) Reduce("+", dt_list) # Error in f(init, x[[i]]) : non-numeric argument to binary operator # In addition: Warning message: # In Reduce("+", dt_list) : # Incompatible methods ("Ops.data.frame", "Ops.data.table") for "+" If I use data.frame instead of data.table, Reduce works properly. __ 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] a replace for subset
Would facet_wrap or facet_grid give you what you want? On Sat, Apr 16, 2016 at 8:45 AM, ch.elahe via R-help <r-help@r-project.org> wrote: > Hi, > I have a data set (mydata), which a part of this is like the following: > > > 'data.frame': 36190 obs. of 16 variables: > $ RE: int 38 41 11 67 30 18 38 41 41 30 ... > $ LU : int 4200 3330 530 4500 3000 1790 4700 3400 > 3640 4000 ... > $ COUNTRY: Factor w/ 4 levels "DE","FR","JP", "FR"… > $Light : Factor w/2 levels "ON","OFF","ON", …. > $OR : Factor w/2 levels "S","T","S",…. > $PAT : Factor w/3 levels "low", "high", "middle",…. > > > Now I want to plot RE vs LU with ggplot2 for all the possible cases, I > know how to do subsetting for the data but I want to know is there any > shorter way to do that? For example I want to have a plot for RE vs LU for > (COUNTRY= FR, Light=off, OR=S, PAT=low) and one for (COUNTRY= FR, Light=on, > OR=S, PAT=high) and …., as you see doing subset is time consuming, is there > any other way? > Thank you for any help. > Elahe > > __ > 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. -- *James C. Whanger* [[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] ggplot2
Thanks, the stat="identity" worked. On Tue, Apr 12, 2016 at 3:34 PM, Huzefa Khalil <huzefa.kha...@umich.edu> wrote: > Hi James, > > If you want to specify the y-values, you need to use stat="identity" as > below: > > ggplot(probability, aes(x=Fertilizer, y=prob)) + > geom_bar(stat="identity", aes(fill=Treatment)) > > > best, > huzefa > > On Tue, Apr 12, 2016 at 1:02 PM, James Henson <jfhens...@gmail.com> wrote: > > Dear R Community, > > > > Below is a problem with a simple ggplot2 graph. The code returns the > error > > message below. > > > > Error: stat_count() must not be used with a y aesthetic. > > > > My code is below and the data is attached as a ‘text’ file. > > > > > > > > # Graph of the probabilities > > > > library(digest) > > > > library(DT) > > > > datatable(probability) > > > > str(probability) > > > > probability$Fertilizer <- as.factor(probability$Fertilizer) > > > > str(probability) > > > > library(ggplot2) > > > > plot1 <- ggplot(probability, aes(x=Fertilizer, y=prob)) + > > geom_bar(aes(fill=Treatment)) > > > > plot1 > > > > > > > > Thanks. > > > > Best regards, > > > > James F. Henson > > > > __ > > 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. > [[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.
[R] ggplot2
Dear R Community, Below is a problem with a simple ggplot2 graph. The code returns the error message below. Error: stat_count() must not be used with a y aesthetic. My code is below and the data is attached as a ‘text’ file. # Graph of the probabilities library(digest) library(DT) datatable(probability) str(probability) probability$Fertilizer <- as.factor(probability$Fertilizer) str(probability) library(ggplot2) plot1 <- ggplot(probability, aes(x=Fertilizer, y=prob)) + geom_bar(aes(fill=Treatment)) plot1 Thanks. Best regards, James F. Henson Trt probLL UL Fertilizer Treatment S0 0. 0.0154 0.4998 0 S S2 0. 0.0154 0.4998 2 S S4 0. 0.0154 0.4998 4 S S6 0. 0.0154 0.4998 6 S P0 0. 0.056 0.579 0 P P2 0.7778 0.4208 0.9439 2 P P3 0.333 0. 0.6665 4 P P4 0.6667 0.3334 0. 6 P __ 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] Is this a bug in quantmod::OpCl?
OpCl works on xts objects but not on quantmod.OHLC objects. Is this a bug? Example error: x.Date <- as.Date("2003-02-01") + c(1, 3, 7, 9, 14) - 1 set.seed(1) x <- zoo(matrix(runif(20, 0, 1), nrow=5, ncol=4), x.Date) q <- as.quantmod.OHLC(x,c("Open","High","Low","Close")) # error OpCl(q) #> Error in `colnames<-`(`*tmp*`, value = "OpCl.q") : #> attempt to set 'colnames' on an object with less than two dimensions # OK OpCl(as.xts(q)) [[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] installing packages
To All, Thanks for your help. I uninstalled R, the 3.2 library and R Studio. Reinstalled R and R Studio. Now the temp files move the newly installed packages into the R-.23.2.4revised library. > .libPaths() [1] "C:/Users/james_henson/Desktop/Documents/R/win-library/3.2" [2] "C:/Program Files/R/R-3.2.4revised/library" On Mon, Mar 21, 2016 at 9:57 PM, Jeff Newmiller <jdnew...@dcn.davis.ca.us> wrote: > I hope not. That directory is not for working in. suggestion to restart R > sounds most likely to fix the issue. > -- > Sent from my phone. Please excuse my brevity. > > On March 21, 2016 2:10:01 PM PDT, KMNanus <kmna...@gmail.com> wrote: >> >> Have you set your working directory to the “3.2” folder? >> Ken >> kmna...@gmail.com >> 914-450-0816 (tel) >> 347-730-4813 (fax) >> >> >> >> On Mar 21, 2016, at 5:07 PM, James Henson <jfhens...@gmail.com> wrote: >>> >>> Dear R community, >>> >>> When I install or update a package, R prints the waring below. I go to the >>> ‘downloaded_packages’ folder in the Temp file and manually move the new or >>> updated package to the folder ‘3.2’. How can I instruct R to download new >>> and updates packages into the ‘3.2’ folder? >>> >>> Warning in install.packages : >>> >>> unable to move temporary installation >>> >>> ‘C:\Users\james_henson\Desktop\Documents\R\win-library\3.2\file1c5c6f1731c8\nlme’ >>> to ‘C:\Users\james_henson\Desktop\Documents\R\win-library\3.2\nlme >>> >>> >>> >>> The downloaded binary packages are in >>> >>> >>> C:\Users\james_henson\AppData\Local\Temp\RtmpIZmUa3\downloaded_packages >>> >>> >>> >>> Thank for your help. >>> >>> James F. Henson >>> >>> [[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. >>> >> >> -- >> >> 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. >> >> [[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.
[R] installing packages
Dear R community, When I install or update a package, R prints the waring below. I go to the ‘downloaded_packages’ folder in the Temp file and manually move the new or updated package to the folder ‘3.2’. How can I instruct R to download new and updates packages into the ‘3.2’ folder? Warning in install.packages : unable to move temporary installation ‘C:\Users\james_henson\Desktop\Documents\R\win-library\3.2\file1c5c6f1731c8\nlme’ to ‘C:\Users\james_henson\Desktop\Documents\R\win-library\3.2\nlme The downloaded binary packages are in C:\Users\james_henson\AppData\Local\Temp\RtmpIZmUa3\downloaded_packages Thank for your help. James F. Henson [[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.
[R] Removing a dollar sign from a character vector
What I’ve got: # sessionInfo() R version 3.2.3 (2015-12-10) Platform: x86_64-apple-darwin13.4.0 (64-bit) Running under: OS X 10.11.3 (El Capitan) locale: [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8 attached base packages: [1] stats graphics grDevices utils datasets methods base other attached packages: [1] XML_3.98-1.3 dplyr_0.4.3 loaded via a namespace (and not attached): [1] magrittr_1.5 R6_2.1.2 assertthat_0.1rsconnect_0.4.1.4 [5] parallel_3.2.3DBI_0.3.1 tools_3.2.3 Rcpp_0.12.3 > str(y) #toy vector, subset of larger vector in a dataframe of ~4,600 rows. chr [1:5] "$1,000.00 " "$1,000.00 " "$1,000.00 " "$2,600.00 " "$2,600.00 “ y is a subset of a column in a dataframe that’s too big to post. I tried the commands listed here on the dataframe and it didn’t work. So I’m using a small subset to find out where my error is. It’s being a PITA, and I’m trying to solve it. What I want is a vector of numbers: 1000, 1000, 1000, 2600, 2,600. What I’ve tried: > y [1] "$1,000.00 " "$1,000.00 " "$1,000.00 " "$2,600.00 " "$2,600.00 " > gsub("$", "", y) [1] "$1,000.00 " "$1,000.00 " "$1,000.00 " "$2,600.00 " "$2,600.00 “ # no change. Why? > gsub(".00", "", y) # note: that’s dot zero zero, replace with “" [1] "$10 " "$10 " "$10 " "$2, " "$2, “ #WTF? I’ve also tried sapply and apply, but haven’t yet tried a loop. (These were done in desperation; gsub ought to work the way the help says.) I’ve tried lots more than is listed here, over and over, with no results. I’d be grateful for any guidance you can provide. Thanks in advance, Jim Plante __ 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] package broom
Dear R community My version is R version 3.2.3. The package "broom" appears to install, but it will not load. The error message is below. > library(broom) Error in loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), versionCheck = vI[[j]]) : there is no package called ‘mnormt’ Error: package or namespace load failed for ‘broom’ Thanks, James F. Henson [[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.
[R] how to plot two variables in a figure using ggplot2
Greetings! You don't specify what type of "figure" you're looking for...here are two possibilities to get you started: As a note, it would have made things slightly easier if you had used dput() to provide the data to us. It took a little massaging in notepad before getting it into R. #Read data from clipboard after removing blank line and column numbers in notepad... mydata <- read.table(file="clipboard", sep=" ", header =TRUE) str(mydata) #Restructure the data to long for ggplot2...there are other ways to do this, also. mydata2 <- data.frame(group=rep(c("OA","KA"), each=9), xvar=rep(mydata$XX, times=2), yvar=c(mydata$OA, mydata$KA)) #Look at format of the data mydata2 #Now to the plotting... require(ggplot2) #You might want a barplot... plot1 <- ggplot(data=mydata2, aes(x=xvar, y=yvar,group=group, fill=group)) + geom_bar(stat="identity", position="dodge") + ggtitle("Barchart of OA and KA") plot1 #..or you might want a lineplot... plot2 <-ggplot(data=mydata2, aes(x=xvar, y=yvar, group=group, colour=group)) + geom_line() + ggtitle("Linechart of OA and KA") plot2 The line chart is very easy to do in ggplot2 even if you don't restructure the data to long format, if that is what you were looking for. Hope this helps and best regards! Jim Gullen, Ph.D Higher Education Data Reporting Consultant Office of Professional Preparation Services Michigan Department of Education Customer Service is a priority at the Michigan Department of Education - helping Michigan schools, families, and communities improve the achievement and well-being of ALL our children. __ 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] value of variable in ls()
> On Oct 18, 2015, at 10:51 AM, Christian Hoffmann <christ...@echoffmann.ch> > wrote: > > How can I do e.g. print("unknown"(ls())) and get the variable values in my > current environment? >From your example, it sounds like what you want is simply this: sapply(ls(), get) James __ 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] rvest and the not css selector
Hi, I'm trying to use rvest to scrape a page and I am having difficulty excluding child element superscripts via a CSS selector. For example, here I've read the html and selected nodes. p <- read_html(targetUrl) p %>% html_nodes("td.xyz") The result looks something like this: {xml_nodeset (20)} [1] Foo9: [2] Bar3: [...] I would like to extract the words "Foo" and "Bar" without the superscripts by passing along to html_text(). I thought something like this would work, but it returns just the superscripts. p %>% html_nodes("td.xyz") %>% html_nodes(":not(sup)") %>% html_text() Perhaps I’m using the not selector improperly. Any suggestions on how to get this to work properly? Thanks. James __ 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] contrasts among simple effects
Greetings R Community My goal is to make orthogonal contrasts among simple effects in analysis of repeated measures data. The SAS publication, on page 1224, shows how to make this type of contrasts in SAS. But, my search of books about repeated measures analysis using R, and on-line has not yielded a methodology. Hopefully, someone can direct me to a book or publication that will show me a methodology. Statistical Analysis of Repeated Measures Data Using SAS Procedures http://cslras.pbworks.com/f/littell_j_anim_sci_76_4_analysis_of_repeated_measures_using_sas.pdf Attached is a csv data file (file name = heartRate.csv). My code for the repeated measures analysis is below. library("nlme") # with AR1 variance/covariance structure, with ordered statement heartRate$time <- factor(heartRate$time) model2a <- lme(HR ~ drug*ordered(time), random =~1|person, correlation =corAR1(, form=~1|person), data = heartRate) summary(model2a) anova(model2a) Making a new variable ‘simple’ that merges the variables drug and time will enable me to make orthogonal contrasts among the simple effects. But, when using the variable ‘simple’ as the independent variable, the data will no longer be fitted to the AR1 variance/co-variance structure. Thanks. Best regards, James F.Henson __ 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] contrasts among simple effects - 2
Greetings R Community Apologize for previously sending a csv file. My goal is to make orthogonal contrasts among simple effects in analysis of repeated measures data. The SAS publication, on page 1224, shows how to make this type of contrasts in SAS. But, my search of books about repeated measures analysis using R, and on-line has not yielded a methodology. Hopefully, someone can direct me to a book or publication that will show me a methodology. Statistical Analysis of Repeated Measures Data Using SAS Procedures http://cslras.pbworks.com/f/littell_j_anim_sci_76_4_analysis_of_repeated_measures_using_sas.pdf Attached is a txt data file (file name = heart_rate.txt). My code for the repeated measures analysis is below. library("nlme") # with AR1 variance/covariance structure, with ordered statement heartRate$time <- factor(heartRate$time) model2a <- lme(HR ~ drug*ordered(time), random =~1|person, correlation =corAR1(, form=~1|person), data = heartRate) summary(model2a) anova(model2a) Making a new variable ‘simple’ that merges the variables drug and time will enable me to make orthogonal contrasts among the simple effects. But, when using the variable ‘simple’ as the independent variable, the data will no longer be fitted to the AR1 variance/covariance structure. Thanks. Best regards, James F.Henson drugperson timeHR a 1 1 72 a 4 1 78 a 7 1 71 a 10 1 72 a 13 1 66 a 16 1 74 a 19 1 62 a 22 1 69 b 2 1 85 b 5 1 82 b 8 1 71 b 11 1 83 b 14 1 86 b 17 1 85 b 20 1 79 b 23 1 83 c 3 1 69 c 6 1 66 c 9 1 84 c 12 1 80 c 15 1 72 c 18 1 65 c 21 1 75 c 24 1 71 a 1 2 86 a 4 2 83 a 7 2 82 a 10 2 83 a 13 2 79 a 16 2 83 a 19 2 73 a 22 2 75 b 2 2 86 b 5 2 86 b 8 2 78 b 11 2 88 b 14 2 85 b 17 2 82 b 20 2 83 b 23 2 84 c 3 2 73 c 6 2 62 c 9 2 90 c 12 2 81 c 15 2 72 c 18 2 62 c 21 2 69 c 24 2 70 a 1 3 81 a 4 3 88 a 7 3 81 a 10 3 83 a 13 3 77 a 16 3 84 a 19 3 78 a 22 3 76 b 2 3 83 b 5 3 80 b 8 3 70 b 11 3 79 b 14 3 76 b 17 3 83 b 20 3 80 b 23 3 78 c 3 3 72 c 6 3 67 c 9 3 88 c 12 3 77 c 15 3 69 c 18 3 65 c 21 3 69 c 24 3 65 a 1 4 77 a 4 4 81 a 7 4 75 a 10 4 69 a 13 4 66 a 16 4 77 a 19 4 70 a 22 4 70 b 2 4 80 b 5 4 84 b 8 4 75 b 11 4 81 b 14 4 76 b 17 4 80 b 20 4 81 b 23 4 81 c 3 4 74 c 6 4 73 c 9 4 87 c 12 4 72 c 15 4 70 c 18 4 61 c 21 4 68 c 24 4 63 __ 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] Two conditions selection
cycle %% filter(col == blue, cycle == 1) On Tue, Aug 4, 2015 at 18:59 Rodrigo Díaz rodlupa...@hotmail.com wrote: Hi. I have a matrix like this: cycle=c(rep(1,3),rep(2,3),rep(3,3),rep(4,3))col=c(rep(blue,2),rep(green,2),rep(blue,2),rep(green,2),rep(blue,2),rep(green,2))values=c(1:12)data.frame(cycle,col,values) # cycle col values#1 1 blue 1#2 1 blue 2#3 1 green 3#4 2 green 4#5 2 blue 5#6 2 blue 6#7 3 green 7#8 3 green 8#9 3 blue 9#10 4 blue 10#11 4 green 11#12 4 green 12 I want to select or extract values matching 2 conditions. For example: values from col blue and cycle 1. If I use : values[col==blue] I get all blue values. I tried using values[c(col==blue,cycle==1)] but is not working. Please help. I have a very big data matrix and I do not wanna go to excel and start cutting the data. Thanks. [[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. [[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] Two conditions selection
Sorry. In dplyr: data %% filter(col == blue, cycle ==1) %% select(values) On Tue, Aug 4, 2015 at 19:54 James Hedges jhedg...@gmail.com wrote: cycle %% filter(col == blue, cycle == 1) On Tue, Aug 4, 2015 at 18:59 Rodrigo Díaz rodlupa...@hotmail.com wrote: Hi. I have a matrix like this: cycle=c(rep(1,3),rep(2,3),rep(3,3),rep(4,3))col=c(rep(blue,2),rep(green,2),rep(blue,2),rep(green,2),rep(blue,2),rep(green,2))values=c(1:12)data.frame(cycle,col,values) # cycle col values#1 1 blue 1#2 1 blue 2#3 1 green 3#4 2 green 4#5 2 blue 5#6 2 blue 6#7 3 green 7#8 3 green 8#9 3 blue 9#10 4 blue 10#11 4 green 11#12 4 green 12 I want to select or extract values matching 2 conditions. For example: values from col blue and cycle 1. If I use : values[col==blue] I get all blue values. I tried using values[c(col==blue,cycle==1)] but is not working. Please help. I have a very big data matrix and I do not wanna go to excel and start cutting the data. Thanks. [[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. [[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.
[R] Combining estimates from multiple regressions
I am interested in using quantile regression to fit the following model at different quantiles of a response variable: (1) y = b0 + b1*g1 + b2*g2 + B*Z where b0 is an intercept, g1 and g2 are dummy variables for 2 of 3 independent groups, and Z is a matrix of covariates to be adjusted for in the estimation (e.g., age, gender). The problem is that estimates for g2 and g1 are not estimable at all quantiles. To overcome this, one option is to fit a separate model for each group (i.e., group 0, which is reflected by intercept above, group 1, and group 2): (2) y = b11 + B1*Z (model for group 0) (3) y = b12 + B2*Z (model for group 1) (4) y = b13 + B3*Z (model for group 2) This would correspond to fitting a single model in which group membership was interacted with all covariates, albeit some of the interaction terms would not be estimable for the reason noted above. However, I ultimately would like to base inferences on a single set of estimates. Can anyone suggest an approach to combine estimates from models (2)-(4), perhaps through weighted averaging, to generate estimates for the model presented in (1) above? An approach is not immediately clear to me since the group effects are subsumed in the intercepts in (2)-(4), whereas (1) includes separate estimates of group effects instead of a single weighted average. Regards, Jim [[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] Combining estimates from multiple regressions
Thanks for the suggestions, Gunter. On Wed, Jun 24, 2015 at 10:33 AM, Bert Gunter bgunter.4...@gmail.com wrote: Not an answer to your question, but you should not be using dummy variables in R. Use factors instead. Please read a R tutorial or text -- there are many -- to learn how to fit models in R. You might also wish to consult a local statistician or post on a statistics list like stats.stackexchange.com for statistics questions, which are off topic here. Further, when you post here, please read and follow the posting guide (below) and post in plain text, not HTML. Cheers, Bert Bert Gunter Data is not information. Information is not knowledge. And knowledge is certainly not wisdom. -- Clifford Stoll On Wed, Jun 24, 2015 at 3:27 AM, James Shaw sha...@gmail.com wrote: I am interested in using quantile regression to fit the following model at different quantiles of a response variable: (1) y = b0 + b1*g1 + b2*g2 + B*Z where b0 is an intercept, g1 and g2 are dummy variables for 2 of 3 independent groups, and Z is a matrix of covariates to be adjusted for in the estimation (e.g., age, gender). The problem is that estimates for g2 and g1 are not estimable at all quantiles. To overcome this, one option is to fit a separate model for each group (i.e., group 0, which is reflected by intercept above, group 1, and group 2): (2) y = b11 + B1*Z (model for group 0) (3) y = b12 + B2*Z (model for group 1) (4) y = b13 + B3*Z (model for group 2) This would correspond to fitting a single model in which group membership was interacted with all covariates, albeit some of the interaction terms would not be estimable for the reason noted above. However, I ultimately would like to base inferences on a single set of estimates. Can anyone suggest an approach to combine estimates from models (2)-(4), perhaps through weighted averaging, to generate estimates for the model presented in (1) above? An approach is not immediately clear to me since the group effects are subsumed in the intercepts in (2)-(4), whereas (1) includes separate estimates of group effects instead of a single weighted average. Regards, Jim [[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. __ 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] [FORGED] Re: Dunnett Test in 'multicomp' package
Thanks. A useful tip for a long-time SAS user. James F. Henson On Fri, Jun 5, 2015 at 3:47 AM, Gerrit Eichner gerrit.eich...@math.uni-giessen.de wrote: Hello, everyone, aside from Rolf's hint (and Richard's warning!) you could also consider relevel(): viagraData$dose - relevel( viagraData$dose, ref = placebo) Hth -- Gerrit On Fri, 5 Jun 2015, Rolf Turner wrote: On 05/06/15 11:08, Jim Lemon wrote: Hi James, You can change the order of levels like this: levels(viagraData$dose)-c(placebo,low dose,high dose) SNIP As Richard Heiberger has pointed out, this is wrong. What *does* work is: viagraData$dose)-factor(viagraData$dose, levels=c(placebo,low dose,high dose) This is a trap into which many a Young Player (including my very good self) has fallen. cheers, Rolf Turner -- Technical Editor ANZJS Department of Statistics University of Auckland Phone: +64-9-373-7599 ext. 88276 __ 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-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. [[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.
[R] Dunnett Test in 'multicomp' package
Greetings Below is my code. library(multcomp) viaModel1 - aov(libido ~ dose, data=viagraData) dunnettModel - glht(viaModel1 , linfct = mcp(dose = Dunnett), base = placebo) The code base=placebo is ignored. All treatments are compared to the first treatment in the order, which is high dose. It is possible to rearrange the order so that placebo' is first, but this is inconvenient. Thanks, James F. Henson [[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.
[R] MCMCglmm Intersex covariance set to 0
Dear all I'm trying to examine the effect that the additive genetic covariance (B) between the sexes has on the predicted response to selection on life-history traits in the sexes. Using the method of Argrawal and Stinchcombe (2009) this is done by calculating the response to selection following the method of Lande (1980): (Delta_Z_Male = 1/2 ( GmB(beta m Delta_Z_Female)B Gf) beta f) when B was estimated from my breeding design versus when it was set to zero to reflect the case where genetic covariance between the sexes does not constrain the evolution of shared life-history traits. My experiment was a half-sib quantitative breeding design which looked at nutrient intake, specifically protein and carbohydrate, using artificial diets of known nutritional content, in males and females. My life history traits are lifespan and reproductive effort. I have used an MCMCglmm model to calculate the response to selection when B was predicted from my breeding design using the following as an example: prior1.1 - list(G = list(G1 = list(V = diag(4), n = 1.002)), R = list(V = diag(4), n = 1.002)) model1.1 - MCMCglmm(cbind(Total_P_Eaten_Male_Daily, Total_C_Eaten_Male_Daily, Total_P_Eaten_Female_Daily, Total_C_Eaten_Female_Daily) ~ trait -1, random = ~us(trait):animal, rcov = ~us(trait):units, family = c(gaussian, gaussian, gaussian, gaussian), pedigree = Ped, data = Data, nitt=15000, thin = 50, burnin=100, prior = prior1.1, verbose = T) modelBM1 - MCMCglmm(Z_MLS ~ Z_MP + Z_MC-1, data = Male.Data, nitt=15000, thin=50, burnin=100) modelBF1 - MCMCglmm(Z_FLS ~ Z_FP + Z_FC-1, data = Female.Data, nitt=15000, thin=50, burnin=100) # Calculate delta_z MP_LS_delta_z-numeric(298) for(i in 1:298){ MP_MP - model1.1$VCV[i, 1] MP_MC - model1.1$VCV[i, 2] MP_FP - model1.1$VCV[i, 3] MP_FC - model1.1$VCV[i, 4] MP_LS - modelBM1$Sol[i, 1] MC_LS - modelBM1$Sol[i, 2] FP_LS - modelBF1$Sol[i, 1] FC_LS - modelBF1$Sol[i, 2] MP_LS_delta_z[i]- ((MP_MP*MP_LS)+(MP_MC*MC_LS)+(MP_FP*FP_LS)+(MP_FC*FC_LS)) } #Summary of deltaz including confidence summary(MP_LS_delta_z) This has allowed me to calculate the confidence interval of my predicted responses and I would like to be able to do this for when my between sex genetic covariance is set to 0, but I am having trouble doing this. Is there a way to set my B to 0? I know how to set all my off diagonal components to 0 but this isn't exactly what I want to do. Here is an example of my G matrix: G1 G2 G3 G4 G1 G1,1G1,2G1,3G1,4 G2 G1,2G2,2G2,3G2,4 G3 G1,3G2,3G3,3G3,4 G4 G1,4G2,4G3,4G4,4 I have read the help (?MCMCglmm) and searched through the R help pages but if the answer is there I'm not able to find/understand it. Any help would be greatly appreciated. Thank you. James Rapkin __ 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] Fwd: PLEASE HELP ON R-LANGUAGE
Subject: PLEASE HELP ON R-LANGUAGE I am writing my project on The effect of Bootstrapping on Time Series Data. My problem is how I will write r programme to run a non stationary time series data. I am familia to r language already. Please help me. [[alternative HTML version deleted]] __ 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-contained, reproducible code.
[R] print vectors with consecutive numbers
Hi all, I have a matrix with consecutive and non-consecutive numbers in columns. For example, the first 2 columns have consecutive numbers. I want R to print only columns with consecutive numbers. Here is the matrix and how I did using conditional statement: ## mat=matrix(data=c(9,2,3,4,5,6,10,13,15,17,19,22, 25,27,29,31,34,37,39,41),ncol=5) mat difference = diff(mat)==1 difference y1=difference[1,] y2=difference[2,] y3=difference[3,] y=(y1|y2|y3) y if (y==TRUE) mat else 0 ## However, R still print all 5 columns, not the first 2 columns I wanted. I got the Warning message: In if (y == TRUE) mat else 0 : the condition has length 1 and only the first element will be used How can I change the code to get only the first 2 columns with consecutive numbers printed? I am new to R. Thanks in advance for your help. James [[alternative HTML version deleted]] __ 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-contained, reproducible code.
Re: [R] print vectors with consecutive numbers
Hi Jorge, Thanks so much, it is working perfectly. There are so many for me to learn. Cheers. James From: jorgeivanve...@gmail.com Date: Fri, 22 Aug 2014 22:28:40 +1000 Subject: Re: [R] print vectors with consecutive numbers To: zwei0...@hotmail.com CC: r-help@r-project.org Hi James, Try mat[, apply(mat, 2, function(x) any(diff(x) == 1))] HTH, Jorge.- On Fri, Aug 22, 2014 at 10:18 PM, James Wei zwei0...@hotmail.com wrote: Hi all, I have a matrix with consecutive and non-consecutive numbers in columns. For example, the first 2 columns have consecutive numbers. I want R to print only columns with consecutive numbers. Here is the matrix and how I did using conditional statement: ## mat=matrix(data=c(9,2,3,4,5,6,10,13,15,17,19,22, 25,27,29,31,34,37,39,41),ncol=5) mat difference = diff(mat)==1 difference y1=difference[1,] y2=difference[2,] y3=difference[3,] y=(y1|y2|y3) y if (y==TRUE) mat else 0 ## However, R still print all 5 columns, not the first 2 columns I wanted. I got the Warning message: In if (y == TRUE) mat else 0 : the condition has length 1 and only the first element will be used How can I change the code to get only the first 2 columns with consecutive numbers printed? I am new to R. Thanks in advance for your help. James [[alternative HTML version deleted]] __ 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-contained, reproducible code. [[alternative HTML version deleted]] __ 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-contained, reproducible code.
Re: [R] Installing manual package problem
Thank you all, I didn't know about the install_github function. Sorry, forgot to switch to plain text On Sat, Aug 9, 2014 at 10:11 AM, Ista Zahn istaz...@gmail.com wrote: If you just want to install the package from github, the easy way is to first install the devtools package and use the install_github function. Best, Ista On Aug 8, 2014 4:21 PM, James Holland holland.ag...@gmail.com wrote: Running R 3.03 on Windows 7 I am trying to install a package from a github repository. https://github.com/google/glassbox I downloaded the repository as a zip file, extracted it to get the glassbox folder and re-zipped it with 7-zip. I then ran #-Start code---# install.packages(C:/Users/jholland/Downloads/glassbox.zip, repos=NULL, type=source) #-# The output message said Installing package into ‘C:/Users/jholland/Documents/R/win-library/3.0’ (as ‘lib’ is unspecified) library(glassbox) Error in library(glassbox) : ‘glassbox’ is not a valid installed package I'm not sure what I'm doing wrong. When I look in the R library folder (...R/win-library/3.0) I see the glassbox folder there. I'm new to using packages not from the CRAN list so I'm trying to learn fast. I tried some searching and this seems to be what I'm suppossed to do, but perhaps I need to use dev mode ? Thank you for the help. ~James [[alternative HTML version deleted]] __ 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-contained, reproducible code. __ 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-contained, reproducible code.
[R] Installing manual package problem
Running R 3.03 on Windows 7 I am trying to install a package from a github repository. https://github.com/google/glassbox I downloaded the repository as a zip file, extracted it to get the glassbox folder and re-zipped it with 7-zip. I then ran #-Start code---# install.packages(C:/Users/jholland/Downloads/glassbox.zip, repos=NULL, type=source) #-# The output message said Installing package into âC:/Users/jholland/Documents/R/win-library/3.0â (as âlibâ is unspecified) library(glassbox) Error in library(glassbox) : âglassboxâ is not a valid installed package I'm not sure what I'm doing wrong. When I look in the R library folder (...R/win-library/3.0) I see the glassbox folder there. I'm new to using packages not from the CRAN list so I'm trying to learn fast. I tried some searching and this seems to be what I'm suppossed to do, but perhaps I need to use dev mode ? Thank you for the help. ~James [[alternative HTML version deleted]] __ 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-contained, reproducible code.
Re: [R] Installing manual package problem
I re-zipped it because when I downloaded from GitHub, it had the actual glassbox folder within the glassbox-master folder, so I zipped that glassbox folder because my understanding was the install.package On Aug 8, 2014, at 1:29 PM, James Holland wrote: Running R 3.03 on Windows 7 I am trying to install a package from a github repository. https://github.com/google/glassbox I downloaded the repository as a zip file, extracted it to get the glassbox folder and re-zipped it with 7-zip. Why? I then ran #-Start code---# install.packages(C:/Users/jholland/Downloads/glassbox.zip, repos=NULL, type=source) I'm a Mac user but when I look at the directory created by expanding that zip file, it appears ready to just move/drag to the library without further installation. It is, however, not named 'glassbox' but rather 'glassbox-master' so perhaps you forgot to rename it? The output message said Installing package into âC:/Users/jholland/Documents/R/win-library/3.0â (as âlibâ is unspecified) library(glassbox) Error in library(glassbox) : âglassboxâ is not a valid installed package I'm not sure what I'm doing wrong. When I look in the R library folder (...R/win-library/3.0) I see the glassbox folder there. I'm new to using packages not from the CRAN list so I'm trying to learn fast. I tried some searching and this seems to be what I'm suppossed to do, but perhaps I need to use dev mode ? Thank you for the help. ~James [[alternative HTML version deleted]] This is a plain text mailing list. -- David Winsemius Alameda, CA, USA [[alternative HTML version deleted]] __ 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-contained, reproducible code.
Re: [R] Installing manual package problem
I re-zipped it because when I downloaded from GitHub, it had the actual glassbox folder within the glassbox-master folder, so I zipped that glassbox folder because my understanding was the install.package function only works on zipped files. And it does seem like it installed within my R library (I see the glassbox folder in there) but the library function doesn't attach the package. ~James On Fri, Aug 8, 2014 at 6:50 PM, David Winsemius dwinsem...@comcast.net wrote: On Aug 8, 2014, at 1:29 PM, James Holland wrote: Running R 3.03 on Windows 7 I am trying to install a package from a github repository. https://github.com/google/glassbox I downloaded the repository as a zip file, extracted it to get the glassbox folder and re-zipped it with 7-zip. Why? I then ran #-Start code---# install.packages(C:/Users/jholland/Downloads/glassbox.zip, repos=NULL, type=source) I'm a Mac user but when I look at the directory created by expanding that zip file, it appears ready to just move/drag to the library without further installation. It is, however, not named 'glassbox' but rather 'glassbox-master' so perhaps you forgot to rename it? The output message said Installing package into âC:/Users/jholland/Documents/R/win-library/3.0â (as âlibâ is unspecified) library(glassbox) Error in library(glassbox) : âglassboxâ is not a valid installed package I'm not sure what I'm doing wrong. When I look in the R library folder (...R/win-library/3.0) I see the glassbox folder there. I'm new to using packages not from the CRAN list so I'm trying to learn fast. I tried some searching and this seems to be what I'm suppossed to do, but perhaps I need to use dev mode ? Thank you for the help. ~James [[alternative HTML version deleted]] This is a plain text mailing list. -- David Winsemius Alameda, CA, USA [[alternative HTML version deleted]] __ 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-contained, reproducible code.
Re: [R] Importing random subsets of a data file
Here's a stack overflow question addressing the same issue. http://stackoverflow.com/a/22261345 Hopefully it will help. Thanks Date: Wed, 23 Jul 2014 12:33:11 -0300 From: khurram.na...@gmail.com To: r-help@r-project.org Subject: [R] Importing random subsets of a data file Hi R folks, Here is my problem. *1.* I have a large data file (say, in .csv or .txt format) containing 1 million rows and 500 variables (columns). *2.* My statistical algorithm does not require the entire dataset but just a small random sample from the original 1 million rows. *3. *This algorithm needs to be applied 1 times, each time generating a different random sample from the 'big' file as described in (2) above. Is there a way to 'import' only a (random) subset of rows from the .csv file without importing the entire dataset? A quick search on various R forums suggest that read.table() does not have this functionality. Obviously, I want to avoid importing the whole file because of memory issues. Looking forward to your help. Thanks, Khurram Khurram Nadeem Postdoctoral Research Fellow Department of Mathematics Statistics Acadia University, NS, Canada. [[alternative HTML version deleted]] __ 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-contained, reproducible code. [[alternative HTML version deleted]] __ 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-contained, reproducible code.
[R] plotGooglemaps - Problem with the legend.
I cannot get the legend to display the cut points I want correctly. Instead of doing the colors at 1, 2, 3, 4, 5 - its doing the color breaks at odd points on the legends. The labels seem to get coded correctly however. # Code Below #. # Messing around with Student Engagement Survey data library(RgoogleMaps) library(PBSmapping) library(maptools) library(reshape) library(RColorBrewer) library(plotGoogleMaps) library(rgdal) rm(list=ls()) mydata - data.frame(NAME=c(James Elem,Chloe MS,Logan HS, Kristen Elem, Heather HS, Nora MS, Elizabeth JH), i1.a.=c(0,1,2, 2.4, 3.5, 4.3, 5), lat = c(32.968, 32.874, 32.884, 32.91538, 32.91810, 32.87884, 32.94468), lon = c(-96.692, -96.725, -96.708, -96.72321, -96.71760, -96.73990, -96.72850) ) # --- # # --- # # -- Ploting School Locations --- # coordinates(mydata) - ~lon + lat proj4string(mydata) - CRS(+proj=longlat +datum=WGS84) #SchoolRaceP - SpatialPointsDataFrame, data # Playing around with various options m - plotGoogleMaps(mydata, zcol=i1.a., at=0:4, colPalette = c(#FF,#FF9900,#00,#0066FF,#00CC00), layerName=Some Schools, filename=MyMap.html) [[alternative HTML version deleted]] __ 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-contained, reproducible code.
[R] Ridge regression for beta and gamma models
Dear All, Please, is there any package in R that has implemented ridge regression for beta and gamma models? If not, kindly help me to adjust my model below for the beta regression so as to accommodate ridge penalty. Thanks. lbeta - function(par,y,X){ n -length(y) k - ncol(X) beta - par[1:k] phi - par[k+1] if(phi 0)return(NA) mu - X%*%beta val - vector() mu - X%*%beta mul - exp(mu)/(1+exp(mu)) p - phi*mul; q - phi*(1-mul) for(i in 1:n) val[i] - dbeta(y[i],p[i,],q[i,],log=TRUE) return(-sum(val)) } James [[alternative HTML version deleted]] __ 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-contained, reproducible code.
[R] Pull Stock Symbol Out of String
Dear R Helpers, My regex skills are beginner to intermediate and banging around the web has not resulted in a solution to the problem below so I hope that one of you who has mad skills can help me out. I want to extract the stock ticker--AMT-- out of the string American Tower Corporation (REIT) (AMT) The presence of the other parenthetical text (REIT) makes this difficult. Please note that the string may or may not have a interfering set of characters such as the (REIT) so the solution needs to be generalizable to the last set of characters that are contained in parentheses in the larger string. So an example of a string without the interfering (REIT) would be Aetna Inc. (AET) Your assistance would be very much appreciated. --John Sparks __ 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-contained, reproducible code.
[R] rehh package for iHS and Rsb on NGS data
Hello expert community. Is there anybody whose used rehh package for iHS and rsb. I have gone through the tutorial a dozen times, I need expert help to enable me apply it to my p.falciparum snp data from the illumina platform. Thanks James Abugri -- * The information contained in this email and any attachments may be legally privileged and confidential. If you are not an intended recipient, you are hereby notified that any dissemination, distribution, or copying of this e-mail is strictly prohibited. If you have received this e-mail in error, please notify the sender and permanently delete the e-mail and any attachments immediately. You should not retain, copy or use this e-mail or any attachments for any purpose, nor disclose all or any part of the contents to any other person.* [[alternative HTML version deleted]] __ 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-contained, reproducible code.
[R] looping in R
I ran the following loop on my SNP data and got an error message as indicated for (i in genenames){ + current - fst1[which(fst1$Gene == i),] + num - nrow(current) + fst - max(current$fst) + position - mean(current$pos) + nposition - mean(current$newpos) + numhigh - nrow(current[which(current$fst threshold),]) + colors - mean(current$colors) + output - matrix(NA,nrow=1,ncol=8) + numthresh - paste(# SNPs Fst = , threshold, sep=) + colnames(output) - c(gene, gene_old, pos, newpos, # Snps, numthresh, Max.Fst, colors) + output[1,1] - i + output[1,2] - as.character(current[1, gene_old]) + output[1,3] - position + output[1,4] - nposition + output[1,5] - num + output[1,6] - numhigh + output[1,7] - fst + output[1,8] - colors + maxfstgene - rbind(maxfstgene, output) + } Error in output[1, 2] - as.character(current[1, gene_old]) : replacement has length zero In addition: Warning message: In mean.default(current$pos) : argument is not numeric or logical: returning NA -- -- * The information contained in this email and any attachments may be legally privileged and confidential. If you are not an intended recipient, you are hereby notified that any dissemination, distribution, or copying of this e-mail is strictly prohibited. If you have received this e-mail in error, please notify the sender and permanently delete the e-mail and any attachments immediately. You should not retain, copy or use this e-mail or any attachments for any purpose, nor disclose all or any part of the contents to any other person.* [[alternative HTML version deleted]] __ 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-contained, reproducible code.
[R] Emacs/R/SSH But View( ) Doesn't Work
I successfully run Emacs on a Windows laptop then use Emacs' Tramp to connect to a Linux server using SSH. Emacs in this fashion supports editing .R files resident on the remote machine and running of R in an inferior Emacs shell. The R process runs on the server. Also, I successfully use Putty and Xming to allow display of R plots executed in R on the remote machine to be displayed on the Windows laptop. One last thing that would complete this configuration is if I could use the R View( ) command to look at data frames resident within the R process. The following is the error: View(cars) Error in .External2(C_dataviewer, x, title) : invalid device In addition: Warning message: In View(cars) : unable to open display Has anyone been able to either get View( ) to work under this configuration or devised another solution? I have used Sweave with xtable and then displayed the pdf file in the Putty/Xming window on the laptop but this is slow. Thanks, Dr. Jim Allison [[alternative HTML version deleted]] __ 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-contained, reproducible code.
[R] Font Path question
I am having weird problems where more recent installs of R cannot find the Font path. I don't have sudo access, so install R in my personal directory on an Ubuntu box, from source. $ ls -lah R-3.0.1/bin/ | grep -w R -rwxr-xr-x 1 jmacdon staff 8.5K Aug 30 14:04 R $ ls -lah R-3.0.2/bin/ | grep -w R -rwxr-xr-x 1 jmacdon staff 8.5K Sep 26 09:24 R $ ls -lah R-2.15.1/bin/ | grep -w R -rwxr-xr-x 1 jmacdon staff 8.5K Dec 19 12:58 R $ ls -lah R-devel/bin/ | grep -w R -rwxr-xr-x 1 jmacdon staff 8.5K Feb 11 09:47 R Neither R-2.15.1 nor R-devel can find the Font Path, but R-3.0.1 and R-3.0.2 can: plot(1:10) ## no problems here sessionInfo() R version 3.0.2 (2013-09-25) Platform: x86_64-unknown-linux-gnu (64-bit) locale: [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C [3] LC_TIME=en_US.UTF-8LC_COLLATE=en_US.UTF-8 [5] LC_MONETARY=en_US.UTF-8LC_MESSAGES=en_US.UTF-8 [7] LC_PAPER=en_US.UTF-8 LC_NAME=C [9] LC_ADDRESS=C LC_TELEPHONE=C [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C attached base packages: [1] stats graphics grDevices utils datasets methods base plot(1:10) #urgh Error in axis(side = side, at = at, labels = labels, ...) : could not find any X11 fonts Check that the Font Path is correct. sessionInfo() R Under development (unstable) (2014-02-10 r64961) Platform: x86_64-unknown-linux-gnu (64-bit) locale: [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C [3] LC_TIME=en_US.UTF-8LC_COLLATE=en_US.UTF-8 [5] LC_MONETARY=en_US.UTF-8LC_MESSAGES=en_US.UTF-8 [7] LC_PAPER=en_US.UTF-8 LC_NAME=C [9] LC_ADDRESS=C LC_TELEPHONE=C [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C attached base packages: [1] stats graphics grDevices utils datasets methods base Any suggestions as to how I might track this down? Best, Jim -- James W. MacDonald, M.S. Biostatistician University of Washington Environmental and Occupational Health Sciences 4225 Roosevelt Way NE, # 100 Seattle WA 98105-6099 __ 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-contained, reproducible code.
[R] Best practices for loading large datasets into R
Hello, I'm working with a 22 GB datasets with ~100 million observations and ~40 variables. It's store in SQLite and I use the RSQLite package to load it into memory. Loading the full population, even for only a few variables, can be very slow and I was wondering if there are best practices for how to manage large datasets when doing analysis in R. Is there an alternative file format / relational datbase in which I should be storing the data? Best, James -- James F. Mahon III, Ph.D. Candidate Harvard University Tel: (857) 209-8438 Fax: (270) 813-3498 Web: http://www.people.fas.harvard.edu/~jmahon/ [[alternative HTML version deleted]] __ 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-contained, reproducible code.
Re: [R] [BioC] Why daisy() in cluster library failed to exclude NA when computing dissimilarity
Hi Gundala, This question isn't about a Bioconductor package, so should be asked on R-help instead. Best, Jim On Sunday, December 08, 2013 2:11:12 AM, Gundala Viswanath wrote: Hi, According to daisy function from cluster documentation, it can compute dissimilarity when NA (missing) value(s) is present. http://stat.ethz.ch/R-manual/R-devel/library/cluster/html/daisy.html But why when I tried this code library(cluster) x - c(1.115,NA,NA,0.971,NA) y - c(NA,1.006,NA,NA,0.645) df - as.data.frame(rbind(x,y)) daisy(df,metric=gower) It gave this message: Dissimilarities : x y NA Metric : mixed ; Types = I, I, I, I, I Number of objects : 2 Warning messages: 1: In min(x) : no non-missing arguments to min; returning Inf 2: In max(x) : no non-missing arguments to max; returning -Inf I welcome other alternative than gower. I expect the dissimilarity output gives a non-NA value e.g. 0. What's the right way to do it? G.V. ___ Bioconductor mailing list bioconduc...@r-project.org https://stat.ethz.ch/mailman/listinfo/bioconductor Search the archives: http://news.gmane.org/gmane.science.biology.informatics.conductor -- James W. MacDonald, M.S. Biostatistician University of Washington Environmental and Occupational Health Sciences 4225 Roosevelt Way NE, # 100 Seattle WA 98105-6099 __ 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-contained, reproducible code.
[R] Finding absolute viewport location in grid / lattice
I'm trying to do some post-plot manipulation of some lattice graphics, in which I need to get the absolute viewport locations on the plotting device. So for example: library(lattice) print(xyplot(Petal.Length ~ Sepal.Length | Species, iris, layout = c(2, 2))) trellis.focus('panel', 1, 1) This shows the item I want to identify. I need to know, for example, that the lower left corner of the highlighted panel is at (0.1, 0.1) of the plotting device. Hopefully there's some grid shenanigans I can use to do so. To put the question into context (in case there's an alternative way): I'm constructing PDF reports that are an amalgam of PDF figures, constructed through LaTeX programmatically constructed in R, and I'd like to be able to add tooltips to some of the data points on the graphs. To do so, I'm overlaying a tikz (empty) image that uses the pdfcomment package to add the tooltips. Hence I need to be able to calculate where some of the points are on the screen so I can calculate where to put the tooltip 'hit-zones'. This would be fairly trivial using javascript / actionscript and mouseover hooks, but I'm constrained by PDF. Thanks, Jim Price. Strength in Numbers. [[alternative HTML version deleted]] __ 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-contained, reproducible code.
[R] [R-pkgs] scholar 0.1.0 on CRAN
Dear R users, A new package 'scholar' (version 0.1.0) is now available on CRAN: http://cran.r-project.org/web/packages/scholar/index.html. The scholar package provides functions to extract citation data from Google Scholar. In addition to retrieving basic information about a single scholar, the package also allows you to compare multiple scholars and predict future h-index values based on the method of Acuna et al. For example, we can compare the careers of Richard Feynman and Stephen Hawking as follows: ids - c('B7vSqZsJ', 'qj74uXkJ') df - compare_scholar_careers(ids) ggplot(df, aes(x=career_year, y=cites)) + geom_line(aes(linetype=name)) For more information and examples of how to use the package, please see https://github.com/jkeirstead/scholar. Your comments and suggestions would be appreciated. Best wishes, James -- Dr James Keirstead Lecturer Dept of Civil and Environmental Engineering Imperial College South Kensington, London SW7 2AZ ___ R-packages mailing list r-packa...@r-project.org https://stat.ethz.ch/mailman/listinfo/r-packages __ 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-contained, reproducible code.
[R] Windows The system cannot find the path specified error when submitting R in batch mode
This is an R and operating system related question. I am not able to submit an R program to be executed in batch mode by Windows. I have confirmed the location of the R.exe file. I am following the directions I found in Quick-R, but neither of the following work from a DOS prompt ... D:\chip\Projects\Crescendo Bioscience\Studies\024-CL-01 - BRASS FM\biostat\programs\R\024-CL-01 - BRASS FM - ManuscriptC:\Program Files\R\R-2.15.2\bin\R.exe CMD BATCH boxplotByMBDAAndCRP.R The system cannot find the path specified. D:\chip\Projects\Crescendo Bioscience\Studies\024-CL-01 - BRASS FM\biostat\programs\R\024-CL-01 - BRASS FM - ManuscriptC:\Program Files\R\R-2.15.2\bin\R.exe CMD BATCH D:\chip\Projects\Crescendo Bioscience\Studies\024-CL-01 - BRASS FM\biostat\programs\R\024-CL-01 - BRASS FM - Manuscript\boxplotByMBDAAndCRP.R The system cannot find the path specified. Thank you for any help you can provide, Chip James Chip Hackett, Ph.D. | Statistical Consultant | Hackett Associates, Inc. | c...@hackettassociates.net | 408.416.3747 (Office) | 805.509.0741 (Mobile) The material in this transmission may contain confidential information intended only for the addressee. If you are not the addressee, any disclosure or use of this information by you is strictly prohibited. If you have received this transmission in error, please delete it, destroy all copies, and notify the sender immediately by reply or by calling 1-408-416-3747. [[alternative HTML version deleted]] __ 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-contained, reproducible code.
Re: [R] Grap Element from Web Page
Thanks, the second approach worked fine on Windows. --JJS On Thu, August 15, 2013 8:38 am, Jeffrey Dick wrote: Sorry, I can't generate an error when running those commands in R on Linux 64-bit. But if I move to Windows (R version 3.0.1, XML_3.98-1.1), I get a different error ... require(XML) Loading required package: XML doc - htmlTreeParse( http://www.sec.gov/cgi-bin/browse-edgar?CIK=MSFTFind=Searchowner=excludeaction=getcompany ) node - getNodeSet(doc[[1]], //link[@rel='alternate'] ) Input is not proper UTF-8, indicate encoding ! Bytes: 0xC2 0x0A 0x20 0x20 Error: 1: Input is not proper UTF-8, indicate encoding ! Bytes: 0xC2 0x0A 0x20 0x20 node - getNodeSet(doc, //link[@rel='alternate'] ) Error in UseMethod(xpathApply) : no applicable method for 'xpathApply' applied to an object of class XMLDocumentContent ... note that I've tried both doc[[1]] and doc in the function call. Also, only the XML library is required. I'm not sure what's going on with the character encoding error, might be my system settings. Reading the help page (?htmlTreeParse) provides a clue to use the htmlParse function instead, equivalent to setting the useInternalNodes parameter to TRUE ... These can then be searched using XPath expressions via 'xpathApply' and 'getNodeSet'. That seems to be relevant to this case. doc - htmlParse( http://www.sec.gov/cgi-bin/browse-edgar?CIK=MSFTFind=Searchowner=excludeaction=getcompany ) node - xpathSApply(doc, //link[@rel='alternate'], xmlAttrs) node [,1] rel alternate type application/atom+xml title ATOM href /cgi-bin/browse-edgar?action=getcompanyCIK=789019type=dateb=owner=excludecount=40output=atom strsplit(strsplit(node[[4]], CIK=)[[1]][2], type)[[1]][1] [1] 789019 Perhaps that approach is less prone to error. On Thu, Aug 15, 2013 at 12:48 PM, Sparks, John James jspa...@uic.eduwrote: Thanks so much for looking into this for me. Unfortunately, I get an error when I execute your code. Is there a library that you loaded that I haven't? require(scrapeR) require(XML) require(RCurl) doc-htmlTreeParse( http://www.sec.gov/cgi-bin/browse-edgar?CIK=MSFTFind=Searchowner=excludeaction=getcompany ) node - getNodeSet(doc[[1]], //link[@rel='alternate'] ) Error in UseMethod(xpathApply) : no applicable method for 'xpathApply' applied to an object of class character Guidance would be much appreciated. --JJS On Wed, August 14, 2013 4:19 am, Jeffrey Dick wrote: Hi, There are many occurrences of the CIK number in the page source. This pulls out the first node containing it: node - getNodeSet(doc[[1]], //link[@rel='alternate'] ) From there you can extract the number. Here's one way to do it. strsplit(strsplit(unlist(node)[[5]], CIK=)[[1]][2], type)[[1]][1] Jeff On Wed, Aug 14, 2013 at 1:34 PM, Sparks, John James jspa...@uic.edu wrote: Dear R Helpers, I would like to pull the CIK number from the web page http://www.sec.gov/cgi-bin/browse-edgar?CIK=MSFTFind=Searchowner=excludeaction=getcompany If you put this web page into your browser you will see the CIK number in red on the left side of the page near the top. When I try the basic require(scrapeR) require(XML) require(RCurl) doc -htmlTreeParse( http://www.sec.gov/cgi-bin/browse-edgar?CIK=MSFTFind=Searchowner=excludeaction=getcompany ) str(doc) I get a large number of items in the data frame that I don't know how to interpret. Both tables - readHTMLTable(doc) and list-xmlToList(doc) result in errors. Any (positive) guidance would be much appreciated. --John J. Sparks, Ph.D. __ 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-contained, reproducible code. __ 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-contained, reproducible code.
Re: [R] Grap Element from Web Page
Thanks so much for looking into this for me. Unfortunately, I get an error when I execute your code. Is there a library that you loaded that I haven't? require(scrapeR) require(XML) require(RCurl) doc-htmlTreeParse(http://www.sec.gov/cgi-bin/browse-edgar?CIK=MSFTFind=Searchowner=excludeaction=getcompany;) node - getNodeSet(doc[[1]], //link[@rel='alternate'] ) Error in UseMethod(xpathApply) : no applicable method for 'xpathApply' applied to an object of class character Guidance would be much appreciated. --JJS On Wed, August 14, 2013 4:19 am, Jeffrey Dick wrote: Hi, There are many occurrences of the CIK number in the page source. This pulls out the first node containing it: node - getNodeSet(doc[[1]], //link[@rel='alternate'] ) From there you can extract the number. Here's one way to do it. strsplit(strsplit(unlist(node)[[5]], CIK=)[[1]][2], type)[[1]][1] Jeff On Wed, Aug 14, 2013 at 1:34 PM, Sparks, John James jspa...@uic.edu wrote: Dear R Helpers, I would like to pull the CIK number from the web page http://www.sec.gov/cgi-bin/browse-edgar?CIK=MSFTFind=Searchowner=excludeaction=getcompany If you put this web page into your browser you will see the CIK number in red on the left side of the page near the top. When I try the basic require(scrapeR) require(XML) require(RCurl) doc -htmlTreeParse( http://www.sec.gov/cgi-bin/browse-edgar?CIK=MSFTFind=Searchowner=excludeaction=getcompany ) str(doc) I get a large number of items in the data frame that I don't know how to interpret. Both tables - readHTMLTable(doc) and list-xmlToList(doc) result in errors. Any (positive) guidance would be much appreciated. --John J. Sparks, Ph.D. __ 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-contained, reproducible code. __ 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-contained, reproducible code.
[R] Grap Element from Web Page
Dear R Helpers, I would like to pull the CIK number from the web page http://www.sec.gov/cgi-bin/browse-edgar?CIK=MSFTFind=Searchowner=excludeaction=getcompany If you put this web page into your browser you will see the CIK number in red on the left side of the page near the top. When I try the basic require(scrapeR) require(XML) require(RCurl) doc -htmlTreeParse(http://www.sec.gov/cgi-bin/browse-edgar?CIK=MSFTFind=Searchowner=excludeaction=getcompany;) str(doc) I get a large number of items in the data frame that I don't know how to interpret. Both tables - readHTMLTable(doc) and list-xmlToList(doc) result in errors. Any (positive) guidance would be much appreciated. --John J. Sparks, Ph.D. __ 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-contained, reproducible code.