New member
- Joined
- Feb 3, 2023
- Messages
- 7
- Thread Author
- #1
I have the below function in R. How can I print the output of 'llod' (from the second last line) outside this function?
Code:
apply.llod <- function(vst.grp) {
vst.grp.ercc <- vst.grp[grepl('ERCC', rownames(vst.grp)), ]
dat <- data.frame(
gene <- rep(rownames(vst.grp.ercc), times=ncol(vst.grp)),
expr <- as.vector(vst.grp.ercc),
conc <- concentration[rep(rownames(vst.grp.ercc), times=ncol(vst.grp))])
lm <- lm(expr ~ conc, dat)
seg <- segmented(lm, ~conc)
lld <- seg$psi[2]
llod <- predict(seg, data.frame(conc=lld))[[1]]
}