I found this error when I was dealing with the swirl assignment:
You're probably sick of it but rerun qplot again, this time with 4 arguments. The first 3 are the same as the last qplot command you just ran (price, data set equal to diamonds, and binwidth set equal to 18497/30). (Use the up arrow to save yourself some typing.) The fourth argument is fill set equal to cut. The shape of the histogram will be familiar, but it will be more colorful.
qplot(price, data = diamonds, binwidth = 18497/30, fill = cut)
Error in readRDS(nsInfoFilePath) : error reading from connection
I cannot solve this problem even after a long search on the internet
I encountered the same error while using ggplot2, even with very simple data and graph.
I traced the readRDS function with the following code :
trace(readRDS, quote(print(ls.str())))
which after running the ggplot code returned something like :
Tracing readRDS(metapath) on entry
file : chr "/home/username/R/x86_64-pc-linux-gnu-library/4.1/farver/Meta/package.rds"
refhook : NULL
I reinstalled the farver package, the error disappeared and I was finally able to plot the graph I wanted.
This package (and the package.rds file) was probably not installed correctly.
I found a similar issue and the tracing command here.
Related
I use ggplot regularly. I was rerunning some scripts tonight and for the first time am getting this error on every plot.
Error in grid.Call.graphics(C_setviewport, vp, TRUE) :
non-finite location and/or size for viewport
after checking my DFs nothing seemed wrong. I even ran a super basic line:
ggplot() + geom_point(aes(x = 1, y = 1))
and still get the same error.
can someone help?! perhaps it is a conflicting package or something? I am running ggplot version 3.3.2.
thank you!
Are you using RStudio? This happens sometimes to me when the Plots pane is too small to display the graph. Try enlarging it by dragging the sides and see if you're still getting the error?
I have been getting the error Error in default + theme : non-numeric argument to binary operator. I have been using R and teaching R for a long time but I can't find this problem. I have included a reproducible example that fails this way below:
library(tibble)
library(ggplot2)
brains <- as_tibble(brains)
brains <- brains[1:10, ]
brains
ggplot(brains, aes(x = BodyWt, y = BrainWt)) +
geom_point()
The error occurs when executing the ggplot() statement.
My hardware is an HP Laptop 15-ef0xxx. I am running Windows 10 Home version 2004. I am running RStudio community edition "Water Lily" and R version R x64** 4.0.2.
I know this is a simple error and it is driving me crazy.
So I finally solved this problem. On the github issue I had opened Hiroaki commented that "One possibility is that you might set a invalid default theme in your .Rprofile, but I'm not sure..." (see link to issue below).
I'm not sure if your R file is part of a project but mine is.
So I went back and deleted the theme_set() line in my R file, went in and double checked all my project options and selected the option "Disable .Rprofile execution on session start/resume" and "Quit child processes on exit". And then I restarted the R session and now everything works. Including on the default R editor console.
I'm not sure if all those steps are necessary but that seemed to do the trick for me! Hope it helps.
I thought this was an RStudio issue but it seems it's possibly a ggplot2 > problem. I have verified using two different datasets that the same >error comes up when I try using ggplot2 in RStudio or using the default R >console. I get the exact same error with code that's been working fine >but now suddenly won't. I have opened an issue on Github (ggplot2) with a >reprex. Might be worth checking there: >https://github.com/tidyverse/ggplot2/issues/4177
I know this is not an answer per se but I don't have enough reputation >points to add a comment to the previous answer but I thought linking to >the issue on Github might help.
I think you have numbers quoted somewhere and you are trying to perform mathematical operation on character values. Consider
x <- c("5","6")
y <- x/1
> y <- x/1
Error in x/1 : non-numeric argument to binary operator
Now try converting x to numeric and perform the same operation.
y <- as.numeric(x)/1
> y
[1] 5 6
So, you need to use as.numeric on your variable.
The following should resove this issue
ggplot(brains, aes(x = as.numeric(BodyWt), y = as.numeric(BrainWt)))
I am trying to run the following lines of code:
tree <- read.nexus("~/Dropbox/Billfishes/Analysis/Phylogenies/Fish_12Tax_time_calibrated.tre");
characterTable <- read.csv("~/Dropbox/Billfishes/Analysis/CodingTableThresh95.csv", row.names = 1);
treeWData <- treedata(tree, characterTable, sort = T);
When I ran this code last week, it worked. I then updated all my packages as part of routine maintenance, and now I get this error:
Error in integer(max(oldnodes)) : vector size cannot be infinite
In addition: Warning message:
In max(oldnodes) : no non-missing arguments to max; returning -Inf
I've tried rolling back to previous versions of R (I'm currently running R version 3.4.0 in RStudio 1.0.143; geiger is version 2.0.6), reading the tree in as a Newick, and trying other tree files, always resulting in the same error. When I try using other tree and character datasets, I do not get the error.
Any ideas what this error means, and/or how to get this code to run without throwing this error?
After careful error checking, I discovered that the taxon names in the phylogeny file were separated by underscores, whereas the taxon names in the table used camel caps. Thus, the error was thrown because no taxa in the phylogeny mapped to the character table.
If I run:
library(ggplot2)
ToothGrowth$dose <- as.factor(ToothGrowth$dose)
bp<-ggplot(ToothGrowth, aes(x=dose, y=len, fill=dose)) +
geom_boxplot()
bp
I see the error: Error in grDevices::col2rgb(colour, TRUE) : invalid RGB specification.
If I run the identical code on my other computer, I get the expected plot. I am guessing that some plotting parameter is the culprit, but I have no idea how to find it. What's going wrong?
The computer that behaves strangely is Mac OS X 10_11_3 running R 3.2.2 via RStudio 0.99.489
Sorry I am late, but the problem is that the function alpha is masked form ggplot2, that's why if you restart R and happen to call alpha after sourcing psych but before ggplot2 it works.
Anyway, the way to solve it is to make explicit that we want the psych function:
reliability = psych::alpha(df)
Restarting R was sufficient to fix the weird behavior. Obviously should have tried that before posting...
I have three dataframes, for which I am trying to find a cell-by-cell mean.
r1<-raster('a.tif')
r2<-raster('b.tif')
r3<-raster('c.tif')
However, doing this is giving me the following error
q<-mean(r1,r2,r3)
or
q<-(r1+r2+r3)/3
Error
Error in .local(.Object, ...) : options(warn) not set
Warning message:
closing unused connection 4 .....
That is a weird error message. Often this type of situation goes away if you restart R without loading an old workspace (which may be stale). If that is what is going on use unlink(".RData"), exit R without saving and start again.
To answer your aside question, yes it is much easier to stack them. E.g.
f <- list.files(pattern='tif$')
s <- stack(f)
x <- sum(s)