Please help - object of type 'closure' is not subsettable error!

Hi all,

I am trying to optimize a PCR reaction but keep getting the error 'object of type 'closure' is not subsettable'.

Does anyone know where this is?
install.packages("readxl")
install.packages("knitr")
install.packages("kableExtra")

library(readxl)
library(knitr)
library(kableExtra)

PCR_REACTION <- read_excel("D:/joey/PCRREACTION.xlsx")
PCR_REACTION$Factors <-c("No.of cycles","Each Dntp",
"Each primer", "Plasmid", "Polymerase")
PCR_REACTION <-PCR_REACTION[,c(4,2,3)]
colnames(PCR_REACTION) <-c("Factor", "+1", "-1")

kable(PCR_REACTION, align = "l", caption =
"Table 1. Factors and Levels Assayed in Fractional Factorial Design") %>%
kable_styling(bootstrap_options = c("striped", "condensed", "responsive",
font_size = 16), position="left") %>%
row_spec(1:5, font_size = 16)
View(PCR_REACTION)

install.packages("AlgDesign")
library(AlgDesign)

Data <- gen.factorial(levels=2,nVars=5,center=TRUE, varNames=c("No.of cycles","Each Dntp","Each primer","Plasmid","Polymerase")

#specify the quarter design using Federov's exchange algorithm and 8 experiments
FFD_quarter <- function(optFederov) {return(~.,data,8) }
FFD_quarter$design <-write.csv(FFD_quarter$design,
file="FFD_quart_design.csv")

This code is confusing to me on the grounds that.
the majority of it from the beginning seems oriented around getting and manipulating a PCR_REACTION object
Then you introduce a library(AlgDesign)
The code from this point makes no reference to PCR_REACTION.
So is PCR_REACTION relevant ?

I use the alg design library to make the FFD for the analysis

I'm not 100% sure, but I think the above line could be causing trouble. It looks like you're missing a closed parenthesis: you have ( after gen.factorial, and then you have another ( after c, but you only have one, not two, )'s after "Polymerase".

Give that a try and see if it fixes things?

That fixed another error I was getting but didn't solve the object closure error, thanks so much though!

Its not straightforwardly easy to know what causes your error as it's not possible to run your code (it includes data only you have...)
Here is a guide on how you can approach that.

I was asking about the relevance as it seems you have one complaint , but two unrelated codes, I was attempting to identify the problematic code. I hope you understand my intentions.

My data is quite simple as im doing a design of experiments approach to find optimal pcr conditions but havent gotten very far without getting an error.
#This is the data im going off

|Factor|Level_Plus|Level_Minus|
|No.of cycles |100 |1|
|tds |5 |8|
|primer | 0. 5 |60|
|membrane| 0.7| 60|
|Polymerase| 0.2 |50|

Thank you! Ill have a read of that page too :slight_smile:

@nirgrahamuk

Hi Nir,

I dont suppose you have any more advice to offer regarding this error please? I still havent found a solution (very new to this)

library(AlgDesign)

Data <- gen.factorial(levels=2,
                     nVars=5,
                     center=TRUE,
                     varNames=c("No.of cycles",
                                "Each Dntp",
                                "Each primer",
                                "Plasmid",
                                "Polymerase"))

#FFD_quarter <- function(optFederov) {return(~.,data,8) }
FFD_quarter <- optFederov(~.,Data,8)
1 Like

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

If you have a query related to it or one of the replies, start a new topic and refer back with a link.