R Error In Xy.coordsx Y 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
Subscript Out Of Bounds R Error
this site About Us Learn more about Stack Overflow the company Business error in * tmp * subscript out of bounds Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask
Error In Pi[[j]] : Subscript Out Of Bounds Rbind
Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 6.2 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign solving problems of subscript out of bounds in r up Subscript out of bounds - general definition and solution? up vote 18 down vote favorite 19 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 error during wrapup: subscript out of bounds > 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,42921439 1 @January has it. It means you're trying to get something, say a column
be able to write a function that has arguments being objects and column names of these ojbects... A simple example code
Rbind Subscript Out Of Bounds
that doesnt work is the following.. auto_plot <- function (object1,column1,object2,column2) { plot(object1$column1,object2$column2) subscript out of bounds r studio } I get the message: Error in xy.coords(x, y, xlabel, ylabel, log) : x and y lengths differ
Subscript Out Of Bounds Shiny
Maybe the solution is simple but i just couldnt find it.. Thanks a lot for your help.. Achilleas. ______________________________________________ R-help@xxxxxxxxxxxxxxxxx mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://stackoverflow.com/questions/15031338/subscript-out-of-bounds-general-definition-and-solution http://www.R-project.org/posting-guide.html Thread at a glance: Previous Message by Date: Re: [R] dput() error Robin Hankin
non-generic functions Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] termplot() does not https://stat.ethz.ch/pipermail/r-devel/2004-January/028433.html carry subsetting over to carriers that are in the environment https://bugs.r-project.org/bugzilla3/show_bug.cgi?id=6327 but not in the data frame. This generates a "subscript out of bounds" error. > data(ToothGrowth) > logdose <- log(ToothGrowth$dose) > tooth.lm <- lm(len ~ logdose, data=ToothGrowth) > termplot(tooth.lm) ## Works fine > toothVC2.lm <- lm(len ~ poly(dose,2), data=ToothGrowth, + subset=ToothGrowth$supp=="VC") subscript out > termplot(toothVC2.lm) ## Works fine > toothVC.lm <- lm(len ~ logdose, data=ToothGrowth, + subset=ToothGrowth$supp=="VC") > termplot(toothVC.lm) Error in xy.coords(x, y, xlabel, ylabel, log) : subscript out of bounds > traceback() 4: xy.coords(x, y, xlabel, ylabel, log) 3: plot.default(xx[oo], tms[oo, i], type = "l", xlab = xlabs[i], ylab = ylabs[i], xlim = subscript out of xlims, ylim = ylims, main = main[i], col = col.term, lwd = lwd.term, ...) 2: plot(xx[oo], tms[oo, i], type = "l", xlab = xlabs[i], ylab = ylabs[i], xlim = xlims, ylim = ylims, main = main[i], col = col.term, lwd = lwd.term, ...) 1: termplot(toothVC.lm) Because logdose is not in the data frame ToothGrowth, it was not subsetted. Pending better suggestions, I offer the following fix: Replace the lines: if (NROW(tms) < NROW(data)) data <- data[dimnames(tms)[[1]], ] by if (NROW(tms) < NROW(data)) { use.rows <- match(dimnames(tms)[[1]], dimnames(data)[[1]]) data <- data[use.rows, ] } else use.rows <- NULL Then following xx <- carrier(cn[[i]]) add: if(!is.null(use.rows))xx <- xx[use.rows] Alternatively, the (conditional) subsetting may be included within the function carrier() ------------------------------------------------------------------------ ------------- This may be a good time to mention that I'd like to be able to add a smooth to the points that appear when partial.resid=TRUE. One mechanism would be to allow as argument a
subset non-dataframe carriers Summary: termplot; failure to subset non-dataframe carriers Status: CLOSED FIXED Alias: None Product: R Classification: Unclassified Component: Models (show other bugs) Version: old Hardware: ix86 (32-bit) Windows 32-bit Importance: P5 normal Assignee: Jitterbug compatibility account URL: Depends on: Blocks: Reported: 2004-01-04 08:06 UTC by Jitterbug compatibility account Modified: 2004-01-04 08:06 UTC (History) CC List: 0 users See Also: Attachments Add an attachment (proposed patch, testcase, etc.) Note You need to log in before you can comment on or make changes to this bug. Description Jitterbug compatibility account 2004-01-04 08:06:50 UTC From: John Maindonald