How to accurately use the epi.kappa() function in R? - r

I am attempting to perform a kappa statistic test on 2 indices I created. I've found that there are multiple packages in R that have functions for this and am trying to compare two functions: the epi.kappa() function in the epiR package and the cohen.kappa() function from the psych package.
I was able to successfully use the cohen.kappa() function with my data however, I continue to get errors when using the epi.kappa() function. My code is as follows
library(epiR)
kap.dat = matrix(c(275,78,305,154),nrow=2,byrow=TRUE)
colnames(kap.dat) = c("I1-0","I1-1")
rownames(kap.dat) = c("I2-0","I2-1")
epi.kappa(kap.dat,method="cohen",alternative= "two.sided",conf.level=0.95)
The error I get is:
Error in epi.kappa(kap.dat,method="cohen",alternative="two.sided", :
object `pO.p` not found

Check that you've got the latest version of epiR installed and update if necessary. Latest version on CRAN is 2.0.50. Type help(epi.about) once package loaded --- version of package will be shown at the bottom of the page.

Related

newSeqExpressionSet function troubleshooting in R

I want to rebuild the Ruvseq model based on the "RUVseq" manual in Bioconductor. But, I can't use these newSeqExpressionSet, plotRLE, plotPCA, and library(betweenLaneNormalization)functions. every time it gives: "could not find function newSeqExpressionSet"
I used R 4.2.2 and loaded these libraries:
library(edgeR)
library(RUVSeq)
library(EDASeq)
library(zebrafishRNASeq)

BiodiversityR::accumcomp.long function not found

I am trying to use the function accumcomp.long in the Biodiversity.R package in order to adjust my species accumulation curves in ggplot.
However, calling the function accumcomp.long gives me an error, suggesting that this function perhaps does no longer exists.
accum.long1 <- accumcomp.long(Accum.1, ci=NA, label.freq=5)
Error in accumcomp.long(Accum.1, ci = NA, label.freq = 5) :
could not find function "accumcomp.long"
The function BiodiversityR::accumcomp.long
returns
Error: 'accumcomp.long' is not an exported object from 'namespace:BiodiversityR'
I am not certain whether this is an issue with the package, the way the package is loaded into my R space, or perhaps unrelated to the package simply the format of my data.
My community and environment files are of dataframe class. I have tried loading them as .csv files as well as .rda files, but the error remains.
??accumcomp.long
renders "No results found".
I am using R version 3.5.3 (2019-03-11)
Any suggestions as to what else I could try?
Thanks in advance!
I re-installed the package BiodiversityR and included force = T (as per this thread https://community.rstudio.com/t/could-not-find-function-error-even-though-fun-is-in-namespace-and-has-an-rd-file/91243). I then reloaded the package. I am not sure what force = T does, but the accumcomp.long function now works.

Why is_installed() function does not work?

I am trying to use is_installed() function in order to see if my MASS package is installed or not? However, I get the following ERROR message that is_installed function not found...
Why is that? My R version is 4.0.2...
Use rlang::is_installed but more easily (and this is what that function does anyway) use requireNamespace(x, quietly = TRUE) where x is the package name.

R load a method from a package

I've got a large package. I'd like just one method (and any dependencies it has) to be loaded without having to load the whole package. Is this possible?
You could call upon the specific function in R with the following operator and form: (package name)::(function). An example would be calling upon the round_any() function in the package plyr such as
> plyr::round_any(134, accuracy = 10)
[1] 130

Are there known compatibility issues with R package mgcv? Are there general rules for compatibility?

I use R version 2.15.1 (2012-06-22) and mgcv version 1.7-22
I load the following set of packages in R:
library(sqldf)
library(timeDate)
library(forecast)
library(xts)
library(tseries)
library(MASS)
library(mgcv)
It happens that I can not run a simple model (I omit the code). Even the sample code taken from the help pages:
dat = gamSim(1,n=400,dist="normal",scale=2)
b = gam(y~s(x0)+s(x1)+s(x2)+s(x3),data=dat)
gives an error:
Error in qr.qty(qrc, sm$S[[l]]) :
NA/NaN/Inf in foreign function call (arg 5)
In addition: Warning message:
In smoothCon(split$smooth.spec[[i]], data, knots, absorb.cons, scale.penalty = scale.penalty, :
number of items to replace is not a multiple of replacement length
Note that everything works fine, if I just load the package mgcv and then use the sample code right away. It also works if I just load all the packages and run the sample code. It just does not work if I
load all packages
do some file reading, sqldf statements, ts operations and some models from package forecast.
if I then apply GAM, it does not work anymore.
Apparently the variable definitions in the general environment mess up the functioning of the package.
Are there any known issues? Are there general rules that I have to obey if I load various packages? Can I write code that "disturbed" the package mgcv?
# Richard there are 2 GAM related packages: gam and mgcv. Loading both libraries at the same time usually causes a conflict.
Loading mgcv as the first package solved my problem ... strange but true.

Resources