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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T17:11:44+00:00 2026-05-16T17:11:44+00:00

Can I insert a vector as a row in a data.frame ? If so

  • 0

Can I insert a vector as a row in a data.frame? If so how?

  • 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-16T17:11:45+00:00Added an answer on May 16, 2026 at 5:11 pm

    I wouldn’t claim this to be the most elegant and pretty solution out there, but it gets the job done.
    Notice that each dataframe row carries its own row name, which becomes a problem when inserting new lines. That being said, you can mend this with row.names (see below).

    my.df <- data.frame(a = runif(10), b = runif(10), c = runif(10))
    my.vec <- c(1, 1, 1)
    new.df <- rbind(my.df[1:5, ], my.vec, my.df[6:nrow(my.df), ])
    new.df
                a         b          c
    1  0.45433791 0.3798105 0.84514864
    2  0.07074529 0.4985765 0.53912585
    3  0.09645574 0.5441647 0.96636213
    4  0.60788436 0.6070706 0.53791603
    5  0.01593911 0.1697248 0.62697924
    6  1.00000000 1.0000000 1.00000000
    61 0.98455694 0.2206702 0.85500531
    7  0.85356834 0.5279596 0.27462326
    8  0.48028935 0.6689572 0.05428349
    9  0.95675901 0.6875491 0.77642924
    10 0.24691330 0.7980741 0.24013096
    
    row.names(new.df) <- 1:nrow(new.df)  # make row names pretty again
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can i insert a jTable vector data into MSSQL through JDBC in some easy
How can I use emacs string-insert-rectangle operation to add a vector of numbers to
I can insert a row by using code below. USE pmdb; INSERT INTO md5_tbl
Using the code below I can insert a new row to my table (
I need to know how I can insert data inside objects inside an array
I have a vector of type Fruit. I can insert different types of fruits
I can insert annotations on specific datasets on the graph but I wish to
how can insert a record if only a specific value doesn't exist in a
EntityManager.merge() can insert new objects and update existing ones. Why would one want to
Is there a way that I can insert values into a VB.NET Dictionary when

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.