Error in UseMethod("select_")

Hi all,
Below error message coming when I run below r code:
my r code here:

etr2018 <-  "/etr_2018_exc_blanks.Rdata"
PeerCodeList <- c('Idv_Ocptn_Cd') # occupation field name

load(etr2018)
# Create the PeerCode by pasting together the columns from PeerCodeList
etr2018$PeerCode <- do.call(paste, c(select(etr2018, one_of(PeerCodeList)), sep="-"))

Error message:
Error in UseMethod("select_") :
no applicable method for 'select_' applied to an object of class "character"

Anyone can help me to resolve that error. Much appreciated your help to resolve that error.
Note: At the beginning I included following library

Include

library(stringr)
library(nabor)
library(data.table)
library(dplyr)
source("main_v3.R")

Thanks and look forward to your tips/help.

Regards,
Moni

The error message is the key, no applicable method for 'select_' applied to an object of class "character" meaning you haven't created a data frame or tibble

Try

something <- as.tibble(etr2018$PeerCode <- do.call(paste, c(select(etr2018, one_of(PeerCodeList)), sep="-"))
1 Like

Hi technocrat,

Thanks so much for your tips!
It's working!
I've updated my code as follows:
etr_2018_exc_blanks$PeerCode <- do.call(paste, c(select(etr_2018_exc_blanks, one_of(PeerCodeList)), sep=""))
[here I used original dataset.]

All the best,
Regards,
Moni

If your question's been answered (even by you!), would you mind choosing a solution? It helps other people see which questions still need help, or find solutions if they have similar problems. Here’s how to do it:

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