Error In Data.frame 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 policies of this r subscript out of bounds in matrices site About Us Learn more about Stack Overflow the company Business Learn more
Error In Pi[[j]] : Subscript Out Of Bounds Rbind
about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x error in * tmp * subscript out of bounds 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 Subscript out rbind subscript out of bounds 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 > 0 | reports_to_tie > 0)) # convert to
Error During Wrapup: Subscript Out Of Bounds
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,40921339 1 @January has it. It means you're trying to get something, say a column or row, that doesn't exist. For example, say your
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta solving problems of subscript out of bounds in r Discuss the workings and policies of this site About Us Learn subscript out of bounds r studio more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us
Subscript Out Of Bounds Shiny
Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, http://stackoverflow.com/questions/15031338/subscript-out-of-bounds-general-definition-and-solution helping each other. Join them; it only takes a minute: Sign up Error in R: subscript out of bounds up vote 1 down vote favorite So I'm trying to do something very simple. Loop over a data frame and calculate the max corelation coefficient between a pair of columns. I am trying to do this in R. http://stackoverflow.com/questions/32528077/error-in-r-subscript-out-of-bounds My data frame has been read using fread() Here's my code: I declared max=-1, a=0andb=0in the starting. for(i in 2:1933) { for(j in i+1:1934) { if(is.numeric(data[[i]]) && is.numeric(data[[j]])) { if(isTRUE(sd(data[[i]], na.rm=TRUE) !=0) && isTRUE(sd(data[[j]], na.rm=TRUE) !=0)) { c = cor(data[[i]], data[[j]], use="pairwise.complete.obs") if(isTRUE(c>=max)) { max = c a = i b = j } } } } } The error I get is Error in .subset2(x, i, exact = exact) : subscript out of bounds I do have 1934 columns, I can't figure out the problem. Am I missing something fairly obvious? r share|improve this question asked Sep 11 '15 at 16:28 Mallika 17110 6 Should be (i+1) –Alexey Ferapontov Sep 11 '15 at 16:28 3 you can use combn as an alternative, combn(data, 2, function(x) cor(x[[1]], x[[2]], use="pairwise.complete.obs")) –jenesaisquoi Sep 11 '15 at 16:39 Well I ultimately realized I hadn't cleaned up the data properly, it's done now. What should I do now? Will the mods close this question eventually? @bunk –Mallika Sep
»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 https://www.reddit.com/r/rstats/comments/46lixu/error_in_pij_subscript_out_of_bounds_w_rbind/ by "username"site:example.comfind submissions from "example.com"url:textsearch for https://github.com/rstudio/shiny/issues/1199 "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 subscript out NSFWe.g. subreddit:aww site:imgur.com dogsee the search faq for details.advanced search: by author, subreddit...this post was submitted on 19 Feb 20161 point (67% upvoted)shortlink: remember mereset passwordloginSubmit a new linkSubmit a new text subscript out of postrstatssubscribeunsubscribe9,865 readers~20 users here nowA place to post R stories, questions, and news, For 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<>X2 points · 12 comments Eliminating For Loops?Problems exporting to stata from R7 points · 5 comments R is giving me incorrect quartiles.4 points · 2 comments If the lsmeans packages makes pairwise cont
Sign in Pricing Blog Support Search GitHub This repository Watch 250 Star 1,947 Fork 1,071 rstudio/shiny Code Issues 189 Pull requests 5 Projects 0 Wiki Pulse Graphs New issue subscript out of bounds #1199 Closed abiyug opened this Issue May 26, 2016 · 8 comments Projects None yet Labels None yet Milestone No milestone Assignees No one assigned 3 participants abiyug commented May 26, 2016 I am trying to run a reactive shiny app, and keep getting 'subscription out of bound' error. Warning: Error in .subset2: subscript out of bounds Stack trace (innermost first): 86: reactiveValuesToList 85: as.data.frame Tried to get answer from the community on google and stackoverflow, but no answers. And I am reading that this maybe a bug on renderTable or shiny. Here is the full code to recreate. library(shiny) library(stats) ui <- fluidPage( h1("Temp Predictor for US Mainland"), sidebarLayout( sidebarPanel( numericInput( "new_lat", "Enter latitude between 20 and 60:", 21 ) ), mainPanel( plotOutput("table") ) ) ) server <- function(input, output, session) { load("regression.lm.RData") lat <- reactive({ as.data.frame(reactiveValuesToList(input$new_lat)) }) output$table <- renderTable( predict(regression.lm, lat()) ) } shinyApp(ui, server) abiyug changed the title from Subscript subscript out of bounds to subscript out of bounds May 26, 2016 bborgesr commented May 27, 2016 It looks like the problem is the way you're using reactiveValuesToList(). You cannot pass input$new_lat on to reactiveValuesToList() because input$new_lat is not a reactivevalues object. You can check this yourself by running is.reactivevalues(input$new_lat) and printing the result somewhere inside your server function. But, in any case, I'm a little confused as to what exactly are you trying to do there? input$new_lat is a number -- are yo