Bug 15725 - cannot edit empty dataframe in R.app
Summary: cannot edit empty dataframe in R.app
Alias: None
Product: R
Classification: Unclassified
Component: Misc (show other bugs)
Version: R 3.0.3
Hardware: x86_64/x64/amd64 (64-bit) OS X Mavericks
: P5 enhancement
Assignee: R-core
Depends on:
Reported: 2014-03-26 08:29 UTC by Marc
Modified: 2015-02-15 19:41 UTC (History)
1 user (show)

See Also:


Note You need to log in before you can comment on or make changes to this bug.
Description Marc 2014-03-26 08:29:54 UTC
2014-03-26 08:56:39.842 R[492:707] *** run_REngineRmainloop: exception *** -[__NSArrayM insertObject:atIndex:]: index 1 beyond bounds for empty array caught during REPL iteration.
Comment 1 Brian Ripley 2014-03-26 08:48:03 UTC
From the error message, this is about the editor in R.app: that is not shared by any other platform, including command-line R on OS X.

It works for me in R.app, although I do not see why it is useful to edit an empty data frame.  Did you interact with the editor windows in a way you have not described?
Comment 2 matthew.pugsley 2015-02-15 19:41:21 UTC
I have experienced the same issue as Marc. I tried to edit an empty data frame and add a column. This created the error message that Marc saw. I pressed the stop button on the data editor window. This closed the data editor window. I could not further interact with R. If I tried to just list the value of previously defined variable (x and then enter), the program crashed and I had to force quit.

I am running R 3.1.2 GUI 1.65 Mavericks build (6833) on Mac OS X Yosemite 10.10.2.

As far usefulness, I think it is useful to create a data frame from scratch using a spreadsheet-like user interface. This method is also recommended some sources that I used to find out how to edit a data frame. This bug/issue/change-in-functionality invalidates those documentation sources.

Documentation source #1
*Introductory Statistics with R* (Second Edition) by Peter Dalgaard
Per pg 52, I should be able to enter data into a blank data frame like so:
dd <- data.frame()

fix(dd) is equivalent to dd <- edit(dd)

Documentation source #2
This a web tip from the "For Dummies" brand of books. 

Per this source, I should be able to enter data into a blank data frame like so:

elements <- data.frame()
elements <- edit(elements)

(same method as #1)

Other solutions:
I know from StackOverflow that I can create a dimension blank data frame.

collect1 <- data.frame(id = character(0), max1 = numeric(0), max2 = numeric(0))

I can also create a data frame with a null. This was suggested both on the same stackoverflow thread and also at another website:

---------- // end other solutions

So this is not a show stopper, but it is frustrating that these other documentation sources no longer provide the truth. And if you shouldn't be able to edit an empty data frame, it would be very nice of the data editor window to not allow you to try to add columns. Or R could refuse to open the data editor window. In either case, a helpful message about why the program is not cooperating would be good.

I'm not suggesting that this be done everywhere the user has an opportunity to crash the program. But this particular feature (editing empty data frames) is something that has been documented as not only possible but recommended practice before. So if it's going to cause a crash from now on, it'd be nice to have a warning and not crash. Or restore the ability to edit empty data frames.

My two cents.