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 8793467
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T23:07:35+00:00 2026-06-13T23:07:35+00:00

Let’s say I have the following data frame: > df = data.frame(seq(0, 150, length.out=11),

  • 0

Let’s say I have the following data frame:

> df = data.frame(seq(0, 150, length.out=11), 1:11, rep(0, 11), sample(1:50, 11), 
+ sample(1:50, 11), sample(1:50, 11))
> colnames(df) = c("Time", "Inc", "Side", "Pat1", "Pat2", "Pat3")
> df
    Time Inc Side Pat1 Pat2 Pat3
1     0   1    0   48   49   13
2    15   2    0   43   33   15
3    30   3    0   27   48   38
4    45   4    0   41   47   46
5    60   5    0   11   25   37
6    75   6    0    5   15    4
7    90   7    0   17   22    2
8   105   8    0   10   41   24
9   120   9    0   45   21   33
10  135  10    0   19   26   41
11  150  11    0   25   42   45

Now I want to repeat the first 3 columns n times (n = number of Pat columns) and attach it one below each other. Then I want to place Pat2 below Pat1, Pat3 below Pat2, …

My first intetion was to split the df into a Time/Inc/Side part and a Pat part, but I had problems arranging the columns below each other. Any suggestions?

  • 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-13T23:07:35+00:00Added an answer on June 13, 2026 at 11:07 pm

    An alternative approach using reshape2 and melt

    # recreate the data 
    df = data.frame(seq(0, 150, length.out=11), 1:11, rep(0, 11), sample(1:50, 11), 
     sample(1:50, 11), sample(1:50, 11))
    colnames(df) = c("Time", "Inc", "Side", "Pat1", "Pat2", "Pat3")
    library(reshape2)
    
    melt(df, id.vars = c('Time', 'Inc', 'Side'))
    
       Time Inc Side variable value
    1     0   1    0     Pat1     7
    2    15   2    0     Pat1    18
    3    30   3    0     Pat1    10
    4    45   4    0     Pat1    35
    5    60   5    0     Pat1    30
    6    75   6    0     Pat1    32
    7    90   7    0     Pat1    12
    8   105   8    0     Pat1    38
    9   120   9    0     Pat1    26
    .......
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Let's say I have the following object: var VariableName = { firstProperty: 1, secondProperty:
let's say I have the following string: string s = A B C D
Let's say I have the following entity: public class Store { public List<Product> Products
Let's say I have the following classes : public class MyProductCode { private String
Let's say I have the following text: (example) <table> <tr> <td> <span>col1</span> </td> <td>col2</td>
Let's say I have a domain object with the following field: private Map<StatType, Double>
Let's say I have some data in a CouchDB database. The overall size is
Let's say I have the following two lists of tuples myList = [(1, 7),
Let's say I have the following function in C#: void ProcessResults() { using (FormProgress
Let's say I don't have photoshop, but I want to make pattern files (.pat)

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.