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

  • Home
  • SEARCH
  • 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 8681569
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T21:32:43+00:00 2026-06-12T21:32:43+00:00

I am putting into R a row-major data as a vector. R interprets this

  • 0

I am putting into R a row-major data as a vector. R interprets this as column-major data and as far as I can see there is no way to tell array to behave in a row-major way.

Let’s say I have:

array(1:12, c(3,2,2), 
    dimnames=list(c("r1", "r2", "r3"), c("c1", "c2"),c("t1", "t2"))
)

Which gives:

, , t1

   c1 c2
r1  1  4
r2  2  5
r3  3  6

, , t2

   c1 c2
r1  7 10
r2  8 11
r3  9 12

I want to transform this data to row-major array:

, , t1
   c1 c2
r1  1  2
r2  3  4
r3  5  6

, , t2

   c1 c2
r1  7  8
r2  9 10
r3 11 12
  • 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-06-12T21:32:44+00:00Added an answer on June 12, 2026 at 9:32 pm

    Assuming that your array is in a, i.e. that you already have this array and can’t change it at read time, then the following will work:

    a <- array(1:12, c(3,2,2), 
               dimnames=list(c("r1", "r2", "r3"), c("c1", "c2"),c("t1", "t2")))
    
    b <- aperm(array(a, dim = c(2,3,2),
                     dimnames = dimnames(a)[2:1]),
               perm = c(2,1,3))
    b
    
    >     b
    , , 1
    
       c1 c2
    r1  1  2
    r2  3  4
    r3  5  6
    
    , , 2
    
       c1 c2
    r1  7  8
    r2  9 10
    r3 11 12
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there a simple way of putting source code into a repository and then
I know there is mysql_fetch_assoc which puts all data from a row into an
This block of code is getting data from a csv, putting it into JSON
I'm having trouble putting this problem into searchable terms. I'm working on an Android
I am putting some heavy though into re-writing the data access layer in my
I'm looking to transfer some data from a multi-million row table into another table.
i'm generating several large Hashmaps and putting them into 1 object on Windows (using
Will simply putting an image into the project folder do it?
What exactly does putting extern C into C++ code do? For example: extern C
I was just putting some thought into different languages (as I'm reviewing for final

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.