plot_histogram() function in R not working. Please assist? - r

I'm trying to make a batch histogram visualization from my data in RStudio. Meaning, I want to create a histogram for each variable in my dataframe at once. For some reason I keep getting an error message saying that the plot_histogram() function doesn't exist. Has anyone else had this problem? Could this be a problem with the latest updated version of R? I recently downloaded R version 4.1.1 and have checked for package updates and am still having this problem. Any help would be much appreciated.
plot_histogram() error message

Okay, so the moral of the story is that the name in the upper left hand corner on the RDocumentation website is the package that needs to be installed for a function to work. So if R is saying that the package doesn't exist, install and load that name.
Package name on RDocumentation

Related

Why can R not find function "getStates"

I am trying to create a character map and was recommended to use Phylotools and Ape packages in R.
I have installed the packages but when I try to do function getStates it comes up with an error message:
x<-getStates(nexdata,"tips")
Error in getStates(nexdata, "tips") : could not find function "getStates"
I have installed the right packages (so I think) and I am quite stuck. Any help would be really appreciated. If you need me to explain anything in more detail let me know.
The function library() loads and attaches add-on packages. You are using phytools and ape, so you should have in your code
library(phytools)
library(ape)
You can read more in the documentation, e.g. at rdocumentation.org/packages/base/versions/3.6.1/topics/library.

Could not find LoadFile() even if a guide says it should exist, am I or the guide wrong? In R

I need to perform an analytic hierarchical process (AHP) on a dataset using R. I have basic understanding of navigation and can follow most guides to perform rudiment analyses. However, I'm not comfortable enough to be sure if I or the guide is wrong.
The guide I've followed is this: https://www.r-bloggers.com/analytic-hierarchy-process-ahp-with-the-ahp-package/.
(I run R version 3.3.2 (2016-10-31) -- "Sincere Pumpkin Patch")
1: I have (successfully) installed and loaded the AHP package using:
devtools::install_github("gluc/ahp", build_vignettes = install.packages("data.tree"))
2: I have (successfully) set working directory using:
setwd("myworkingdirectory")
3: I have attempted (PROBLEM) loaded the file to a variable using:
myahp <- LoadFile("myAHPfile.txt")
Error: could not find function "LoadFile"
3x: As diagnosis I run:
getAnywhere("LoadFile")
no object named ‘LoadFile’ was found
For your information: Step 3x is inspired by this SO answer (Error: could not find function ... in R)
Can someone tell me what I am doing wrong? I greatly appreciate any help.
Both. The guide refers to an old version of the gap package from github. With the latest version from cran (0.2.11), the function is now called Load, and the file format has changed.
If you just want to goof around with the package, I can recommend the online app at ipub.com.
If you insist on following the guide, make sure you get version 0.1.1 from github

choroplethr sudden error in choro$render

very new to R, and this is my first question so please be kind :)
I was working with the choroplethr/choroplethrMaps/choroplethrZip packages for a few days without any issues, but suddenly, I keep getting the an error when I try to visualize a map--I have pasted the output below, and any help would be deeply appreciated.
The most perplexing issue for me is why it suddenly stopped working--I didn't add anything to the script--I get the same error with choroplethr/choroplethrMaps as well. Many thanks for your expertise and patience!
data(df_pop_zip)
choro = ZipChoropleth$new(df_pop_zip)
choro$title = "2012 ZCTA Population Estimates"
choro$ggplot_scale = scale_fill_brewer(name="Population", palette=2, drop=FALSE)
choro$set_zoom_zip(state_zoom="florida", county_zoom=NULL, msa_zoom=NULL, zip_zoom=NULL)
choro$render()
Error in FUN(X[[i]], ...) : attempt to apply non-function
I believe that your error can be solved by typing the following:
# install.packages("devtools")
library(devtools)
install_github("choroplethr", "arilamstein")
library(choroplethr)
If I install choroplethr from CRAN I can replicate your error. If I install it from github I can solve it. Note that the actual R code is currently the same in both github and CRAN, because I recently submitted a new version to CRAN.
When I load the version of choroplethr from CRAN I get this warning:
> library(choroplethr)
Warning message:
package ‘choroplethr’ was built under R version 3.2.4
However, the current version of R is 3.2.3. So it looks like CRAN is using different version of R for what they are distrbuting to the public and what they are using to build packages. I'm not sure why this is.
Note that while I think this solution will work for you, I don't find it particularly satisfying or elegant. I could probably install the development version of R to see if I can replicate (and debug) the issue myself. But at this point I'd rather wait until they officially release the new version to see if it is still present. I really don't have much experience with the development versions of R.

Error: could not find function "forceAndCall" - outdated base package?

I would like to apply the function 'fit.tcopula' from the package 'QRM' - Quantitative Risk Management and get the following error message:
fit.tcopula(Udata, method = 'Kendall')
Error: could not find function "forceAndCall"
Since I have applied the 'Udata' to different copulas from the package 'copula' already - and it worked fine - I assume the input is not an issue.
To my understanding 'forceAndCall' is part of the base package. I use the R version 3.1.3.
According to the documentation the QRM package depends R(>=3.0.1), so my version should be OK. However, listing all functions of my base package with
library(help = 'base')
reveals that the forceAndCall-Function is not there. What would the remedy be? Installing R version 3.2.1?
The reason I ask and not just do it is that I do not possess admin rights for my PC and therefore would be happy to get an opinion beforehand.
I posted the question though I already have the answer as it might be interesting to others.
Upgrading to R version 3.2.1 is the/one solution to the problem!

R package Ecdat stopped working

Before (1 week ago) the R package Ecdat was working and I have not changed anything, now I've tried to re-install the package, to have a look on the directory installation and the version it access it, and still couldn't find any answer.
I have tried with both RStudio and R to manage the problem.
library("Ecdat", lib.loc="C:/Users/Melonfarmer Johnes/Documents/R/win-library/2.15")
plot(Capm[,"rmrf"],Capm[,"rcon"])
Error in plot(Capm[, "rmrf"], Capm[, "rcon"]) : object 'Capm' not found
I don't think this would have ever worked. The data instruction to load your Capm dataset is missing :
library(Ecdat)
data(Capm)
plot(...)

Resources