I am trying to use the randomly sampled letter from nbMtx$R to sample from one of the other components of the list, but I am getting an error that says I have the incorrect number of probabilities in my second attempt at sampling. I have called length(nbMtx[start]) and it returns [3], so I'm not sure why my probability vector visit_prob (which has 3 values) isn't working. I also tried replacing the prob argument in the second sample with c(.3, .3, .3) just to be sure, and that also did not work.
set.seed(514) #seed in reference to the class’ code
nbMtx <- list() #Rory’s neighborhood connections
nbMtx$R <- c("L","P","D","J")
nbMtx$L <- c("P","R","D")
nbMtx$P <- c("L","R","J")
nbMtx$D <- c("L","R","J")
nbMtx$J <- c("P","R","D")
original_prob<- rep.int(.25, 4)
visit_prob<- rep.int((1/3), 3)
start<- sample(nbMtx$R, 1, replace=FALSE, prob=original_prob)
visit<- sample(nbMtx[start], 1, replace=FALSE, prob=visit_prob)
Error in sample.int(length(x), size, replace, prob) :
incorrect number of probabilities