Error Lines Subscript Out Bounds
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this
Error Subscript Out Of Bounds R Help
site About Us Learn more about Stack Overflow the company Business Learn more string subscript out of bounds error in teradata about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x
Subscript Out Of Bounds R List
Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up How to subscript out of bounds in r fix “Subscript out of bounds error” up vote 1 down vote favorite I have a R code applied on certain data X and Y, The code is rather simple but it gives certain error "Error in `[<-`(`*tmp*`, R, , value = c(1, 1)) : subscript out of bounds" Can anyone please help me to sort it out. #X <- read.table("data1.dat") #Y <-read.table("data2.dat") X <- error in pi[[j]] : subscript out of bounds rbind c(1,2,43,1,6,5,44,6.8,7.8,9.8) Y <- c(1,3,31,26,78,4,5,44,4,6) length(X) length(Y) Rmax <- 15 data_len <- length(X) Z <- as.matrix(cbind(X,Y)) Cen <- matrix(rnorm(2*Rmax),Rmax,2) Xe <- as.matrix(cbind(1,X)) w <- matrix(rnorm(2*Rmax),Rmax,2) lambda <- matrix(rnorm(1*Rmax),Rmax,1) U <- matrix(rnorm(1*Rmax),Rmax,1) gamma <- matrix(rnorm(2*Rmax),Rmax,2) P_matrix <- 10^3*matrix(rnorm(2*2),2,2) Yhat <- matrix(,data_len,1) a1 <- 0 a2 <- 0 a4 <- matrix(rnorm(2),1,2) a3 <- 0 Pz <- 0 P <- matrix(rnorm(1*Rmax),Rmax,1) dist <- numeric(Rmax) r <- 0.04 m3 <- 0 k <- 1 while (k < length(X)){ if(k == 1){ Cen[1,] <- Z[k,]; U[k,] <- 1; lambda <- matrix(sapply(U,function(x){x/sum (U)}),Rmax,1); Yhat[k,] <- Xe[k,]%*%(t(w)%*%lambda) } else { a1 <- big_V(Z[k,]);a2 <- a2+ big_V(Z[k-1,]);a4 <- a4 + Z[k-1,];a3 <- sum(Z[k,]*a4) B <- ((k-1)*(a1+1))+a2-(2*a3); Pz <- (k-1)/B for(i in 1:length(P)){ P[i] <- ((k-1)*P[i])/((k-2)+(P[i])+(P[i])*(dist(Z[k-1,],Z[k,]))) } print(k) for (i in 1:Rmax){ dist[i] <- abs(sqrt(sum((Z[k,]-Cen[i,])^2))) } p1 <- min(dist) p2 <- which.min(dist) m1 <- max(P) m2 <- which.max(P) m3 <- (p1/r)+(Pz/m1) if (Pz > m1 & m3 < 1){ Cen[m2,] <- Z[k,] P[m2] <- Pz } for (i in 1:Rmax){ U[i] <- exp(-r*(abs(sqrt(sum((X[k,]-Cen[i,1])^2))))) } lambda <- sapply(U, function(x) x/sum(U)) P_matrix <- (diag(2)-(t(gamma)%*%lambda%*%Xe[k,]))%*%P_matrix A <- lambda%*%Xe[k,] Z1 <- P_matrix%*%t(A) Z2 <- A%*%P_matrix%*%t(A) Z3 <- diag(15)+Z2 gamma <- t(Z1%*%solve(Z3)) w_bar <- Xe[1
messages Witold E Wolski Threaded Open this post in threaded view ♦ ♦ | Report Content as Inappropriate ♦ ♦ how does a valid subscript can
Error In * Tmp * Subscript Out Of Bounds
produce an "subscript out of bounds" error? how does a valid subscript (see solving problems of subscript out of bounds in r first 2 lines) can produce an "subscript out of bounds" error (see line 4)? 1> sum(!rownames(msexp$rt) %in% msexp$pepinfo$transition_group_id) [1]
Subscript Out Of Bounds R Studio
0 2> sum(!msexp$pepinfo$transition_group_id %in% rownames(msexp$rt)) [1] 0 3> class(msexp$rt) [1] "matrix" 4> msexp$rt = as.matrix(msexp$rt[msexp$pepinfo$transition_group_id,]) Error in msexp$rt[msexp$pepinfo$transition_group_id, ] : subscript out of bounds > -- Witold Eryk Wolski ______________________________________________ [hidden http://stackoverflow.com/questions/26541594/how-to-fix-subscript-out-of-bounds-error email] mailing list https://stat.ethz.ch/mailman/listinfo/r-helpPLEASE do read the posting guide http://www.R-project.org/posting-guide.htmland provide commented, minimal, self-contained, reproducible code. Duncan Murdoch-2 Threaded Open this post in threaded view ♦ ♦ | Report Content as Inappropriate ♦ ♦ Re: how does a valid subscript can produce an "subscript out of bounds" error? On 04/07/2014, 6:35 PM, Witold E Wolski wrote: > how does a valid subscript (see first http://r.789695.n4.nabble.com/how-does-a-valid-subscript-can-produce-an-quot-subscript-out-of-bounds-quot-error-td4693536.html 2 lines) can produce an > "subscript out of bounds" error (see line 4)? > > > 1> sum(!rownames(msexp$rt) %in% msexp$pepinfo$transition_group_id) > [1] 0 > 2> sum(!msexp$pepinfo$transition_group_id %in% rownames(msexp$rt)) > [1] 0 > 3> class(msexp$rt) > [1] "matrix" > 4> msexp$rt = as.matrix(msexp$rt[msexp$pepinfo$transition_group_id,]) > Error in msexp$rt[msexp$pepinfo$transition_group_id, ] : > subscript out of bounds >> > How are we supposed to know, since you didn't show us msexp$pepinfo$transition_group_id or the thing it was indexing, msexp$rt ? Please post reproducible examples. Duncan Murdoch ______________________________________________ [hidden email] mailing list https://stat.ethz.ch/mailman/listinfo/r-helpPLEASE do read the posting guide http://www.R-project.org/posting-guide.htmland provide commented, minimal, self-contained, reproducible code. Duncan Murdoch-2 Threaded Open this post in threaded view ♦ ♦ | Report Content as Inappropriate ♦ ♦ Re: how does a valid subscript can produce an "subscript out of bounds" error? In reply to this post by Witold E Wolski On 04/07/2014, 6:35 PM, Witold E Wolski wrote: > how does a valid subscript (see first 2 lines) can produce an > "subscript out of bounds" error (see line 4)? > > > 1> sum(!rownames(msexp$rt) %in% msexp$pepinfo$transition_group_id) > [1] 0 > 2> sum(!msexp$pepinfo$transition_group_id %in% rownames(msexp$rt)) > [1] 0 > 3>
Home » Support Forums » Bug Reports » 5.x Bug Reports Subscript out of bounds error Submitted by tony_mucci on Thu, 04/09/2015 - 13:36 I have written several programs in Trtue Basic Silver version 5.5 ( in Word) . For all of these programs I receive the same error message: "Subscript http://www.truebasic.com/node/1153 out of bounds occurred on line 91 in main program." It clearly doesn't matter what the program is, or what is on line 91, since I have replaced whatever was on or near 91 with rem statements. Can anyone enlighten me as to what is happening here? Again, I want to emphasize that the error message is "program independent" ; it doesn't matter what program I run. If this is not a common occurrence with a known solution, is there some BASIC "headquarters" I can contact subscript out for registration of this problem? Note e-mail address: Anthony.Mucci@fda.hhs.gov Cut/copy/paste by keys › 5.x Bug Reports Login or register to post comments Comments Subscript out of bounds error Submitted by mcc on Mon, 04/13/2015 - 05:37. Hi Tony, The only place to get help is via this forum. I have been using TB for many many years and have never heard of this sort of problem. In all versions the underlying core code is always the same, so this problem is probably not 'version' related. subscript out of The core of TB is quite robust; it was invented some 50 years ago at Dartmouth and was just about the first usable programming language there ever was. Over the years, in the move from DOS to MS Windows some quirks have crept in here and there. But the core code of TB has never been changed because the source code is no longer available. It apparently was committed to machine language or something at the very outset, and now no one knows what's in there! While there are some old "DOS" limitations still present in the core code, it is usually the add-on Windows features which cause problems, in my experience. I have never seen an actual "bug" in TB itself. The first thing to note is that TB files are in reality just plain ASCII text files. Open any TB program in a text editor and there it is. Usually one uses the '.tru' extension but a plain '.txt' file will work just as well. If you are using MS Word your file might contain all sorts of MS formatting codes and stuff which may be causing the problem. Try writing your program and just save it as a .txt file. You should be able to save it as such from MS Word. Or just use a plain text editor, such as Notepad, Word pad, etc. (or better yet, EditPad Lite or any of the other good free text editors). Then see if the problem goes away. If there is still a