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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T05:26:38+00:00 2026-06-09T05:26:38+00:00

Here is data: myd <- data.frame (var1.1 = rnorm (10, 5,2), var1.2 = rnorm

  • 0

Here is data:

myd <- data.frame (var1.1 = rnorm (10, 5,2), var1.2 = rnorm (10, 3,1),
                   varA.1 = rnorm (10, 5,2), varA.2 = rnorm (10,1,2), 
                    C.1 = rnorm (10, 3,1), C.2 = rnorm (10, 4,1))

I want create a list with of size 3 (n/2, if n is number of variable in dataframe) (with two columns each)

mylist <- as.list (myd)

creats a list with each variable as component. But I want create list of pair of variable in one unit – var1.1 and var1.2, similarly varA.1 and varA.2 or C.1 and C.2. Thus new list unit has 2 columns each. Any solution ?

  • 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-09T05:26:41+00:00Added an answer on June 9, 2026 at 5:26 am

    I think this will give you what you want:

    lapply(seq(2, ncol(myd), by = 2), function(i) myd[, (i-1):i])
    

    Now lets say you wanted to name each element in the list by the shared variable names of the data frame:

    X <- lapply(seq(2, ncol(myd), by = 2), function(i) myd[, (i-1):i])
    names(X) <- sapply(X, function(x){
        strsplit(names(x)[1], '\\.')[[c(1, 1)]]
    })
    X
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here is small dataset: myd <- data.frame(PC1 = rnorm(5, 5, 2), PC2 = rnorm
Here is my question: myd <- data.frame (V1 = paste (V, 1:1000), V2 =
Here is dataset: set.seed(123) myd <- data.frame (class = rep(1:4, each = 100), yvar
Here is example data: myd <- data.frame (matrix (sample (c(AB, BB, AA), 100*100, replace
I want to read an XML file located here The data looks like this
I have created an xml file here: /data/data/com.appName/emergency.xml Now I want to access this
Here variable data should hold the data getJSON-method returns. But is there something wrong?
I have text file having multiple rows of data.here I want to align all
Data: Here is sample table(TableA) data ID StartTime EndTime 1 2012-03-22 06:00:00.000 2012-03-22 06:30:00.000
I am sending HTTP GET request and receiving data here: ssize_t numBytes = recvfrom(sock,

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.