Function error in R "setnames" [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 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)

Related

Undefined Columns Selected (when using order function) [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 5 years ago.
Improve this question
I have searched for answers to my question and can't seem to find any answer. I am trying to sort my data so that I can first sort by year of birth and then by last name. Here is my code:
ResidentsBD_99_2015_clean < ResidentsBD_99_2015_clean[order(ResidentsBD_99_2015_clean[, birthdate_year],
ResidentsBD_99_2015_clean[, "surname"],
decreasing = FALSE), ]
When I run this code, this is the error message that I recieve:
Error in `[.data.frame`(ResidentsBD_99_2015_clean, , birthdate_year) :
undefined columns selected
You might just be stuck with typos in your code. birthdate_year should be quoted. It also looks like you have a typo in the assign-operator (<-).
In a more general sense, I prefer ordering with dplyr.
library(dplyr)
ResidentsBD_99_2015_clean <- arrange(ResidentsBD_99_2015_clean, birthdate_year, surname)
From what I can see from your code, it might just be the missing - in the assignment and some small syntax problem. Try this:
ResidentsBD_99_2015_clean<- ResidentsBD_99_2015_clean[order(ResidentsBD_99_2015_clean$birthdate_year, ResidentsBD_99_2015_clean$surname),]

Mark a function as deprecated in customised R 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 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")

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.

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