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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T10:38:14+00:00 2026-06-18T10:38:14+00:00

How to export data and its label, heading, information-about data for layman understanding- into

  • 0

How to export data and its label, heading, information-about data for layman understanding- into a single excel sheet when the data is generated through double-for-loop at different stages within single iteration.
Code:

 k=3
 t=2
   o=seq(from=1, to=t, by=1)
    for(i in 1:t){
        v=((o[i])+1)
        print ("treatments")
        print (v)
        h=seq(from=0, to=o[i], by=1)
        q1=NULL
        q2=NULL
        x1=NULL
           for(j in 1:o[i]){
              q1=c((v-(4*h[j]+1)))
              q2=c(((4*h[j])+2))
              T=c(q1,q2)
              y=c(0)
              IB=c(y,cumsum(T)%%v)
              print("The Initial Block(s) is/are=")
              print(IB)
                   p=seq(from=0, to=v-1, by=1)
                   l=NULL
                     for(i in 1:k){
                     for(j in 1:v){
                     l=c(l,rep((IB[i]+p[j]+v)%% v))
                     }
                    }
              x= matrix(c(l),nrow=k,ncol=v,byrow = TRUE)
              x1=cbind(x1,x)
                }
         print ("Design Matrix is")
         print (x1)
       }

At first iteration, the output is:

        [1] "treatments"
        [1] 3
        [1] "The Initial Block(s) is/are="
        [1] 0 2 1
        [1] "Design Matrix is"
        [,1] [,2] [,3]
 [1,]    0    1    2
 [2,]    2    0    1
 [3,]    1    2    0

At 2nd iteration, the output is

  [1] "treatments"
  [1] 5
  [1] "The Initial Block(s) is/are="
  [1] 0 4 1
  [1] "The Initial Block(s) is/are="
  [1] 0 0 1
  [1] "Design Matrix is"
       [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10]
 [1,]    0    1    2    3    4    0    1    2    3     4
 [2,]    4    0    1    2    3    0    1    2    3     4
 [3,]    1    2    3    4    0    1    2    3    4     0

and so on …

please consider

  1. The output may be in the sequence as mentioned on single excel sheet of a file.

  2. Matrix may be cell by cell– I have tried but it pasted in single cell.

  3. Please ask if something ambiguous.

  4. Codes are very lengthy so one may take his/her own example please.

  • 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-18T10:38:15+00:00Added an answer on June 18, 2026 at 10:38 am

    For the record, this is a terrible, terrible way to display information.

    library(XLConnect)
    wb <- loadWorkbook("~/Desktop/so/terrible_idea.xlsx",create = TRUE)
    sht <- "Horrible Way To Display Data"
    createSheet(wb,name = sht)
    
    k=3
     t=2
       o=seq(from=1, to=t, by=1)
        for(i in 1:t){
            v=((o[i])+1)
            print ("treatments")
            appendWorksheet(wb,data.frame("treatments"),sheet = sht,header = FALSE)
            row_counter <- row_counter + 1
            print (v)
            appendWorksheet(wb,as.data.frame(v),sheet = sht,header = FALSE)
            h=seq(from=0, to=o[i], by=1)
            q1=NULL
            q2=NULL
            x1=NULL
               for(j in 1:o[i]){
                  q1=c((v-(4*h[j]+1)))
                  q2=c(((4*h[j])+2))
                  T=c(q1,q2)
                  y=c(0)
                  IB=c(y,cumsum(T)%%v)
                  print("The Initial Block(s) is/are=")
                  appendWorksheet(wb,data.frame("The Initial Block(s) is/are="),sheet = sht,header = FALSE)
                  print(IB)
                  appendWorksheet(wb,as.data.frame(IB),sheet = sht,header = FALSE)
                  row_counter <- row_counter + nrow(as.data.frame(IB))
                       p=seq(from=0, to=v-1, by=1)
                       l=NULL
                         for(i in 1:k){
                         for(j in 1:v){
                         l=c(l,rep((IB[i]+p[j]+v)%% v))
                         }
                        }
                  x= matrix(c(l),nrow=k,ncol=v,byrow = TRUE)
                  x1=cbind(x1,x)
                    }
             print ("Design Matrix is")
             appendWorksheet(wb,data.frame("Design Matrix is"),sheet = sht,header = FALSE)
             print (x1)
             appendWorksheet(wb,as.data.frame(x1),sheet = sht,header = FALSE)
           }
    
    saveWorkbook(wb)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to export data from mysql tables to excel sheet. I am using
I am using the below code to export data to csv format. Normally its
I'm looking to export data to excel from Delphi without having to own a
I have been thinking of a way to export data from SQL to Excel.
Using Excel 2010 and SQL Server 2008 R2. I used import and export data
I have an lightswitch project which I export its data via Odata. In my
I'll be doing a database data export into another database and the column of
Below program exports the data of the single table in excel file.My question is
I ran into a issue about Import/Export on SQL Server. I have a database
I want export data from MSSQL SERVER 2008 from Excel, but i have error

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.