httr2 `req_proxy` Error in constants[[]] : subscript out of bounds - r

I have opened an issue with the package developers,Bug Report, it seems there is a bug in httr2::req_proxy that can be found from the document reprex. It seems as though the logic error is coming from httr2::auth_flags() and is trying to select an unavailable matrix position from the list of authentiation options it makes available? Does anyone have any clue as to why the code would be written this way OR any idea on how to refactor to not lose any function but correct the error?
REPREX + Error:
httr2::request("http://hadley.nz") %>%
httr2::req_proxy("20.116.130.70", 3128) %>%
httr2::req_perform()
# Error in constants[[]] : subscript out of bounds
auth_flags() LOGIC:
auth_flags <- function (x = "basic")
{
constants <- c(basic = 1, digest = 2, gssnegotiate = 4,
ntlm = 8, digest_ie = 16, any = -17)
idx <- arg_match0(x, names(constants), arg_nm = "auth",
error_call = caller_env())
constants[[]] # Why is this here?
}

Related

Consistent error message while running grouping analysis in 'plspm' package

I am looking for some help in resolving an error using the partial least squares path modeling package ('plspm').
I can get results running a basic PLS-PM analysis but run into issues when using the grouping function, receiving the error message:
Error in if (w_dif < specs$tol || iter == specs$maxiter) break : missing value where TRUE/FALSE needed
I have no missing values and all variables have the proper classification. Elsewhere I read that there is a problem with processing observations with the exact same values across all variables, I have deleted those and still face this issue. I seem to be facing the issue only when I run the groups using the "bootstrap" method as well.
farmwood = read.csv("farmwood_groups(distance).csv", header = TRUE) %>%
slice(-c(119:123))
Control = c(0,0,0,0,0,0)
Normative = c(0,0,0,0,0,0)
B_beliefs = c(0,0,0,0,0,0)
P_control = c(1,0,0,0,0,0)
S_norm = c(0,1,0,0,0,0)
Behavior = c(0,0,1,1,1,0)
farmwood_path = rbind(Control, Normative, B_beliefs, P_control, S_norm, Behavior)
colnames(farmwood_path) = rownames(farmwood_path)
farmwood_blocks = list(14:18,20:23,8:13,24:27,19,4:7)
farmwood_modes = rep("A", 6)
farmwood_pls = plspm(farmwood, farmwood_path, farmwood_blocks, modes = farmwood_modes)
ames(farmwood)[names(farmwood) == "QB3"] <- "Distance"
farmwood$Distance <- as.factor(farmwood$Distance)
distance_boot = plspm.groups(farmwood_pls, farmwood$Distance, method = "bootstrap")
distance_perm = plspm.groups(farmwood_pls, farmwood$Distance, method = "permutation")
The data is contained here:
https://www.dropbox.com/s/8vewuupywpi1jkt/farmwood_groups%28distance%29.csv?dl=0
Any help would be appreciated. Thank you in advance

"Error in checkForRemoteErrors(val) : 2 nodes produced errors; first error: could not find function "wincrqa"

I am currently trying to run a parallelized RQA with the following code.
library(snow)
library(doSNOW)
library(crqa)
my_wincrqa = function(x, y){
wincrqa(x, y, windowstep = 1000, windowsize = 2000,
radius = .2, delay = 4, embed = 2, rescale = 0, normalize = 0,
mindiagline = 2, minvertline = 2, tw = 0, whiteline = F,
side = "both", method = "crqa", metric = "euclidean", datatype = "continuous")
}
cl<-makeCluster(11,type="SOCK")
start_time <- Sys.time()
WCRQA_list = clusterMap(cl, my_wincrqa, HR_list, RR_list)
end_time <- Sys.time()
end_time - start_time
Unfortunately, I get this: "
Error in checkForRemoteErrors(val) : 2 nodes produced errors; first
error: could not find function "wincrqa"
I know there is probably sum error in setting up the parallel processing, but I am not able to resolve it. I also tried a similar thing using the parallel() package.
I am happy for any help!
Best,
Johnson
The issue is that you’ve loaded and attached the ‘crqa’ package in your main execution environment, but the cluster nodes are running code in separate, isolated R sessions — they don’t see the same loaded packages or global variables!
The easiest solution is to replace use of wincrqa with a fully qualified name, i.e. to use crqa::wincrqa inside your function.
Alternatively, it is possible to attach the ‘crqa’ package on all cluster nodes prior to executing the function:
clusterEvalQ(cl, library(crqa))
WCRQA_list = clusterMap(cl, my_wincrqa, HR_list, RR_list)

Clustering by M3C package : Error in `[.data.frame`(df, neworder2) : undefined columns selected

I had a similar problem to what posted here. To resolve the issue, followed the answer by #Jack Gisby there. Now a new error showed up:
Working on TCGA data , I am getting the same error (first error):
Error in `.rowNamesDF<-`(x, value = value) :
duplicate 'row.names' are not allowed
running duplicated() on each relevant field returned FALSE.
Her is the second error (just after trimming identifiers to not start with a common string like "TCGA-"):
Error in `[.data.frame`(df, neworder2) : undefined columns selected
> traceback()
5: stop("undefined columns selected")
4: `[.data.frame`(df, neworder2)
3: df[neworder2]
2: M3Creal(as.matrix(mydata), maxK = maxK, reps = repsreal, pItem = pItem,
pFeature = 1, clusterAlg = clusteralg, distance = distance,
title = "/home/christopher/Desktop/", des = des, lthick = lthick,
dotsize = dotsize, x1 = pacx1, x2 = pacx2, seed = seed, removeplots = removeplots,
silent = silent, fsize = fsize, method = method, objective = objective)
1: M3C(pro.vst, des = clin, removeplots = FALSE, iters = 25, objective = "PAC",
fsize = 8, lthick = 1, dotsize = 1.25)
I've added to an opened issue on the M3C GitHub.
I got the same error as Hamid Ghaedi while running M3C. I managed to track it down to the following line of code (line 476 on the M3C.R file):
df <- data.frame(m_matrix)
Many of my sample names (column names) started with a number and the data.frame() function added an "X" to the beginning of each name that started with a number ("1" becomes "X1"). This caused a mismatch with the names listed in neworder2.
To get around this problem, I changed all of my sample names to start with a letter and M3C is now running correctly.
Edit: This workaround can be easily applied by using the data.frame() function on your input dataset before running M3C.

R error : "attempt to select less than one element in get1index"

I'm a beginner in R and I'm trying to use the package ClonEvol, however the documentation on the github webpage is very limited. So for now I'm using their example code and trying to adapt it to my data called ce.
ce <- data.frame(
cluster = c(1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,6,6,6,6,7,7,7,7),
gene = c("geneA","geneB","geneC","geneD","geneA","geneB","geneC","geneD","geneA","geneB","geneC","geneD","geneA","geneB","geneC",
"geneD","geneA","geneB","geneC","geneD","geneA","geneB","geneC","geneD","geneA","geneB","geneC","geneD"),
prim.vaf = c(0.5,0,0,0,0.5,0.5,0,0,1,0.5,0,0,1,0.5,0,0.5,0.5,0.5,0,0.5,0.5,0.5,0,1,0.5,0.5,0.5,0)
)
cluster <- ce$cluster
gene <- ce$gene
prim.vaf <- ce$prim.vaf
x <- ce
vaf.col.names <- grep('prim.vaf', colnames(x), value=T)
sample.names <- gsub('prim.vaf', '', vaf.col.names)
x[, sample.names] <- x[, vaf.col.names]
vaf.col.names <- sample.names
sample.groups <- c('P', 'R');
names(sample.groups) <- vaf.col.names
x <- x[order(x$cluster),]
pdf('box.pdf', width = 3, height = 5, useDingbats = FALSE, title='')
pp <- variant.box.plot(x,
cluster.col.name = ce$cluster,
show.cluster.size = FALSE,
cluster.size.text.color = 'blue',
vaf.col.names = vaf.col.names,
vaf.limits = 70,
sample.title.size = 20,
violin = FALSE,
box = FALSE,
jitter = TRUE,
jitter.shape = 1,
jitter.color = clone.colors,
jitter.size = 3,
jitter.alpha = 1,
jitter.center.method = 'median',
jitter.center.size = 1,
jitter.center.color = 'darkgray',
jitter.center.display.value = 'none',
highlight = 'is.driver',
highlight.note.col.name = 'gene',
highlight.note.size = 2,
highlight.shape =16,
order.by.total.vaf = FALSE
)
dev.off()
However, I get the following error :
Error in .subset2(x, i, exact = exact) : recursive indexing failed at level 2
And if I delete cluster.col.name=ce$cluster and vaf.col.names=vaf.col.names, the error becomes the following :
Error in .subset2(x, i, exact = exact) : attempt to select less than one
element in get1index
Has someone any idea of what went wrong ?
I met this error message today. I know little about the R package in this question, but I think I can show what the error message means here. And maybe it is useful for you to find out the problem.
The error occurs when we use NULL as an index to subset a list.
Here are the expressions invoking this error message:
any.list <- list(1, 2, 3)
# If single brackets, no error occurs:
any.list[NULL]
## list()
# If double brackets, the error occurs:
any.list[[NULL]]
## Error in any.list[[NULL]] :
## attempt to select less than one element in get1index
The list above can be any list, or even a vector.
a.vector <- c(1, 2, 3)
a.vector[[NULL]]
## Error in a.vector[[NULL]] :
## attempt to select less than one element in get1index
Here is a similar error message:
any.list[[0]]
## Error in any.list[[0]] :
## attempt to select less than one element in get1index <real>
END

Getting error while using "predict" method for Markov chain implemenattion in R using clickstream package

I have data set for user wise, clicks pattern for each session for one online site.I would like to predict next clicks using Markov chain & its probability.
Following is the my Code:
library(clickstream);
cls2<-readClickstreams(file.choose(),sep = ',',header = TRUE);
mc2<-fitMarkovChain(clickstreamList = cls2,order = 2,control = list(optimizer= "linear"));
pattern <- new("Pattern", sequence = c("/clsisGre/PersonalDetailForm.jsp","/clsisGre/PersonalDetail.jsp"), absorbingProbabilities = data.frame(NULL = 0.9, Success = 0.1));
> resultPattern <- predict(mc2, startPattern = pattern, dist = 1);
Error Message is :
Error in if (nextState %in% object#absorbingStates) { :
argument is of length zero
In addition: Warning message:
In max(cp, na.rm = T) : no non-missing arguments to max; returning -Inf
Need help to handle this error/exception.
Thanks in advance.
Sorry for late update but I am able to crack this problem, So I m posting the same solution which might be helpful for others.
In code (a,b,c,d,e,f,g,h,l,m) is the sequence input for which I would like to build Markov chain.Below code will help to handle the error mentioned in above post.
pattern <- new("Pattern", sequence = c(a,b,c,d,e,f,g,h,l,m),
absorbingProbabilities = data.frame(NULL = 0.9, Success = 0.1));
possibleError <- tryCatch(
suppressWarnings( predict(mc2, startPattern = pattern, dist = 1)),
error=function(e) e
);
if(inherits(possibleError, "error")) next
resultPattern <- predict(mc2, startPattern = pattern, dist = 1);
aa<-attributes(resultPattern)$absorbingProbabilities;
success_mat10[i,2]<-aa$Success;
success_mat10[i,1]<-as.vector(url_mat10[i,1]);

Resources