I encountered an error in the script that I am writing, this only happens when dplyr starts. I first came across this when I found a function from dplyr that I wanted to use, after which I installed and launched the package. Here is an example of my error:
First I read in a table from excel that has the column values ββthat I will use as indices in it:
library(readxl) examplelist <- read_excel("example.xlsx")
File contents:
1 2 3 4 1 1 4 1 2 3 2 1 4 4 1 4
And then I create a data frame:
testdf = data.frame(1:12, 13:24, 25:36, 37:48)
And then I have a loop that calls a function that uses examplelist values ββas indexes.
testfun <- function(df, a, b, c, d){ value1 <- df[[a]] value2 <- df[[b]] value3 <- df[[c]] value4 <- df[[d]] } for (i in 1:nrow(examplelist)){ testfun(testdf, examplelist[i, 1], examplelist[i, 2], examplelist[i, 3], examplelist[i, 4]) }
When I run this script without dplyr , everything is fine, but with dplyr it gives me an error:
Error in .subset2(x, i, exact = exact) : invalid subscript type 'list'
Why did dplyr error dplyr and how to fix it?