Mark a function as deprecated in customised R package [closed] - r

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 5 years ago.
Improve this question
I built my first R package months ago and I now realise some of my older functions are looking a bit dated. I'm already writing better functions to replace them.
I've seen how other R packages warn of deprecated functions, and redirect users to the newer functions. I want to do the same.
How do I mark a function as deprecated in R? Do I just set a warning?

The answer is to call the .Deprecated function from base R:
f_old = function(x) {
.Deprecated("f_new")
return(x * x)
}
f_new = function(x) {
return(x^2)
}
This will give the appropriate warning:
> f_old(4)
[1] 16
Warning message:
'f_old' is deprecated.
Use 'f_new' instead.
See help("Deprecated")

Related

How do I translate in R? [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 2 years ago.
Improve this question
I am trying to compute this in R
When I tried
exp(1)^ln(1.89)/10
I get the error: Error in ln(1.89) : could not find function "ln"
I was wondering if ln is ^
I tried exp(1)^(1.89/10) but I get a value of 1.208041 and the answer should be 1.066.
Am I translating the equation into R correctly?
log() is the function you are looking for
T_val <- 2 # some value
exp(log(1.89) / 10 * T_val)
You should log and not ln. Moreover, parenthesis are important due to operator precedence (^ versus / and *).

matplot is missing from CRAN? [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 6 years ago.
Improve this question
Im taking an R programming class that is using the package "matplot" for a demo. I cant find "matplot" in CRAN so i'm assuming it has been replaced/deleted/changed. Is there another package that replaced it?
There is a matplot function within the graphics library. Here's an example from the documentation:
require(grDevices)
matplot((-4:5)^2, main = "Quadratic")
Also, matplot is a plotting library for PHP. Perhaps your instructor could help clarify what is expected.

Function error in R "setnames" [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 6 years ago.
Improve this question
I made an upgrade in R, and since then, I have a lot of errors in programs which were working well before.
The one I cannot go around is :
Error: could not find function "setnames"
I am loading the packages (
library(plyr)
library(dtplyr)
library(tidyr)
library(lsr)
library(ggplot2)
library(stats)
and i am using R :
platform x86_64-w64
major 3
minor 3.2
Does anybody knows how to go around please ?
It's probably a typo, if you're referring to setNames in stats.
Remember to capitalize the 'n'.
See https://stat.ethz.ch/R-manual/R-devel/library/stats/html/setNames.html
(The other possibility is that you may not have loaded the data.table package. See, for example, Using data.table::setnames() when some column names might not be present)

R can't find function after installing package [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 7 years ago.
Improve this question
I'm trying to use the function isdigit but R can't find it, even after I installed the qmrparser package and submitted the code library(qmrparser).
(I'm brand new to R so please explain like I'm 5!)
Try
library(qmrparser)
to load / attach the package. Failing that, try
qmrparser::isdigit()
to call it up explicitly using the :: operator along with the package name.
You can have thousands of packages installed, so installed does not automate loading (though you can arrange for that, but that is a different topic).
Edit: And if the function is not accessible even after loading try the 'triple-:' operator to access non-exported sysmbols:
qmrparser:::isdigit()
Edit 2: Your premise was wrong as the function is called isDigit with a capital-D. So you have to type
isDigit()
which will get you the function as it is exported via NAMESPACE.

has the %between% command in R been removed? [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 7 years ago.
Improve this question
I am returning to some old code where I had used the following syntax:
y[df$myvar %between% c(1,100)]
but get the error
could not find function "%between%"
This code used to work, and I have updated R in the mean time. any thoughts?
As Pascal pointed out, you should load the package data.table first:
library(data.table)
Then you'll be able to use it.

Resources