Error Subscript Out Of 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 error subscript out of bounds r help policies of this site About Us Learn more about Stack Overflow the company
Error Subscript Out Of Bounds R
Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users google error subscript out of bounds Badges Ask Question x 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
Task 1 Failed Subscript Out Of Bounds
minute: Sign up Subscript out of bounds - general definition and solution? up vote 16 down vote favorite 18 When working with R I frequently get the error message "subscript out of bounds". For example: # Load necessary libraries and data library(igraph) library(NetData) data(kracknets, package = "NetData") # Reduce dataset to nonzero edges krack_full_nonzero_edges <- subset(krack_full_data_frame, (advice_tie > 0 | friendship_tie error in x i subscript out of bounds > 0 | reports_to_tie > 0)) # convert to graph data farme krack_full <- graph.data.frame(krack_full_nonzero_edges) # Set vertex attributes for (i in V(krack_full)) { for (j in names(attributes)) { krack_full <- set.vertex.attribute(krack_full, j, index=i, attributes[i+1,j]) } } # Calculate reachability for each vertix reachability <- function(g, m) { reach_mat = matrix(nrow = vcount(g), ncol = vcount(g)) for (i in 1:vcount(g)) { reach_mat[i,] = 0 this_node_reach <- subcomponent(g, (i - 1), mode = m) for (j in 1:(length(this_node_reach))) { alter = this_node_reach[j] + 1 reach_mat[i, alter] = 1 } } return(reach_mat) } reach_full_in <- reachability(krack_full, 'in') reach_full_in This generates the following error Error in reach_mat[i, alter] = 1 : subscript out of bounds. However, my question is not about this particular piece of code (even though it would be helpful to solve that too), but my question is more general: What is the definition of a subscript-out-of-bounds error? What causes it? Are there any generic ways of approaching this kind of error? r matrix sna share|improve this question asked Feb 22 '13 at 19:00 histelheim 1,41921339 1 @January has it. It means you
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 site About Us
Error In E1 J Subscript Out Of Bounds
Learn more about Stack Overflow the company Business Learn more about hiring developers
Subscript Out Of Bounds List R
or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack error in pi[[j]] : subscript out of bounds rbind 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 R error type “Subscript out of bounds” up http://stackoverflow.com/questions/15031338/subscript-out-of-bounds-general-definition-and-solution vote 1 down vote favorite I am simulating a correlation matrix, where the 60 variables correlate in the following way: more highly (0.6) for every two variables (1-2, 3-4... 59-60) moderate (0.3) for every group of 12 variables (1-12,13-24...) mc <- matrix(0,60,60) diag(mc) <- 1 for (c in seq(1,59,2)){ # every pair of variables in order are given 0.6 correlation mc[c,c+1] <- 0.6 mc[c+1,c] <- 0.6 } http://stackoverflow.com/questions/21114784/r-error-type-subscript-out-of-bounds for (n in seq(1,51,10)){ # every group of 12 are given correlation of 0.3 for (w in seq(12,60,12)){ # these are variables 11-12, 21-22 and such. mc[n:n+1,c(n+2,w)] <- 0.2 mc[c(n+2,w),n:n+1] <- 0.2 } } for (m in seq(3,9,2)){ # every group of 12 are given correlation of 0.3 for (w in seq(12,60,12)){ # these variables are the rest. mc[m:m+1,c(1:m-1,m+2:w)] <- 0.2 mc[c(1:m-1,m+2:w),m:m+1] <- 0.2 } } The first loop works well, but not the second and third ones. I get this error message: Error in `[<-`(`*tmp*`, m:m + 1, c(1:m - 1, m + 2:w), value = 0.2) : subscript out of bounds Error in `[<-`(`*tmp*`, m:m + 1, c(1:m - 1, m + 2:w), value = 0.2) : subscript out of bounds I would really appreciate any hints, since I don't see the loop commands get to exceed the matrix dimensions. Thanks a lot in advance! r loops share|improve this question edited Jan 14 '14 at 13:48 asked Jan 14 '14 at 13:29 Gina Zetkin 76118 try putting cat() or print() statements in your code to see what's going on, or use options(error=recover) to have R dump you into a browser when an error occurs ...
»reddit.comrstatscommentsWant to join? Log in or sign up in seconds.|Englishlimit my search to /r/rstatsuse the following search parameters to narrow your results:subreddit:subredditfind submissions in "subreddit"author:usernamefind submissions by "username"site:example.comfind submissions from https://www.reddit.com/r/rstats/comments/46lixu/error_in_pij_subscript_out_of_bounds_w_rbind/ "example.com"url:textsearch for "text" in urlselftext:textsearch for "text" in self post contentsself:yes (or self:no)include (or exclude) self postsnsfw:yes (or nsfw:no)include (or exclude) results marked as NSFWe.g. subreddit:aww site:imgur.com dogsee the search faq for details.advanced search: subscript out by author, subreddit...this post was submitted on 19 Feb 20161 point (67% upvoted)shortlink: remember mereset passwordloginSubmit a new linkSubmit a new text postrstatssubscribeunsubscribe9,894 readers~10 users here nowA place to post R stories, questions, and news, For subscript out of posting problems, Stack Overflow is a better platform, but feel free to cross post them here or on #rstats (Twitter). The only rule: be polite. Other R-related subs to check out: /r/Rlanguage, /r/Rshiny, /r/RStudio created by ffualoa community for 7 yearsmessage the moderatorsMODERATORSvsbuffalohadleyffualodeanat78hrbrmstrkrossvalidateabout moderation team »discussions in /r/rstats<>X4 points The North of England has terrible mental health· 3 comments Is there a simple way to find text strings that are surrounded by html/xml tags?4 points · 4 comments T test vs regression in R2 points · 5 comments Intended or unintended problems with data.table's column naming commands2 points · 2 comments Cronbach’s alpha for a row of values18 points