Just doing the basic data set from the examples in the R-Graph-gallery, not sure why I can't get anything to plot correctly.
I searched around and some posts said to install 'extrafonts' but that also isn't possible:
PackagesNotFoundError: The following packages are not available from current channels:
- r-extrafonts
iris plot error:
Using theme_ipsum from hrbrthemes package
You perhaps want to figure out which of your Windows fonts are not present or present in a location that R is not expecting. Here's how to find the installed and accessible PDF fonts known to R. I'm working with PDF fonts because you mentioned something that might be a reference to an R package named "extrafont". There is no CRAN -sited package named 'r-extrafonts'.
names(pdfFonts())
[1] "serif" "sans" "mono" "AvantGarde"
[5] "Bookman" "Courier" "Helvetica" "Helvetica-Narrow"
[9] "NewCenturySchoolbook" "Palatino" "Times" "URWGothic"
[13] "URWBookman" "NimbusMon" "NimbusSan" "URWHelvetica"
[17] "NimbusSanCond" "CenturySch" "URWPalladio" "NimbusRom"
[21] "URWTimes" "ArialMT" "Japan1" "Japan1HeiMin"
[25] "Japan1GothicBBB" "Japan1Ryumin" "Korea1" "Korea1deb"
[29] "CNS1" "GB1"
I'm on a Linux box so yours will undoubtedly be different. The first three will be the defaults. You can examine it more carefully to see which font is likely to be askew or missing:
pdfFonts()[['serif']]$family
[1] "Times"
pdfFonts()[['serif']]
$family
[1] "Times"
$metrics
[1] "Times-Roman.afm" "Times-Bold.afm" "Times-Italic.afm" "Times-BoldItalic.afm"
[5] "Symbol.afm"
$encoding
[1] "default"
attr(,"class")
[1] "Type1Font"
Related
My code:
setwd("C:/A549_ALI/4_tert-Butanol (22)/")
list.celfiles()
my.affy=ReadAffy()
dim(exprs(my.affy))
Output:
Show in New Window
[1] "(46) 22-B1-1_(miRNA-4_0).CEL"
[2] "(47) 22-B1-2_(miRNA-4_0).CEL"
[3] "(48) 22-B1-3_(miRNA-4_0).CEL"
[4] "(49) 22-R1-1_(miRNA-4_0).CEL"
[5] "(50) 22-NEC 1-1_(miRNA-4_0).CEL"
[6] "(51) 22-B2-1_(miRNA-4_0).CEL"
[7] "(52) 22-B2-2_(miRNA-4_0).CEL"
[8] "(53) 22-B2-3_(miRNA-4_0).CEL"
[9] "(54) 22-R2-1_(miRNA-4_0).CEL"
[10] "(55) 22-NEC 2-1_(miRNA-4_0).CEL"
[11] "(56) 22-B3-1_(miRNA-4_0).CEL"
[12] "(57) 22-B3-2_(miRNA-4_0).CEL"
[13] "(58) 22-B3-3_(miRNA-4_0).CEL"
[14] "(59) 22-R3-1_(miRNA-4_0).CEL"
[15] "(60) 22-NEC 3-1_(miRNA-4_0).CEL"
[1] 292681 15
Up to here everything works but than I get this error message:
background correction: mas
PM/MM correction : mas
expression values: mas
background correcting...'getOption("repos")' replaces Bioconductor standard repositories, see '?repositories' for details
replacement repositories:
CRAN: https://cran.rstudio.com/
Error in getCdfInfo(object) :
Could not obtain CDF environment, problems encountered:
Specified environment does not contain miRNA-4_0
Library - package mirna40cdf not installed
Bioconductor - mirna40cdf not available
I have already tried to install this package, but I can't find it on the Bioconductor website.
Now I do not know how to proceed. Is there any other way to use the mas5calls function?
I use R 4.2.2.
Thanks for all answers.
This simply means that the package with the cdf-env built upon the chip description (CDF) - file for this type of MicroArray data is not distributed through Bio-conductor. It seems that Affymetrix is not providing those anymore, but you can find them on GEO. (click on the platform and than under "Supplementary file" . Alternatively ask the person you got the data from if they can provide you with the relevant CDFs. Use cfdName() to check which ones you need.
Once you obtained the CDF you can build the R package ( mirna40cdf in your case) that affy needs using the makecdfenv package you can install from Bioconductor. You could also try to use another package called oligo and see if it supports your data.
I wanted to filter a data set based on some conditions. When I looked at the help for filter function the result was:
filter {stats} R Documentation
Linear Filtering on a Time Series
Description
Applies linear filtering to a univariate time series or to each series separately of a multivariate time series.
After searching on web I found the filter function I needed i.e. from dplyr package. How can R have two functions with same name. What am I missing here?
At the moment the R interpreter would dispatch a call to filter to the dplyr environment, at least if the class of the object were among the avaialble methods:
methods(filter)
[1] filter.data.frame* filter.default* filter.sf* filter.tbl_cube* filter.tbl_df* filter.tbl_lazy*
[7] filter.ts*
As you can see there is a ts method, so if the object were of that class, the interpreter would instead deliver the x values to it. However, it appears that the authors of dplyr have blocked that mechanism and instead put in a warning function. You would need to use:
getFromNamespace('filter', 'stats')
function (x, filter, method = c("convolution", "recursive"),
sides = 2L, circular = FALSE, init = NULL)
{ <omitting rest of function body> }
# same result also obtained with:
stats::filter
R functions are contained in namespaces, so a full designation of a function would be: namespace_name::function_name. There is a hierarchy of namespace containers (actually "environments" in R terminology) arranged along a search path (which will vary depending on the order in which packages and their dependencies have been loaded). The ::-infix-operator can be used to specify a namespace or package name that is further up the search path than might be found in the context of the calling function. The function search can display the names of currently loaded packages and their associated namespaces. See ?search Here's mine at the moment (which is a rather bloated one because I answer a lot of questions and don't usually start with a clean systems:
> search()
[1] ".GlobalEnv" "package:kernlab" "package:mice" "package:plotrix"
[5] "package:survey" "package:Matrix" "package:grid" "package:DHARMa"
[9] "package:eha" "train" "package:SPARQL" "package:RCurl"
[13] "package:XML" "package:rnaturalearthdata" "package:rnaturalearth" "package:sf"
[17] "package:plotly" "package:rms" "package:SparseM" "package:Hmisc"
[21] "package:Formula" "package:survival" "package:lattice" "package:remotes"
[25] "package:forcats" "package:stringr" "package:dplyr" "package:purrr"
[29] "package:readr" "package:tidyr" "package:tibble" "package:ggplot2"
[33] "package:tidyverse" "tools:rstudio" "package:stats" "package:graphics"
[37] "package:grDevices" "package:utils" "package:datasets" "package:methods"
[41] "Autoloads"
At the moment I can find instances of 3 versions of filter using the help system:
?filter
# brings this up in the help panel
Help on topic 'filter' was found in the following packages:
Return rows with matching conditions
(in package dplyr in library /home/david/R/x86_64-pc-linux-gnu-library/3.5.1)
Linear Filtering on a Time Series
(in package stats in library /usr/lib/R/library)
Objects exported from other packages
(in package plotly in library /home/david/R/x86_64-pc-linux-gnu-library/3.5.1)
Is it possible to scan all the packages on CRAN in order to find all those that are dependent on a specific package?
I have found out how to do that but only on the packages I have installed and that is not what I want.
If you don't care about doing it programmatically, the easiest way is to look at the corresponding CRAN web page (i.e. https://CRAN.R-project.org/package=PKGNAME) and look at the "Reverse depends:", "Reverse imports:", and "Reverse suggests:" sections.
You can do (with a package randomly picked from CRAN):
tools::package_dependencies(package = "ABHgenotypeR")
$ABHgenotypeR
[1] "ggplot2" "reshape2" "utils"
If you need the reverse dependencies, you can do:
tools::package_dependencies(package = "ABHgenotypeR",
reverse = TRUE)
$ABHgenotypeR
character(0)
From documentation:
For given packages which are not found in the db, NULL entries are
returned, as opposed to character(0) entries which indicate no
dependencies.
And you can do it for multiple packages simultaneously:
packages <- c("ABHgenotypeR", "accelerometry", "ACNE")
tools::package_dependencies(package = packages)
$ABHgenotypeR
[1] "ggplot2" "reshape2" "utils"
$accelerometry
[1] "Rcpp" "dvmisc"
$ACNE
[1] "aroma.affymetrix" "MASS" "R.methodsS3" "R.oo" "R.utils"
[6] "matrixStats" "R.filesets" "aroma.core"
After I installed RStudio, I ran:
library()
Warning message:
libraries '/usr/local/lib/R/site-library', 'usr/lib/R/site-library' contain no packages
Then I input:
.libPaths()
[1] "/home/avalon/R/x86_64-pc-linux-gun-library/3.2"
[2] "/usr/local/lib/R/site-library"
[3] "/usr/lib/R/site-library"
[4] "/usr/lib/R/library"
How can I remove [2] and [3] to prevent the warning message appear again?
Expected output:
.libPaths()
[1] "/home/avalon/R/x86_64-pc-linux-gun-library/3.2"
[4] "/usr/lib/R/library"
Linux
First thing to do is read the manpage on it (?.libPaths), and you'll see:
'.libPaths' is used for getting or setting the library trees that R knows about (and hence uses when looking for packages). If called with argument ‘new’, the library search path is set to the existing directories in unique(c(new, .Library.site, .Library)) and this is returned. If given no argument, a character vector with the currently active library trees is returned.
(emphasis added). This should clue us in to wonder what .Library.site holds. Oddly enough, it holds system-wide (ergo "site") library paths that "should" always be kept, so they are always maintained.
It further goes on to say:
'.Library.site' can be set via the environment variable 'R_LIBS_SITE' (as a non-empty semicolon-separated list of library trees).
So one way to fix it is to give it an empty string when you start R (cannot be done from within R):
# in bash on the command line:
$ R_LIBS_SITE=" " R
# in R
R> .libPaths()
[1] "/usr/lib/R/library"
The way to get this to work with RStudio is by creating a ~/.Renviron file with at least the following:
R_LIBS_SITE=" "
That done, you should not have to do anything further to remove the secondary site library paths from .libPaths():
R> .libPaths()
[1] "/usr/lib/R/library"
Windows
Assuming you're doing the following:
R> .libPaths(c("/home/avalon/R/x86_64-pc-linux-gun-library/3.2", .libPaths()))
[1] "/home/avalon/R/x86_64-pc-linux-gun-library/3.2"
[2] "/usr/local/lib/R/site-library"
[3] "/usr/lib/R/site-library"
[4] "/usr/lib/R/library"
If you want to correct it after you've done this, then just do:
R> .libPaths( c(.libPaths()[c(1,4)]) )
[1] "/home/avalon/R/x86_64-pc-linux-gun-library/3.2"
[2] "/usr/lib/R/library"
Alternatively, you can do it this way the first time (i.e., while it still has three elements, two of which are not good for you):
R> .libPaths(c("/home/avalon/R/x86_64-pc-linux-gun-library/3.2", .libPaths()[3]))
[1] "/home/avalon/R/x86_64-pc-linux-gun-library/3.2"
[2] "/usr/lib/R/library"
There is certainly a way to filter the paths programmatically instead of blindly taking the 3rd element, but this should work for now.
I am trying to read a .sav file into RStudio. The file contains data from a Spanish language survey, and when I read it into R -- even though my default text encoding has already been set to ISO-8859-1 -- the display of special characters is incorrect.
For example, the word "Camión" appears as
"Cami<c3><b3>n"
even though it shows up correctly as "Camión" in PSPP.
This is what I did:
install.packages("memisc")
jcv2014 <- as.data.set(spss.system.file('myfile.sav'))
Later, I wanted to create a list of just the variable labels, so I did the following:
library(foreign)
jcv2014.spss <- read.spss("myfile.sav", to.data.frame=FALSE, use.value.labels=FALSE)
jcv2014_vars <- attr(jcv2014.spss, "variable.labels")
(I'm not sure if this is the best way to do it, but it worked)
Anyway, this time around, I still didn't get the proper accents but there was a different sort of encoding:
A variable label that was supposed to be "¿Qué calificación le daría..." instead appeared as
"\302\277Qu\303\251 calificaci\303\263n le dar\303\255a..."
I'm not sure how to get the proper characters, but they appear correctly in PSPP. I tried changing the default text encoding in R to both ISO-8859-1 and UTF-8, to no avail. I don't know what the original file was encoded in, but I guessed it would be one of those.
Any ideas?
And if it helps, I have R version 3.1.1 and OS X Yosemite version 10.10.1, and I am using PSPP, not SPSS.
Thanks so much in advance!!!
Can you just set the encoding once you've read the data in?
# Here's your sentence
s <- "\302\277Qu\303\251 calificaci\303\263n le dar\303\255a..."
# it has no encoding
Encoding(s)
# [1] "unknown"
# but if you specify UTF-8, then it shows up correctly
iconv(s, 'UTF-8')
# [1] "¿Qué calificación le daría..."
# This also works
Encoding(s) <- 'UTF-8'
s
# [1] "¿Qué calificación le daría..."
Here are the results of my sessionInfo() call. You should post yours too.
> sessionInfo()
R version 3.1.1 (2014-07-10)
Platform: x86_64-apple-darwin13.1.0 (64-bit)
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] reshape2_1.4 hexbin_1.27.0 ggplot2_1.0.0 data.table_1.9.2 yaml_2.1.13
[6] redshift_0.4 RJDBC_0.2-4 rJava_0.9-6 DBI_0.3.1
loaded via a namespace (and not attached):
[1] colorspace_1.2-4 digest_0.6.4 grid_3.1.1 gtable_0.1.2 labeling_0.2
[6] lattice_0.20-29 MASS_7.3-33 munsell_0.4.2 plyr_1.8.1 proto_0.3-10
[11] Rcpp_0.11.2 scales_0.2.4 stringr_0.6.2 tools_3.1.1
Update: looks like you may not have a locale that supports UTF-8. Here are the locale settings for each category on my system. You might try using Sys.setLocale() and updating them one by one on your system (or just use LC_ALL if you don't feel the need to test each one incrementally). ?Sys.setLocale for more info
cat_str <- c("LC_COLLATE", "LC_CTYPE", "LC_MONETARY", "LC_NUMERIC",
"LC_TIME", "LC_MESSAGES", "LC_PAPER", "LC_MEASUREMENT")
sapply(cat_str, Sys.getlocale)
# LC_COLLATE LC_CTYPE LC_MONETARY LC_NUMERIC LC_TIME LC_MESSAGES
# "en_US.UTF-8" "en_US.UTF-8" "en_US.UTF-8" "C" "en_US.UTF-8" "en_US.UTF-8"
# LC_PAPER LC_MEASUREMENT
# "" ""