R:V3.1.1, Platform:x86_64-w64-mingw32/x64 (64-bit), Package: choroplethrMaps - r

This is my first question to the community. I've read through the guidelines and am doing my best to ask an appropriate question and including a minimal, complete, and verifiable example. That being said, please feel free to suggest ways in which I can ask better questions going forward.
I am having trouble with the choroplethrMaps package, which I have never used in the past. I have had issues installing packages on my work computer before, but have gotten around this issue by pasting the package and its dependencies in my library directory. Part of my issues may stem from that, but I'm not sure.
Here is the code that replicates the issue on my machine.
library(choroplethrMaps)
library(choroplethrAdmin1)
library(choroplethr)
data(state.map)
df<-data.frame(region=unique(x = state.map$region),value=rnorm(n = 51,mean = 500,sd = 45))
debug(state_choropleth)
state_choropleth(df = df,title = "", legend = "", num_colors = 1)
After debugging the state_choropleth function, it looks like there is an error with the "render" portion of the code. When I execute the above code, I get the following error message.
Error in withCallingHandlers(tryCatch(evalq((function (..., call. = TRUE, :
object '.rcpp_warning_recorder' not found
Note that I am only using state_choropleth because when running the choroplethr function, I was advised to use state_choropleth instead. It seems as though choroplethr is out of date.

Related

Is there an issue with raster::writeRaster writing raster stacks in R4.2?

I am using some older code to write a raster stack with bylayer = T and I havent bothered to migrate it to terra yet so I am still using raster. This used to work fine:
raster::writeRaster(stack(rastList3), names(rastList3), bylayer = T, overwrite = TRUE, format = "GTiff")
Now it throws the hard to decipher error:
"Error in if (tolower(e) %in% c(".tiff", ".tif")) { :
the condition has length > 1"
Replies to similar error message here suggest it seems to have to do with R 4.2 but I am not fully sure that is what is happening. I can get it to write one layer at a time using
dsn <- here("Clipped_ENVData/Mask2022//")
nameT = paste(dsn, names(rastList3), ".tiff", sep = "")
writeRaster(rastList3[[3]], nameT[[3]], overwrite = TRUE)
but it wont write bylayer from the stack of 10 rasters :(
Does anyone know if there is a workaround in the writeRaster function that needs to be fixed or is it something broken in my code?
That is a bug. It goes away if you update the "raster" package to version 3.6-5. That is currently the development version. You can install that version with
install.packages('raster', repos='https://rspatial.r-universe.dev')
OH-KAY. I also found the answer to this post here which helped me work out my solution:
lapply(rastList3, function(x) writeRaster(x, filename=paste0(dsn,names(x)), format="GTiff", overwrite = TRUE))
While updating to a development version might fix the bug, I was hesitant as it possibly could create more headaches in other places.

Command describe unrecognized even if the package psych is loaded

I'm using Rstudio 2022.22.1 on MacOS Monterey 12.3.1.
I load libraries at the begininning by doing:
knitr::opts_chunk$set(echo = TRUE)
library("tidyverse", "here", "magrittr")
library("pastecs", "psych")
## dlf<-read.delim("data/DownloadFestival(No Outlier).dat", header=TRUE)
dlf<-here::here("data/DownloadFestival(No Outlier).dat") %>% readr::read_delim(col_names = TRUE)
I also check the thick for the library "psych" in the Packages section of RStudio.
The issue is that, from a certain point (after Knitting) I wasn't unable to use the command describe, this is the error:
could not find function "describe"
I could bypass this, by typing each time I use the function:
psych::describe
instead of describe alone
How can I use describe without specifying the psych:: prefix each time ?
Your problem is that library("pastecs", "psych") isn't doing what you think. Weirdly enough, there isn't an obvious idiom for "load a bunch of packages at once": I wish there were an easier way to do this, but try
invisible(lapply(c("psych", "pastecs"), library, character.only = TRUE))
The answers to this question provide a bunch of different ways to load many packages at once (the accepted answer is the same as the one given here).

R function seas() not found in v.4.1.0

I have a script that I have used several times over the past year. The last time I used it was 3 months ago. It was all working with no errors.
In the interim, I have upgraded R to v. 4.1.0. This may be a generic problem, but I've covered what I think are the obvious possible explanations (packages not installed, libs not loaded, typos, etc).
Here's the relevant code (all calls are successful up to the seas() call):
library(fpp2)
library(ggplot2)
library(seasonal)
library(seas) # Added recently in attempt to mitigate this issue
hh=6
ff=12
LT <- read.csv("C:\\...\\lt.csv")
LTts <- ts(LT, start=c(2007,1),frequency=12)
#...
LTx11 <- seas(LTts, x11="")
RESULT (Console output):
> LTx11 <- seas(LTts, x11="")
#Error in seas(LTts, x11 = "") : could not find function "seas"
Any tips or suggestions would be greatly appreciated.
After digging around a little more, I found the original text reference where I had learned to use the seas() function in Hyndman's text: https://otexts.com/fpp2/x11.html
In that text, I also found that seas() should be exposed by the seasonal library and verified this in the docs for that library.
After verifying this, added seasonal:: in front of the function and it worked. I wish I knew WHY this happened, but I don't. So here is the workaround.
Workaround:
LTx11 <- seasonal::seas(LTts, x11="")
If anyone can explain why this was necessary in v.4.1.0 and not earlier versions of R, please do!

Error when using *whatNWISdata* function within *dataRetrieval* package from USGS: All components of query must be named

I am trying to use the whatNWISdata function to retrieve all available data for specific USGS sites.
I get the following error after trying to execute the function:
siteNo <- "09508300"
dailyDataAvailable <- whatNWISdata(siteNo, service = "dv", parameterCd = "00060",
statCd = "00003")
Yields:
Error: All components of query must be named
Although I am using the function as recommended in rdocumentation.org and cran, I get the same error. My rstudio is updated to the latest version and so is my dataRetrieval package that this function is part of.
This error was a question that was brought up in 2016 on github, and they recommended downgrading the httr package, but the httr package has been updated since this question was asked and it seems this issue was resolved in the update.
Thanks!
Thank you so much for your input #Dragonthoughts!
I emailed the author and apparently they had made some slight edits in the format of the input values, and yes you are correct in that the first argument needed a value as in the other inputs for the function.
For anyone else having this problem, it works when you change the input to be like this: dailyDataAvailable <- whatNWISdata(siteNumber = "09508300", service = "dv", parameterCd = "00060", statCd = "00003")

unused argument (key = "iris.hex")

When ever I try to run this line or any other line which uses key(following document in http://h2o-release.s3.amazonaws.com/h2o/rel-lambert/5/docs-website/Ruser/rtutorial.html)
iris.hex = h2o.uploadFile(localH2O, path = irisPath, key = "iris.hex")
I get an error in the key calling it as unused argument.
This is the first time I am using H2O and I am new to R as well. Please let me know what is the function of key and only when I run this, I get error. I could create a dataframe with the following statement. But still I would want to understand this key error
h2o.init(ip = "localhost", port = 54321, startH2O = TRUE)
irisPath = system.file("extdata", "iris.csv", package = "h2o")
iris.hex = h2o.uploadFile(path = prosPath, destination_frame = "iris.hex")
iris.data.frame<- as.data.frame(iris.hex)
summary(iris.data.frame)
H2O may be very good in various areas. but unfortunately lack of documentation and tutorial makes it's really difficult to learn...
Hoping that they watch these type of comments and improve their documentation.
At least launching one tutorial of 12GB airlines data processing can help a lot for multiple enthusiastic people who really wanted to explore H2O.
This is a very outdated version of the H2O docs and there have been some major API changes since H2O 3.0. The latest R docs can always be found at: http://h2o-release.s3.amazonaws.com/h2o/latest_stable_Rdoc.html
Our main docs landing page has a link to the latest R docs, Python docs, and a bunch of other links you may find useful. We also have a Google Group called h2ostream for posting new questions and searching through old questions. Welcome to H2O!

Resources