Re: [R] Installed packages: Bioconductor vs CRAN?
[working version] On 9/25/2021 2:55 AM, Leonard Mada wrote: Dear List Members, Is there a way to extract if an installed package is from Bioconductor or if it is a regular Cran package? The information seems to be *not* available in: installed.packages() ### [updated] # Basic Info: info.pkg = function(pkg=NULL, fields="Repository") { if(is.null(pkg)) { pkg = installed.packages(fields=fields); } else { all.pkg = installed.packages(); pkg = all.pkg[all.pkg[,1] %in% pkg, ]; } p = pkg; p = as.data.frame(p); p = p[ , c("Package", "Version", "Built", fields, "Imports")]; return(p); } I will think later how to improve the filtering of Bioconductor packages. Probably based on biocViews. Many thanks, Leonard Sincerely, Leonard === I started to write some utility functions to analyse installed packages. The latest version is on Github: https://github.com/discoleo/R/blob/master/Stat/Tools.CRAN.R # Basic Info: info.pkg = function(pkg=NULL) { if(is.null(pkg)) { pkg = installed.packages(); } else { all.pkg = installed.packages(); pkg = all.pkg[all.pkg[,1] %in% pkg, ]; } p = pkg; p = as.data.frame(p); p = p[ , c("Package", "Version", "Built", "Imports")]; return(p); } # Imported packages: imports.pkg = function(pkg=NULL, sort=TRUE) { p = info.pkg(pkg); ### Imported packages imp = lapply(p$Imports, function(s) strsplit(s, "[,][ ]*")) imp = unlist(imp) imp = imp[ ! is.na(imp)] # Cleanup: imp = sub("[ \n\r\t]*+\\([-,. >=0-9\n\t\r]++\\) *+$", "", imp, perl=TRUE) imp = sub("^[ \n\r\t]++", "", imp, perl=TRUE); # Tabulate: tbl = as.data.frame(table(imp), stringsAsFactors=FALSE); names(tbl)[1] = "Name"; if(sort) { id = order(tbl$Freq, decreasing=TRUE); tbl = tbl[id,]; } return(tbl); } match.imports = function(pkg, x=NULL, quote=FALSE) { if(is.null(x)) x = info.pkg(); if(quote) { pkg = paste0("\\Q", pkg, "\\E"); } # TODO: Use word delimiters? # "( __ 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] Installed packages: Bioconductor vs CRAN?
Dear Bert, Indeed, this seems to work: installed.packages(fields="Repository") I still need to figure out what variants to expect. Sincerely, Leonard On 9/25/2021 3:31 AM, Leonard Mada wrote: Dear Bert, The DESCRIPTION file contains additional useful information, e.g.: 1.) Package EBImage: biocViews: Visualization Packaged: 2021-05-19 23:53:29 UTC; biocbuild 2.) deSolve Repository: CRAN I have verified a few of the CRAN packages, and they seem to include the tag: Repository: CRAN The Bioconductor packages are different (see e.g. EBImage). I am wondering if there is already a method to extract this info? Sincerely, Leonard On 9/25/2021 3:06 AM, Bert Gunter wrote: The help file tells you that installed.packages() looks at the DESCRIPTION files of packages. Section 1.1.1 of "Writing R Extensions" tells you what information is in such files. 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 Fri, Sep 24, 2021 at 4:56 PM Leonard Mada via R-help wrote: Dear List Members, Is there a way to extract if an installed package is from Bioconductor or if it is a regular Cran package? The information seems to be *not* available in: installed.packages() Sincerely, Leonard === I started to write some utility functions to analyse installed packages. The latest version is on Github: https://github.com/discoleo/R/blob/master/Stat/Tools.CRAN.R # Basic Info: info.pkg = function(pkg=NULL) { if(is.null(pkg)) { pkg = installed.packages(); } else { all.pkg = installed.packages(); pkg = all.pkg[all.pkg[,1] %in% pkg, ]; } p = pkg; p = as.data.frame(p); p = p[ , c("Package", "Version", "Built", "Imports")]; return(p); } # Imported packages: imports.pkg = function(pkg=NULL, sort=TRUE) { p = info.pkg(pkg); ### Imported packages imp = lapply(p$Imports, function(s) strsplit(s, "[,][ ]*")) imp = unlist(imp) imp = imp[ ! is.na(imp)] # Cleanup: imp = sub("[ \n\r\t]*+\\([-,. >=0-9\n\t\r]++\\) *+$", "", imp, perl=TRUE) imp = sub("^[ \n\r\t]++", "", imp, perl=TRUE); # Tabulate: tbl = as.data.frame(table(imp), stringsAsFactors=FALSE); names(tbl)[1] = "Name"; if(sort) { id = order(tbl$Freq, decreasing=TRUE); tbl = tbl[id,]; } return(tbl); } match.imports = function(pkg, x=NULL, quote=FALSE) { if(is.null(x)) x = info.pkg(); if(quote) { pkg = paste0("\\Q", pkg, "\\E"); } # TODO: Use word delimiters? # "(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] Installed packages: Bioconductor vs CRAN?
Dear Bert, The DESCRIPTION file contains additional useful information, e.g.: 1.) Package EBImage: biocViews: Visualization Packaged: 2021-05-19 23:53:29 UTC; biocbuild 2.) deSolve Repository: CRAN I have verified a few of the CRAN packages, and they seem to include the tag: Repository: CRAN The Bioconductor packages are different (see e.g. EBImage). I am wondering if there is already a method to extract this info? Sincerely, Leonard On 9/25/2021 3:06 AM, Bert Gunter wrote: The help file tells you that installed.packages() looks at the DESCRIPTION files of packages. Section 1.1.1 of "Writing R Extensions" tells you what information is in such files. 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 Fri, Sep 24, 2021 at 4:56 PM Leonard Mada via R-help wrote: Dear List Members, Is there a way to extract if an installed package is from Bioconductor or if it is a regular Cran package? The information seems to be *not* available in: installed.packages() Sincerely, Leonard === I started to write some utility functions to analyse installed packages. The latest version is on Github: https://github.com/discoleo/R/blob/master/Stat/Tools.CRAN.R # Basic Info: info.pkg = function(pkg=NULL) { if(is.null(pkg)) { pkg = installed.packages(); } else { all.pkg = installed.packages(); pkg = all.pkg[all.pkg[,1] %in% pkg, ]; } p = pkg; p = as.data.frame(p); p = p[ , c("Package", "Version", "Built", "Imports")]; return(p); } # Imported packages: imports.pkg = function(pkg=NULL, sort=TRUE) { p = info.pkg(pkg); ### Imported packages imp = lapply(p$Imports, function(s) strsplit(s, "[,][ ]*")) imp = unlist(imp) imp = imp[ ! is.na(imp)] # Cleanup: imp = sub("[ \n\r\t]*+\\([-,. >=0-9\n\t\r]++\\) *+$", "", imp, perl=TRUE) imp = sub("^[ \n\r\t]++", "", imp, perl=TRUE); # Tabulate: tbl = as.data.frame(table(imp), stringsAsFactors=FALSE); names(tbl)[1] = "Name"; if(sort) { id = order(tbl$Freq, decreasing=TRUE); tbl = tbl[id,]; } return(tbl); } match.imports = function(pkg, x=NULL, quote=FALSE) { if(is.null(x)) x = info.pkg(); if(quote) { pkg = paste0("\\Q", pkg, "\\E"); } # TODO: Use word delimiters? # "(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] Installed packages: Bioconductor vs CRAN?
Oh, I should have added that packages can be on other repositories (local, github,...) and I think can be both in CRAN and BIOC . So your query would not seem to have a clear answer. AFAICS anyway. 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 Fri, Sep 24, 2021 at 5:06 PM Bert Gunter wrote: > > The help file tells you that installed.packages() looks at the > DESCRIPTION files of packages. > Section 1.1.1 of "Writing R Extensions" tells you what information is > in such files. > > > 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 Fri, Sep 24, 2021 at 4:56 PM Leonard Mada via R-help > wrote: > > > > Dear List Members, > > > > > > Is there a way to extract if an installed package is from Bioconductor > > or if it is a regular Cran package? > > > > > > The information seems to be *not* available in: > > > > installed.packages() > > > > > > Sincerely, > > > > > > Leonard > > > > === > > > > I started to write some utility functions to analyse installed packages. > > The latest version is on Github: > > https://github.com/discoleo/R/blob/master/Stat/Tools.CRAN.R > > > > > > # Basic Info: > > info.pkg = function(pkg=NULL) { > > if(is.null(pkg)) { pkg = installed.packages(); } > > else { > > all.pkg = installed.packages(); > > pkg = all.pkg[all.pkg[,1] %in% pkg, ]; > > } > > p = pkg; > > p = as.data.frame(p); > > p = p[ , c("Package", "Version", "Built", "Imports")]; > > return(p); > > } > > # Imported packages: > > imports.pkg = function(pkg=NULL, sort=TRUE) { > > p = info.pkg(pkg); > > ### Imported packages > > imp = lapply(p$Imports, function(s) strsplit(s, "[,][ ]*")) > > imp = unlist(imp) > > imp = imp[ ! is.na(imp)] > > # Cleanup: > > imp = sub("[ \n\r\t]*+\\([-,. >=0-9\n\t\r]++\\) *+$", "", imp, > > perl=TRUE) > > imp = sub("^[ \n\r\t]++", "", imp, perl=TRUE); > > # Tabulate: > > tbl = as.data.frame(table(imp), stringsAsFactors=FALSE); > > names(tbl)[1] = "Name"; > > if(sort) { > > id = order(tbl$Freq, decreasing=TRUE); > > tbl = tbl[id,]; > > } > > return(tbl); > > } > > > > match.imports = function(pkg, x=NULL, quote=FALSE) { > > if(is.null(x)) x = info.pkg(); > > if(quote) { > > pkg = paste0("\\Q", pkg, "\\E"); > > } > > # TODO: Use word delimiters? > > # "( > if(length(pkg) == 1) { > > isImport = grepl(pkg, x$Imports); > > return(x[isImport, ]); > > } else { > > # TODO: concept? > > rez = lapply(pkg, function(p) x[grepl(p, x$Imports), ]); > > return(rez); > > } > > } > > > > Examples: > > > > p = info.pkg(); > > f = imports.pkg(); > > > > ### Analyze data > > > > # imported only once: (only in the locally installed packages) > > f$Name[f$Freq == 1] > > > > match.imports("hunspell", p) > > match.imports("labeling", p) > > match.imports("rpart.plot", p) > > > > match.imports(c("pROC", "ROCR"), 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-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] Installed packages: Bioconductor vs CRAN?
The help file tells you that installed.packages() looks at the DESCRIPTION files of packages. Section 1.1.1 of "Writing R Extensions" tells you what information is in such files. 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 Fri, Sep 24, 2021 at 4:56 PM Leonard Mada via R-help wrote: > > Dear List Members, > > > Is there a way to extract if an installed package is from Bioconductor > or if it is a regular Cran package? > > > The information seems to be *not* available in: > > installed.packages() > > > Sincerely, > > > Leonard > > === > > I started to write some utility functions to analyse installed packages. > The latest version is on Github: > https://github.com/discoleo/R/blob/master/Stat/Tools.CRAN.R > > > # Basic Info: > info.pkg = function(pkg=NULL) { > if(is.null(pkg)) { pkg = installed.packages(); } > else { > all.pkg = installed.packages(); > pkg = all.pkg[all.pkg[,1] %in% pkg, ]; > } > p = pkg; > p = as.data.frame(p); > p = p[ , c("Package", "Version", "Built", "Imports")]; > return(p); > } > # Imported packages: > imports.pkg = function(pkg=NULL, sort=TRUE) { > p = info.pkg(pkg); > ### Imported packages > imp = lapply(p$Imports, function(s) strsplit(s, "[,][ ]*")) > imp = unlist(imp) > imp = imp[ ! is.na(imp)] > # Cleanup: > imp = sub("[ \n\r\t]*+\\([-,. >=0-9\n\t\r]++\\) *+$", "", imp, > perl=TRUE) > imp = sub("^[ \n\r\t]++", "", imp, perl=TRUE); > # Tabulate: > tbl = as.data.frame(table(imp), stringsAsFactors=FALSE); > names(tbl)[1] = "Name"; > if(sort) { > id = order(tbl$Freq, decreasing=TRUE); > tbl = tbl[id,]; > } > return(tbl); > } > > match.imports = function(pkg, x=NULL, quote=FALSE) { > if(is.null(x)) x = info.pkg(); > if(quote) { > pkg = paste0("\\Q", pkg, "\\E"); > } > # TODO: Use word delimiters? > # "( if(length(pkg) == 1) { > isImport = grepl(pkg, x$Imports); > return(x[isImport, ]); > } else { > # TODO: concept? > rez = lapply(pkg, function(p) x[grepl(p, x$Imports), ]); > return(rez); > } > } > > Examples: > > p = info.pkg(); > f = imports.pkg(); > > ### Analyze data > > # imported only once: (only in the locally installed packages) > f$Name[f$Freq == 1] > > match.imports("hunspell", p) > match.imports("labeling", p) > match.imports("rpart.plot", p) > > match.imports(c("pROC", "ROCR"), 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-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] Installed packages: Bioconductor vs CRAN?
Dear List Members, Is there a way to extract if an installed package is from Bioconductor or if it is a regular Cran package? The information seems to be *not* available in: installed.packages() Sincerely, Leonard === I started to write some utility functions to analyse installed packages. The latest version is on Github: https://github.com/discoleo/R/blob/master/Stat/Tools.CRAN.R # Basic Info: info.pkg = function(pkg=NULL) { if(is.null(pkg)) { pkg = installed.packages(); } else { all.pkg = installed.packages(); pkg = all.pkg[all.pkg[,1] %in% pkg, ]; } p = pkg; p = as.data.frame(p); p = p[ , c("Package", "Version", "Built", "Imports")]; return(p); } # Imported packages: imports.pkg = function(pkg=NULL, sort=TRUE) { p = info.pkg(pkg); ### Imported packages imp = lapply(p$Imports, function(s) strsplit(s, "[,][ ]*")) imp = unlist(imp) imp = imp[ ! is.na(imp)] # Cleanup: imp = sub("[ \n\r\t]*+\\([-,. >=0-9\n\t\r]++\\) *+$", "", imp, perl=TRUE) imp = sub("^[ \n\r\t]++", "", imp, perl=TRUE); # Tabulate: tbl = as.data.frame(table(imp), stringsAsFactors=FALSE); names(tbl)[1] = "Name"; if(sort) { id = order(tbl$Freq, decreasing=TRUE); tbl = tbl[id,]; } return(tbl); } match.imports = function(pkg, x=NULL, quote=FALSE) { if(is.null(x)) x = info.pkg(); if(quote) { pkg = paste0("\\Q", pkg, "\\E"); } # TODO: Use word delimiters? # "(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] alternative to subset(dataframe, select = - column) in R
If you correct my typo as my followup message indicated, match() works fine. As does logical indexing with %in%. The != version will work for your query, but does not generalize to deleting several columns. The point is to heed Jeff N's advice. 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 Fri, Sep 24, 2021 at 12:43 PM Luigi Marongiu wrote: > > Thank you! > ``` > new_out <- new[ , "ID" != names( new ) ] > new[names(new) != "ID"] > ``` > worked as wanted, `new[-match("ID"), names(new)]` gave the error: > `Error in match("ID") : argument "table" is missing, with no default`. > Cheers > > On Fri, Sep 24, 2021 at 7:33 PM Rui Barradas wrote: > > > > Hello, > > > > Like this? > > > > > > mtcars[names(mtcars) != "mpg"] > > > > > > Hope this helps, > > > > Rui Barradas > > > > Às 15:09 de 24/09/21, Luigi Marongiu escreveu: > > > Hello, > > > this is a very simple question but... > > > what is the vector alternative to `subset(dataframe, select = - column)`? > > > I tried with: > > > ``` > > >> x = new[-ID] > > > Error in `[.data.frame`(new, -ID) : object 'ID' not found > > >> x = new[-"ID"] > > > Error in -"ID" : invalid argument to unary operator > > >> x = new[[-"ID"]] > > > Error in -"ID" : invalid argument to unary operator > > >> x = new[-["ID"]] > > > Error: unexpected '[' in "x = new[-[" > > > ``` > > > Thank you > > > > > > __ > > > 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. > > > > > > > -- > Best regards, > Luigi > > __ > 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] Unusual Error Loading tidyverse
Ah. Thanks Duncan. That makes sense based on some other messages I caught a glimpse of as we tried some things. I will investigate down this line. > On Sep 24, 2021, at 3:26 PM, Duncan Murdoch wrote: > > It is worth checking that the library where things were most recently > installed is the first place R looks, i.e. the first entry in .libPaths(). > Often R is installed by an administrator, and users can't write to the main > library, so when they install packages they go somewhere else. If "somewhere > else" isn't first in .libPaths(), R won't see the new installs. > > Duncan Murdoch > > On 24/09/2021 2:04 p.m., Kevin Thorpe wrote: >> I did try installing xml2 and it appeared to complete. I will ask him to try >> again and send me the output. >>> On Sep 24, 2021, at 1:58 PM, Jeff Newmiller >>> wrote: >>> >>> Seems like they should install the xml2 package before proceeding to load >>> whatever (tidyverse). >>> >>> This kind of "dependency missing" problem tends to be a recurring problem >>> particularly on Windows but in general when some deeply-embedded dependency >>> fails to load or is removed in preparation for upgrading. >>> >>> On September 24, 2021 10:40:41 AM PDT, Kevin Thorpe >>> wrote: Below is some output from one of my students. I have never seen this error and tried a few things (updating packages for one) but am at a loss to help further. Would appreciate suggestions that I can pass along. Here is the error. I tried an install.packages(“xml2”) which appeared to complete but the error persists. > library("tidyverse") Error: package or namespace load failed for ‘tidyverse’ in library.dynam(lib, package, package.lib): DLL ‘xml2’ not found: maybe not installed for this architecture? Here is the sessionInfo() > sessionInfo() R version 4.1.1 (2021-08-10) Platform: x86_64-w64-mingw32/x64 (64-bit) Running under: Windows 10 x64 (build 19042) Matrix products: default locale: [1] LC_COLLATE=English_Canada.1252 LC_CTYPE=English_Canada.1252 LC_MONETARY=English_Canada.1252 LC_NUMERIC=C [5] LC_TIME=English_Canada.1252 attached base packages: [1] stats graphics grDevices utils datasets methods base loaded via a namespace (and not attached): [1] Rcpp_1.0.7 cellranger_1.1.0 pillar_1.6.2 compiler_4.1.1 dbplyr_2.1.1 forcats_0.5.1 tools_4.1.1 [8] jsonlite_1.7.2 lubridate_1.7.10 lifecycle_1.0.0 tibble_3.1.4 gtable_0.3.0 pkgconfig_2.0.3 rlang_0.4.11 [15] reprex_2.0.1 DBI_1.1.1 haven_2.4.3 withr_2.4.2 dplyr_1.0.7 httr_1.4.2 fs_1.5.0 [22] generics_0.1.0 vctrs_0.3.8 hms_1.1.0 grid_4.1.1 tidyselect_1.1.1 glue_1.4.2 R6_2.5.1 [29] fansi_0.5.0 readxl_1.3.1 tzdb_0.1.2 tidyr_1.1.3 ggplot2_3.3.5 purrr_0.3.4 readr_2.0.1 [36] modelr_0.1.8 magrittr_2.0.1 backports_1.2.1 scales_1.1.1 ellipsis_0.3.2 assertthat_0.2.1 colorspace_2.0-2 [43] utf8_1.2.2 munsell_0.5.0 broom_0.7.9 crayon_1.4.1 >>> >>> -- >>> Sent from my phone. Please excuse my brevity. > -- Kevin E. Thorpe Head of Biostatistics, Applied Health Research Centre (AHRC) Li Ka Shing Knowledge Institute of St. Michael's Assistant Professor, Dalla Lana School of Public Health University of Toronto email: kevin.tho...@utoronto.ca Tel: 416.864.5776 Fax: 416.864.3016 __ 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] alternative to subset(dataframe, select = - column) in R
Thank you! ``` new_out <- new[ , "ID" != names( new ) ] new[names(new) != "ID"] ``` worked as wanted, `new[-match("ID"), names(new)]` gave the error: `Error in match("ID") : argument "table" is missing, with no default`. Cheers On Fri, Sep 24, 2021 at 7:33 PM Rui Barradas wrote: > > Hello, > > Like this? > > > mtcars[names(mtcars) != "mpg"] > > > Hope this helps, > > Rui Barradas > > Às 15:09 de 24/09/21, Luigi Marongiu escreveu: > > Hello, > > this is a very simple question but... > > what is the vector alternative to `subset(dataframe, select = - column)`? > > I tried with: > > ``` > >> x = new[-ID] > > Error in `[.data.frame`(new, -ID) : object 'ID' not found > >> x = new[-"ID"] > > Error in -"ID" : invalid argument to unary operator > >> x = new[[-"ID"]] > > Error in -"ID" : invalid argument to unary operator > >> x = new[-["ID"]] > > Error: unexpected '[' in "x = new[-[" > > ``` > > Thank you > > > > __ > > 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. > > -- Best regards, Luigi __ 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] Unusual Error Loading tidyverse
It is worth checking that the library where things were most recently installed is the first place R looks, i.e. the first entry in .libPaths(). Often R is installed by an administrator, and users can't write to the main library, so when they install packages they go somewhere else. If "somewhere else" isn't first in .libPaths(), R won't see the new installs. Duncan Murdoch On 24/09/2021 2:04 p.m., Kevin Thorpe wrote: I did try installing xml2 and it appeared to complete. I will ask him to try again and send me the output. On Sep 24, 2021, at 1:58 PM, Jeff Newmiller wrote: Seems like they should install the xml2 package before proceeding to load whatever (tidyverse). This kind of "dependency missing" problem tends to be a recurring problem particularly on Windows but in general when some deeply-embedded dependency fails to load or is removed in preparation for upgrading. On September 24, 2021 10:40:41 AM PDT, Kevin Thorpe wrote: Below is some output from one of my students. I have never seen this error and tried a few things (updating packages for one) but am at a loss to help further. Would appreciate suggestions that I can pass along. Here is the error. I tried an install.packages(“xml2”) which appeared to complete but the error persists. library("tidyverse") Error: package or namespace load failed for ‘tidyverse’ in library.dynam(lib, package, package.lib): DLL ‘xml2’ not found: maybe not installed for this architecture? Here is the sessionInfo() sessionInfo() R version 4.1.1 (2021-08-10) Platform: x86_64-w64-mingw32/x64 (64-bit) Running under: Windows 10 x64 (build 19042) Matrix products: default locale: [1] LC_COLLATE=English_Canada.1252 LC_CTYPE=English_Canada.1252 LC_MONETARY=English_Canada.1252 LC_NUMERIC=C [5] LC_TIME=English_Canada.1252 attached base packages: [1] stats graphics grDevices utils datasets methods base loaded via a namespace (and not attached): [1] Rcpp_1.0.7 cellranger_1.1.0 pillar_1.6.2 compiler_4.1.1 dbplyr_2.1.1 forcats_0.5.1 tools_4.1.1 [8] jsonlite_1.7.2 lubridate_1.7.10 lifecycle_1.0.0 tibble_3.1.4 gtable_0.3.0 pkgconfig_2.0.3 rlang_0.4.11 [15] reprex_2.0.1 DBI_1.1.1 haven_2.4.3 withr_2.4.2 dplyr_1.0.7 httr_1.4.2 fs_1.5.0 [22] generics_0.1.0 vctrs_0.3.8 hms_1.1.0 grid_4.1.1 tidyselect_1.1.1 glue_1.4.2 R6_2.5.1 [29] fansi_0.5.0 readxl_1.3.1 tzdb_0.1.2 tidyr_1.1.3 ggplot2_3.3.5 purrr_0.3.4 readr_2.0.1 [36] modelr_0.1.8 magrittr_2.0.1 backports_1.2.1 scales_1.1.1 ellipsis_0.3.2 assertthat_0.2.1 colorspace_2.0-2 [43] utf8_1.2.2 munsell_0.5.0 broom_0.7.9 crayon_1.4.1 -- Sent from my phone. Please excuse my brevity. __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Unusual Error Loading tidyverse
I did try installing xml2 and it appeared to complete. I will ask him to try again and send me the output. > On Sep 24, 2021, at 1:58 PM, Jeff Newmiller wrote: > > Seems like they should install the xml2 package before proceeding to load > whatever (tidyverse). > > This kind of "dependency missing" problem tends to be a recurring problem > particularly on Windows but in general when some deeply-embedded dependency > fails to load or is removed in preparation for upgrading. > > On September 24, 2021 10:40:41 AM PDT, Kevin Thorpe > wrote: >> Below is some output from one of my students. I have never seen this error >> and tried a few things (updating packages for one) but am at a loss to help >> further. Would appreciate suggestions that I can pass along. >> >> Here is the error. I tried an install.packages(“xml2”) which appeared to >> complete but the error persists. >> >>> library("tidyverse") >> Error: package or namespace load failed for ‘tidyverse’ in >> library.dynam(lib, package, package.lib): >> DLL ‘xml2’ not found: maybe not installed for this architecture? >> >> Here is the sessionInfo() >> >>> sessionInfo() >> R version 4.1.1 (2021-08-10) >> Platform: x86_64-w64-mingw32/x64 (64-bit) >> Running under: Windows 10 x64 (build 19042) >> >> Matrix products: default >> >> locale: >> [1] LC_COLLATE=English_Canada.1252 LC_CTYPE=English_Canada.1252 >> LC_MONETARY=English_Canada.1252 LC_NUMERIC=C >> [5] LC_TIME=English_Canada.1252 >> >> attached base packages: >> [1] stats graphics grDevices utils datasets methods base >> >> loaded via a namespace (and not attached): >> [1] Rcpp_1.0.7 cellranger_1.1.0 pillar_1.6.2 compiler_4.1.1 dbplyr_2.1.1 >> forcats_0.5.1 tools_4.1.1 >> [8] jsonlite_1.7.2 lubridate_1.7.10 lifecycle_1.0.0 tibble_3.1.4 >> gtable_0.3.0 pkgconfig_2.0.3 rlang_0.4.11 >> [15] reprex_2.0.1 DBI_1.1.1 haven_2.4.3 withr_2.4.2 dplyr_1.0.7 httr_1.4.2 >> fs_1.5.0 >> [22] generics_0.1.0 vctrs_0.3.8 hms_1.1.0 grid_4.1.1 tidyselect_1.1.1 >> glue_1.4.2 R6_2.5.1 >> [29] fansi_0.5.0 readxl_1.3.1 tzdb_0.1.2 tidyr_1.1.3 ggplot2_3.3.5 >> purrr_0.3.4 readr_2.0.1 >> [36] modelr_0.1.8 magrittr_2.0.1 backports_1.2.1 scales_1.1.1 ellipsis_0.3.2 >> assertthat_0.2.1 colorspace_2.0-2 >> [43] utf8_1.2.2 munsell_0.5.0 broom_0.7.9 crayon_1.4.1 >> > > -- > Sent from my phone. Please excuse my brevity. -- Kevin E. Thorpe Head of Biostatistics, Applied Health Research Centre (AHRC) Li Ka Shing Knowledge Institute of St. Michael's Assistant Professor, Dalla Lana School of Public Health University of Toronto email: kevin.tho...@utoronto.ca Tel: 416.864.5776 Fax: 416.864.3016 __ 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] Unusual Error Loading tidyverse
Seems like they should install the xml2 package before proceeding to load whatever (tidyverse). This kind of "dependency missing" problem tends to be a recurring problem particularly on Windows but in general when some deeply-embedded dependency fails to load or is removed in preparation for upgrading. On September 24, 2021 10:40:41 AM PDT, Kevin Thorpe wrote: >Below is some output from one of my students. I have never seen this error and >tried a few things (updating packages for one) but am at a loss to help >further. Would appreciate suggestions that I can pass along. > >Here is the error. I tried an install.packages(“xml2”) which appeared to >complete but the error persists. > >> library("tidyverse") >Error: package or namespace load failed for ‘tidyverse’ in library.dynam(lib, >package, package.lib): >DLL ‘xml2’ not found: maybe not installed for this architecture? > >Here is the sessionInfo() > >> sessionInfo() >R version 4.1.1 (2021-08-10) >Platform: x86_64-w64-mingw32/x64 (64-bit) >Running under: Windows 10 x64 (build 19042) > >Matrix products: default > >locale: >[1] LC_COLLATE=English_Canada.1252 LC_CTYPE=English_Canada.1252 >LC_MONETARY=English_Canada.1252 LC_NUMERIC=C >[5] LC_TIME=English_Canada.1252 > >attached base packages: >[1] stats graphics grDevices utils datasets methods base > >loaded via a namespace (and not attached): >[1] Rcpp_1.0.7 cellranger_1.1.0 pillar_1.6.2 compiler_4.1.1 dbplyr_2.1.1 >forcats_0.5.1 tools_4.1.1 >[8] jsonlite_1.7.2 lubridate_1.7.10 lifecycle_1.0.0 tibble_3.1.4 gtable_0.3.0 >pkgconfig_2.0.3 rlang_0.4.11 >[15] reprex_2.0.1 DBI_1.1.1 haven_2.4.3 withr_2.4.2 dplyr_1.0.7 httr_1.4.2 >fs_1.5.0 >[22] generics_0.1.0 vctrs_0.3.8 hms_1.1.0 grid_4.1.1 tidyselect_1.1.1 >glue_1.4.2 R6_2.5.1 >[29] fansi_0.5.0 readxl_1.3.1 tzdb_0.1.2 tidyr_1.1.3 ggplot2_3.3.5 purrr_0.3.4 >readr_2.0.1 >[36] modelr_0.1.8 magrittr_2.0.1 backports_1.2.1 scales_1.1.1 ellipsis_0.3.2 >assertthat_0.2.1 colorspace_2.0-2 >[43] utf8_1.2.2 munsell_0.5.0 broom_0.7.9 crayon_1.4.1 > -- Sent from my phone. Please excuse my brevity. __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Unusual Error Loading tidyverse
Below is some output from one of my students. I have never seen this error and tried a few things (updating packages for one) but am at a loss to help further. Would appreciate suggestions that I can pass along. Here is the error. I tried an install.packages(“xml2”) which appeared to complete but the error persists. > library("tidyverse") Error: package or namespace load failed for ‘tidyverse’ in library.dynam(lib, package, package.lib): DLL ‘xml2’ not found: maybe not installed for this architecture? Here is the sessionInfo() > sessionInfo() R version 4.1.1 (2021-08-10) Platform: x86_64-w64-mingw32/x64 (64-bit) Running under: Windows 10 x64 (build 19042) Matrix products: default locale: [1] LC_COLLATE=English_Canada.1252 LC_CTYPE=English_Canada.1252 LC_MONETARY=English_Canada.1252 LC_NUMERIC=C [5] LC_TIME=English_Canada.1252 attached base packages: [1] stats graphics grDevices utils datasets methods base loaded via a namespace (and not attached): [1] Rcpp_1.0.7 cellranger_1.1.0 pillar_1.6.2 compiler_4.1.1 dbplyr_2.1.1 forcats_0.5.1 tools_4.1.1 [8] jsonlite_1.7.2 lubridate_1.7.10 lifecycle_1.0.0 tibble_3.1.4 gtable_0.3.0 pkgconfig_2.0.3 rlang_0.4.11 [15] reprex_2.0.1 DBI_1.1.1 haven_2.4.3 withr_2.4.2 dplyr_1.0.7 httr_1.4.2 fs_1.5.0 [22] generics_0.1.0 vctrs_0.3.8 hms_1.1.0 grid_4.1.1 tidyselect_1.1.1 glue_1.4.2 R6_2.5.1 [29] fansi_0.5.0 readxl_1.3.1 tzdb_0.1.2 tidyr_1.1.3 ggplot2_3.3.5 purrr_0.3.4 readr_2.0.1 [36] modelr_0.1.8 magrittr_2.0.1 backports_1.2.1 scales_1.1.1 ellipsis_0.3.2 assertthat_0.2.1 colorspace_2.0-2 [43] utf8_1.2.2 munsell_0.5.0 broom_0.7.9 crayon_1.4.1 -- Kevin E. Thorpe Head of Biostatistics, Applied Health Research Centre (AHRC) Li Ka Shing Knowledge Institute of St. Michael's Assistant Professor, Dalla Lana School of Public Health University of Toronto email: kevin.tho...@utoronto.ca Tel: 416.864.5776 Fax: 416.864.3016 __ 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] alternative to subset(dataframe, select = - column) in R
Hello, Like this? mtcars[names(mtcars) != "mpg"] Hope this helps, Rui Barradas Às 15:09 de 24/09/21, Luigi Marongiu escreveu: Hello, this is a very simple question but... what is the vector alternative to `subset(dataframe, select = - column)`? I tried with: ``` x = new[-ID] Error in `[.data.frame`(new, -ID) : object 'ID' not found x = new[-"ID"] Error in -"ID" : invalid argument to unary operator x = new[[-"ID"]] Error in -"ID" : invalid argument to unary operator x = new[-["ID"]] Error: unexpected '[' in "x = new[-[" ``` Thank you __ 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] alternative to subset(dataframe, select = - column) in R
typo. Correction: x <- new[-match("ID", names(new))] 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 Fri, Sep 24, 2021 at 7:31 AM Bert Gunter wrote: > > x <- new[-match("ID"), names(new))] > > 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 Fri, Sep 24, 2021 at 7:10 AM Luigi Marongiu > wrote: > > > > Hello, > > this is a very simple question but... > > what is the vector alternative to `subset(dataframe, select = - column)`? > > I tried with: > > ``` > > > x = new[-ID] > > Error in `[.data.frame`(new, -ID) : object 'ID' not found > > > x = new[-"ID"] > > Error in -"ID" : invalid argument to unary operator > > > x = new[[-"ID"]] > > Error in -"ID" : invalid argument to unary operator > > > x = new[-["ID"]] > > Error: unexpected '[' in "x = new[-[" > > ``` > > Thank you > > > > __ > > 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] alternative to subset(dataframe, select = - column) in R
The subset function subset( new, select = -ID ) uses non-standard evaluation... it "knows" that when you write the language symbol ID it may match to one of the column names in new, and the `-` in the select argument will be noticed before R tries to change the sign of a variable ID in your calling environment and cause subset to remove the "ID" column from the returned version of new. The vector indexing operator does none of that, so whatever indexing arguments you specify need to be valid expressions on their own without the indexing operator. -ID You don't have a variable called ID, so its sign vanity be changed -"ID" Changing the sign of a character literal is not a defined operation -["ID"] Standalone brackets have no meaning in R... only can be used directly adjacent to a vector to the right. What you do have is the data frame `new`... and it has names, and among those names is "ID", so... "ID" != names( new ) should be a logical vector with FALSE in the position corresponding to "ID", so new[ , "ID" != names( new ) ] will select all of the columns other than the "ID" column. If you want to deselect more than one column, then the %in% operator can help: ! names( new ) %in% c( "ID", "Other" ) will be a logical vector with FALSE in the corresponding positions. On September 24, 2021 7:09:54 AM PDT, Luigi Marongiu wrote: >Hello, >this is a very simple question but... >what is the vector alternative to `subset(dataframe, select = - column)`? >I tried with: >``` >> x = new[-ID] >Error in `[.data.frame`(new, -ID) : object 'ID' not found >> x = new[-"ID"] >Error in -"ID" : invalid argument to unary operator >> x = new[[-"ID"]] >Error in -"ID" : invalid argument to unary operator >> x = new[-["ID"]] >Error: unexpected '[' in "x = new[-[" >``` >Thank you > >__ >R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see >https://stat.ethz.ch/mailman/listinfo/r-help >PLEASE do read the posting guide http://www.R-project.org/posting-guide.html >and provide commented, minimal, self-contained, reproducible code. -- Sent from my phone. Please excuse my brevity. __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] alternative to subset(dataframe, select = - column) in R
x <- new[-match("ID"), names(new))] 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 Fri, Sep 24, 2021 at 7:10 AM Luigi Marongiu wrote: > > Hello, > this is a very simple question but... > what is the vector alternative to `subset(dataframe, select = - column)`? > I tried with: > ``` > > x = new[-ID] > Error in `[.data.frame`(new, -ID) : object 'ID' not found > > x = new[-"ID"] > Error in -"ID" : invalid argument to unary operator > > x = new[[-"ID"]] > Error in -"ID" : invalid argument to unary operator > > x = new[-["ID"]] > Error: unexpected '[' in "x = new[-[" > ``` > Thank you > > __ > 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] alternative to subset(dataframe, select = - column) in R
Hello, this is a very simple question but... what is the vector alternative to `subset(dataframe, select = - column)`? I tried with: ``` > x = new[-ID] Error in `[.data.frame`(new, -ID) : object 'ID' not found > x = new[-"ID"] Error in -"ID" : invalid argument to unary operator > x = new[[-"ID"]] Error in -"ID" : invalid argument to unary operator > x = new[-["ID"]] Error: unexpected '[' in "x = new[-[" ``` Thank you __ 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.