dplyr::filter error, but not for the == reason

The error is "Error in filter_impl(.data, quo) : object '_dplyr_filter_impl' not found"
I have a for loop that has up until a couple of days ago been working fine. I changed the size of the input .data and then had and issue with mdatools, which has been resolved. I am now getting the above error, and I don't understand why. Below is the pertinent code.

level <- levels(.data$Place)
for(i in level)
 {assign(paste0("Class", i), dplyr::filter(.data, Place == i))
 temp_SIMCA <- simca(dplyr::filter(.data, Place == i)[ , !(names(dplyr::filter(.data, Place == i)) %in% drops)])}

Any insight will be helpful.

Hi @DiegoTheGecko -- could you post the output of dput() applied to your table? (Or smaller version of your table if it's more than 50 rows?) That will help folks troubleshoot what might be going on.

I am brand new to using this community. How do I put an example file up? I have a dput output or txt file of some data I can share. It is in fact a filtered group that I created off of this loop at the beginning of the week.

1 Like

You can't share the file, but you can paste its contents: You can copy the dput() output and paste it here between a pair of triple backticks (```), like this:

```
[paste output of dput() here]
```

Ah, well it is too big, the first 2/3 of it gets lost. I will make up a small example version.

Example data. The actual data has >40000 columns, which is signified by the jump from x5 to x40000.

structure(list(x1 = c(18.54816582, -9.891353189, -23.31242892, 
-5.287650562, -46.16125934, -30.03333883, 28.90548588), x2 = c(57.8288443, 
38.45170556, -17.39087878, 57.21453769, -13.56757757, 14.64351475, 
52.99724872), x3 = c(33.48125264, -14.85429708, 81.054707, 54.38507743, 
23.55128244, 72.30890315, -14.24428181), x4 = c(40.78582339, 
32.22607164, 25.12497665, 56.53952981, 44.53448759, 20.66578226, 
-12.80369032), x5 = c(1.512071101, -21.47975789, 45.49699468, 
-4.385417277, -15.73853734, 83.99240902, 28.73790278), x40000 = c(-17.62384625, 
-3.795576346, 29.76438967, 72.23170572, -68.45795549, 60.37422804, 
-56.76775319), x40001 = c(-24.41231102, 9.026253106, -12.88077044, 
-57.67095095, -30.3538712, -59.13110021, -7.551038783), x40002 = c(-24.03026086, 
3.353540934, 37.25669276, 17.05503916, -9.310649566, 52.68837871, 
-53.71208923), x40003 = c(-1.236255251, 51.41055079, -64.835266, 
40.11996692, -15.38699386, -27.75675706, 10.85281402), x40004 = c(-22.57620744, 
-23.9335527, -54.81442323, -40.68955362, -16.03903931, -29.77486848, 
11.20157967), x40005 = c(11.37958342, -28.67856606, -0.122297418, 
7.471062821, -9.766445734, 44.58486322, 73.74395206), Place = structure(c(1L, 
2L, 3L, 2L, 2L, 3L, 4L), .Label = c("Place1", "Place2", "Place3", 
"Place4"), class = "factor"), Date = c(200305L, 191121L, 191210L, 
200130L, 200229L, 191006L, 191216L), Time = c(1245L, 1324L, 1711L, 
2037L, 1046L, 2231L, 1926L), Note = structure(c(1L, 7L, 5L, 4L, 
6L, 3L, 2L), .Label = c("fdhs", "hfds", "jnbf", "jnje", "kjhs", 
"njks", "uekd"), class = "factor")), class = "data.frame", row.names = c("Sample1", 
"Sample2", "Sample3", "Sample4", "Sample5", "Sample6", "Sample7"
))

Great -- the next step is to try turn this into a reprex, which includes all the packages you need to execute the commands you're using, like simca(), so that folks can reproduce the errors accurately.

Here's how you start:

  • First, add the necessarylibrary() commands before the output of dput().
  • Then, assign the output of the structure() command (which will be your table), and rewrite the loop to reflect this.
  • Then copy and paste all this here, between a pair of triple backticks.

I have a whole bunch of libraries/packages that I have been using. Some of them may not be required anymore, but I have included them all here. But like I have said, this code worked at the beginning of this week with all of the libraries/packages being loaded.

library(mdatools)
library(dplyr)
library(dslabs)
library(fields)
library(baseline)
library(pacman)
library(reticulate)
library(readr)
library(data.table)
library(rio)

sampledata <- structure(list(x1 = c(18.54816582, -9.891353189, -23.31242892, -5.287650562, -46.16125934, -30.03333883, 28.90548588), 
                             x2 = c(57.8288443, 38.45170556, -17.39087878, 57.21453769, -13.56757757, 14.64351475, 52.99724872), 
                             x3 = c(33.48125264, -14.85429708, 81.054707, 54.38507743, 23.55128244, 72.30890315, -14.24428181), 
                             x4 = c(40.78582339, 32.22607164, 25.12497665, 56.53952981, 44.53448759, 20.66578226, -12.80369032), 
                             x5 = c(1.512071101, -21.47975789, 45.49699468, -4.385417277, -15.73853734, 83.99240902, 28.73790278), 
                             x40000 = c(-17.62384625, -3.795576346, 29.76438967, 72.23170572, -68.45795549, 60.37422804, -56.76775319), 
                             x40001 = c(-24.41231102, 9.026253106, -12.88077044, -57.67095095, -30.3538712, -59.13110021, -7.551038783), 
                             x40002 = c(-24.03026086, 3.353540934, 37.25669276, 17.05503916, -9.310649566, 52.68837871, -53.71208923), 
                             x40003 = c(-1.236255251, 51.41055079, -64.835266, 40.11996692, -15.38699386, -27.75675706, 10.85281402), 
                             x40004 = c(-22.57620744, -23.9335527, -54.81442323, -40.68955362, -16.03903931, -29.77486848, 11.20157967), 
                             x40005 = c(11.37958342, -28.67856606, -0.122297418, 7.471062821, -9.766445734, 44.58486322, 73.74395206), 
                             Place = structure(c(1L, 2L, 3L, 2L, 2L, 3L, 4L), .Label = c("Place1", "Place2", "Place3", "Place4"), class = "factor"), 
                             Date = c(200305L, 191121L, 191210L, 200130L, 200229L, 191006L, 191216L), 
                             Time = c(1245L, 1324L, 1711L, 2037L, 1046L, 2231L, 1926L), 
                             Note = structure(c(1L, 7L, 5L, 4L, 6L, 3L, 2L), .Label = c("fdhs", "hfds", "jnbf", "jnje", "kjhs", "njks", "uekd"), class = "factor")), 
                        class = "data.frame", 
                        row.names = c("Sample1", "Sample2", "Sample3", "Sample4", "Sample5", "Sample6", "Sample7"))

level <- levels(sampledata$Place)
for(i in level)
{assign(paste0("Class", i), dplyr::filter(sampledata, Place == i))
  temp_SIMCA <- simca(dplyr::filter(sampledata, Place == i)[ , !(names(dplyr::filter(.data, Place == i)) %in% drops)])}

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