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

Use Markdown

library(dpylr)
```{r}
data2_1<- data.frame(data1$dos1[[1]])
data2_2<- data.frame(data1$dos2[[1]])
data2_3<- data.frame(data1$dos3[[1]])
data2_4<- data.frame(data1$dos4[[1]])
data2_5<- data.frame(data1$dos5[[1]])
data2_6<- data.frame(data1$dos6[[1]])
data2_7<- data.frame(data1$dos7[[1]])
```
```{r}
data2_12<- full_join(data2_1,data2_2, by = "CODOPERACION")
data2_13<- full_join(data2_2,data2_3, by = "CODOPERACION")
data2_14<- full_join(data2_3,data2_4, by = "CODOPERACION")
data2_15<- full_join(data2_4,data2_5, by = "CODOPERACION")
data2_16<- full_join(data2_5,data2_6, by = "CODOPERACION")
data2_17<- full_join(data2_6,data2_7, by = "CODOPERACION")
```
```{r}
for (i in 1:7) {
  paste0("data2_1",i) <- paste0("data2_1",i) %>% 
  mutate(
  ope_dudosas1 =  ifelse(DUDOSANORMAL.x=="dudoso" & DUDOSANORMAL.y=="normal",1,
                              ifelse(DUDOSANORMAL.x=="normal" & DUDOSANORMAL.y=="dudoso",2,
                              ifelse(DUDOSANORMAL.x=="normal" & DUDOSANORMAL.y=="normal",3,
                              ifelse(DUDOSANORMAL.x=="dudoso" & DUDOSANORMAL.y=="dudoso",4,10))))
        )
}

```

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

You could help me with this problem please

Could you please provide some context as to what you're trying to achieve? What does your desired output look like?

I have several databases which I want to add a column to all the bases called ope_dudosas, with the data of those bases

mutate() takes a data frame as its first argument (the thing passed into the pipe). I don’t understand the goal of the assignment paste0("data2_1",i) <- paste0("data2_1",i), but the result is a character string, not a valid reference to a data frame.

For clarification, do you mean data frames here? (data frame = an R object; data base = an external system for data storage, such as MySQL)

Is there any way you can come up with a small reproducible example of the sort of thing you’re trying to do? I think it will help people better understand your problem and suggest better solutions. (Complete reproducibility can be hard when databases are involved, but as close as possible is still helpful)

1 Like