Unused argument error in EpiR - r

I'm getting an unused argument error in the following code:
epi.tests(dat4, verbose = TRUE)
# Error in epi.tests(dat4, verbose = TRUE) :
# unused argument (verbose = TRUE)
What could be causing this and how could I fix the issue?
Thanks

Look at ?epiR::epi.tests.
The Usage section indicates that the function should be used as:
epi.tests(dat, conf.level = 0.95)
There is no verbose argument to that function - it only accepts dat (to which you are passing dat4, and conf.level (whose default is 0.95).
Try again with epi.tests(dat4).

Related

tdplyr - (TDR_E1001) using fastload

I am getting some weird errors, when I try to upload a data.frame to the Teradata database using td_fastload() in R.
The copy_to() method works for smaller sets without any issues, just takes a while... but td_fastload() for bigger sets don't work, here is what I am getting, what does this mean ?
my command is:
td_fastload(con, df = TEST55, table.name = "TEST55", overwrite = TRUE )
and the errors are:
Error: In value[[3L]](cond):
[tdplyr - (TDR_E1001)] Error: In value[[3L]](cond):
[tdplyr - (TDR_E1001)] Error in obtainRows(res, FALSE, params): Argument params class character differs from the required data.frame or list
In addition: Warning messages:
1: In td_fastload(con, df = TEST55, table.name = 'TEST55', overwrite = TRUE):
[tdplyr - (TDR_W1011)] Setting 'overwrite = TRUE' will drop existing table 'TEST55' and recreate it with new schema.
2: In sprintf(gettext(fmt, domain = domain, trim = trim), ...) :
one argument not used by format 'Error in obtainRows(res, FALSE, params): Argument params class character differs from the required data.frame or list
'
3: In sprintf(gettext(fmt, domain = domain, trim = trim), ...) :
one argument not used by format 'Error: In value[[3L]](cond):
[tdplyr - (TDR_E1001)] Error in obtainRows(res, FALSE, params): Argument params class character differs from the required data.frame or list```

How to solve unused argument error as part of a meltAssay?

When using meltAssay to convert a SummarizedExperiment object, the central data infrastructure for microbiome analysis in Bioconductor, into long data.frame, I use the following lines according to the instructions in the book:
tse <- transformSamples(tse, method="relabundance")
molten_tse <- meltAssay(tse,
add_row_data = TRUE,
add_col_data = TRUE,
assay_name = "relabundance")
molten_tse
However, I get the following error:
Error in .melt_assay(x, abund_values, feature_name, sample_name, ...)
: unused argument (assay_name = "relabundance")
Use the following syntax instead: (abund_values instead of assay_names.
There seems to be an error in the book)
molten_tse <- meltAssay(tse,
add_row_data = TRUE,
add_col_data = TRUE,
abund_values = "relabundance")

Simple regression linreg error in R: argument 'modeltest'must be either TRUE or FALSE

Hello everyone I am having an issue with my R software. When I try to run a simple regression i get this error:
model1 <- linReg(data = dat, dep = 'Intent', blocks = list(c('Enjoy')), modelTest = 'f', stdEst = TRUE)
model1
Error: Argument 'modelTest' must be either TRUE or FALSE
I have tried changing the to a capital and typing in FALSE instead but when I type in FALSE I get this error:
model1 <- linReg(data = dat, dep = 'Intent', blocks = list(c('Enjoy')), modelTest = FALSE, stdEst = TRUE)
Error in eval(predvars, data, env) : object 'XRW5qb3k' not found
Can anyone please help me with this? All o the descriptives, graphs, and plots run just fine. I have the packages jmv, psych, and car loaded
Thank you for your help!

Trapping error in R

A very basic quesiton. But i am not able to apply this to my code. Hence seeking help here
I am getting an error mentioned below while running this R code
knn.pred <- knn(tdm.stack.nl_train, tdm.stack.nl_Test, tdm.cand_train, prob = TRUE)
> Error in knn(tdm.stack.nl_train, tdm.stack.nl_Test, tdm.cand_train, prob = TRUE) :
> dims of 'test' and 'train' differ.
I want to print the error message as given below. However I could not achieve this. I am not good in writing functions yet.. Please help.
out <- tryCatch( when error = {print('New words seen in testing data')})
It's better and easier to use try:
knn.pred <- try(knn(tdm.stack.nl_train, tdm.stack.nl_Test, tdm.cand_train, prob = TRUE))
if (inherits(knn.pred, "try-error") { # error management
print('New words seen in testing data')
}
You could do:
tryCatch(knn.pred <- knn(tdm.stack.nl_train, tdm.stack.nl_Test, tdm.cand_train, prob = TRUE),
error = function(e) {
stop('New words seen in testing data')
})
This shows up as:
tryCatch(knn.pred <- knn(tdm.stack.nl_train, tdm.stack.nl_Test, tdm.cand_train, prob = TRUE),
error = function(e) {
stop('New words seen in testing data')
})
Error in value[[3L]](cond) : New words seen in testing data

Error in get(as.character(FUN), mode = "function", envir = envir)

I am new to R, so forgive me if the question is a little silly.
I am trying to write a simple while loop for a value function iteration. My function (optim.routine) uses the solver ipoptr. Here is my code:
d<-1
old1<-0
old2<-0
num.iter<-0
i.esp<-1e-05
i.T<-100
lb<-0
ub<-10
while (d>i.eps & num.iter<i.T){
new1 <- optim.routine(old1, old2, eval_f=eval_f, eval_grad_f=eval_grad_f, lb=lb, ub=ub, update=FALSE)
d<-dist(c(old1, new1), method="euclidean")
num.iter<-num.iter+1
old1<-new1
}
where optim.routine is the following function:
optim.routine<-function(old1, old2, eval_f=obj, eval_grad_f=obj.deriv, lb=lb, ub=ub, update){
if (isTRUE(update)){
var2<-old2
var1<-old1
var1.deriv<-deriv(var1)
optimize <- ipoptr(x0 = old2, eval_f = eval_f, eval_grad_f = eval_grad_f, lb = lb,
ub = ub)
new1<- optimize$objective
new2<- optimize$solution
old2<-new2
old1<-new1
}else{
var2<-old2
var1<-old1
var1.deriv<-vf.deriv(var1)
optimize <- ipoptr(x0 = old2, eval_f = eval_f, eval_grad_f = eval_grad_f, lb = lb,
ub = ub)
new1<- optimize$objective
new2<- optimize$solution
old1<-new1
}
}
and deriv is a function that computes derivatives.
I get the following error if i try to run the code:
source('/mnt/ide0/home/myname/Documents/optim.R')
Error in get(as.character(FUN), mode = "function", envir = envir) :
object 'fn' of mode 'function' was not found
and if I debug the function:
Browse[2]> n
Error in isTRUE(update) : argument "update" is missing, with no default
If I only source the function without the while loop no error is displayed. Honestly, I have no clue. Any help is greatly appreciated. Thanks!
Claudia
I had exactly the same error message when I named a variable with the
same name of an existing function in R. I've found this tip
here: http://notepad.patheticcockroach.com/2565/a-bad-idea-in-r-using-variables-with-the-same-name-as-existing-functions/ Hope it helps you too.
– FraNut Oct 12 at 11:26
He's right refrain from using variables that might be function names too.
e.g
z1<-aggregate(steps ~ interval, data_df, mean)
mean<-mean(z[,2],na.rm = TRUE)
mean is a variable and a function name passed as an argument to the aggregate function causing a conflict
Many times that error will appear when you previously created an object called "mean" in the R environment. This creates a conflict when calling the function "mean". To stop this error use:
rm(mean)
This removes the object "mean" from the environment and allows R to call the function "mean".

Resources