Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1092605
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T23:42:30+00:00 2026-05-16T23:42:30+00:00

The R documentation on arrays states The values in the data vector give the

  • 0

The R documentation on arrays states

The values in the data vector give the values in the array in the same order as they would occur in FORTRAN, that is “column major order,” with the first subscript moving fastest and the last subscript slowest.

It then later gives a clarifying example of this by loading data into a two dimensional array:

 > x <- array(1:20, dim=c(4,5))   # Generate a 4 by 5 array.
 > x
      [,1] [,2] [,3] [,4] [,5]
 [1,]    1    5    9   13   17
 [2,]    2    6   10   14   18
 [3,]    3    7   11   15   19
 [4,]    4    8   12   16   20

From experience with other languages, I would think x[1, 2], rather than x[2, 1], would be 2, but this is pretty easy to adjust my thinking to. However, just as quickly as I perform my mental model shift, the next example smashes it apart:

 > i <- array(c(1:3,3:1), dim=c(3,2))
 > i                             # i is a 3 by 2 index array.
      [,1] [,2]
 [1,]    1    3
 [2,]    2    2
 [3,]    3    1
 > x[i]                          # Extract those elements
 [1] 9 6 3

So, I can see what happened here is that we extracted elements x[1, 3], x[2,2], and x[3, 1]. Okay, but doesn’t this run completely counter to above claim of “column major order”?

From what I had understood, i should have been a 2 by 3 array, and R should have interpreted x[i] as x[i[1, 1], i[2, 1]], x[i[1, 2], i[2, 2]], .... However, what we observe is that, instead, R did x[i[1, 1], i[1, 2]], x[i[2, 1], i[2, 2]], ...

Is this a fundamental inconsistency in R, or have I completely misunderstood the documentation?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T23:42:31+00:00Added an answer on May 16, 2026 at 11:42 pm

    “column major order” only means that internally matrices are vectors ordered column by column; see that

    x[1:20]
    

    is 1, 2, 3, ..., 19, 20. Dimensions are ordered as usual in science — first rows, then columns, then depth, then hyperdepth…
    The third example is tricky: if i has the same number of columns that x has dimensions, it is interpreted as vectorized selection. If not, both i and x are flattered to by-column vectors and simple vector indexation rules apply… for instance x[t(i)] is 1:20[c(1,3,2,2,3,1)].

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Documentation simply states that setting setAutosavingDelay to anything > 0 on the shared doc
The documentation for the round() function states that you pass it a number, and
I have read the documentation that states that "given the type of the enum,
I'm trying to iterate through an array of elements. jQuery's documentation says: jquery.Each() documentation
The documentation indicates that the error: option function will make available: XHR instance, a
Documentation is severely lacking on anything to do with stored procedures in mysql with
Documentation can be found here It says in the example: onDrop: Called whenever a
The documentation with the module itself is pretty thin, and just tends to point
The documentation available on the boost website is... limited. From what I've been able
The documentation for +[NSThread detachNewThreadSelector:toTarget:withObject:] says: For non garbage-collected applications, the method aSelector is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.