Code producing error message that has previously been working

Hi, I'm using RStudio cloud. It has been working really well (but I couldn't get the same code to work in RStudio) other than the fact that it periodically resets and "wipes" all but the script. I had just been re-running everything, then this morning, for the first time despite no changes, am getting an error message that makes no sense when I am trying to rename columns and I don't know why that would happen.
Any ideas? it is really frustrating!

I imported my file -

data <- read.csv("MyFile.csv")

#Column name changes:
#specify attention check
data <- rename(x = data, replace = c("Q_14" = "Att_check"))

and the error message now reads:

Error in is_null(vars) : argument ".data" is missing, with no default


It looks like the code is accessing the rename() function from dplyr but your arguments are appropriate for the rename() function from plyr. Try

data <- plyr::rename(x = data, replace = c("Q_14" = "Att_check"))
1 Like

thank you so much I'll try that. Do you know if there is anything I can run to check the packages I loaded while I was trying different things that I might not actually need? I'm wondering if I can put in some code to tell me which packages I'm actually using and then bin the ones I'm not?

The function search() will return a character vector of all of the attached packages and objects.

That all worked, thank you! Last question - again, it is bizarre because it worked yesterday, same code, same data, but my code to switch values isn't working either

#Recode each ETest item as 4 and 3=0, 2=1, 1=2

for(ETest_item in ETest_items_vector){
data[ETest_item] = recode(data[,ETest_item], "4=0; 3=0; 2=1; 1=2;")

the message i'm now getting is:

Error in recode(data[, ETest_item], "4=0; 3=0; 2=1; 1=2;") :
could not find function "recode"

If this is the recode function from dplyr, you could try dplyr::recode, though my last suggestion was based on thinking dplyr is loaded. You may have to do as you suggested and work through which packages you actually need and load no more than that. Keep in mind that the order of loading them matters. Those messages about objects being masked need to be heeded.

I am a total novice, my first research, and first use of R or any type of coding so your advice is very very much appreciated. Steep learning curve! Thank you again!

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.