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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T02:09:25+00:00 2026-05-21T02:09:25+00:00

I´m trying to get a lot of regression coefficients into a dataframe for latex´ing

  • 0

I´m trying to get a lot of regression coefficients into a dataframe for latex´ing afterwards. However, I´m running into the following problem that I cannot understand after pasting together some values into confidence intervals:

> str(q2)
'data.frame':   5 obs. of  7 variables:
 $ name     : Factor w/ 5 levels "1","2",..: 1 2 3 4 5
 $ Intercept: Factor w/ 5 levels "15.4533848220452",..: 1 2 3 4 5
 $ Int.lb   : Factor w/ 5 levels "14.2125590292247",..: 1 2 3 4 5
 $ Int.ub   : Factor w/ 5 levels "17.1483176230248",..: 1 2 3 4 5
 $ BAC      : Factor w/ 5 levels "-0.317030740768092",..: 1 2 3 4 5
 $ Bac.lb   : Factor w/ 5 levels "-0.789518593140102",..: 1 2 3 4 5
 $ Bac.ub   : Factor w/ 5 levels "0.0844578956839408",..: 1 2 3 4 5
> str(q3)
'data.frame':   5 obs. of  2 variables:
 $ CI: Factor w/ 5 levels "(12.17,14.34)",..: 2 1 5 4 3
 $ ci: Factor w/ 5 levels "(-0.31,0.74)",..: 3 5 2 4 1
> q4<-as.data.frame(cbind(name=q2$name,Intercept=q2$Intercept,Interecpt.95.CI=q3$CI,BAC=q2$BAC,BAC.95.CI=q3$ci))
> q4
  name Intercept Interecpt.95.CI BAC BAC.95.CI
1       1         1               2   1         3
2       2         2               1   2         5
3       3         3               5   3         2
4       4         4               4   4         4
5       5         5               3   5         1

> str(q4)
'data.frame':   5 obs. of  5 variables:
 $ name        : int  1 2 3 4 5
 $ Intercept      : int  1 2 3 4 5
 $ Interecpt.95.CI: int  2 1 5 4 3
 $ BAC            : int  1 2 3 4 5
 $ BAC.95.CI      : int  3 5 2 4 1

I.e. Why did the q4 variables all of a sudden change?

  • 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-21T02:09:25+00:00Added an answer on May 21, 2026 at 2:09 am

    The short answer is the factors got converted to their internal numeric codes. It happened during the cbind() call:

    R> set.seed(1)
    R> dat <- data.frame(A = factor(sample(1:5, 10, rep = TRUE)), 
    +                    B = factor(sample(100:200, 10, rep = TRUE)))
    R> head(dat)
      A   B
    1 2 120
    2 2 117
    3 3 169
    4 5 138
    5 2 177
    6 5 150
    R> str(dat)
    'data.frame':   10 obs. of  2 variables:
     $ A: Factor w/ 5 levels "1","2","3","4",..: 2 2 3 5 2 5 5 4 4 1
     $ B: Factor w/ 9 levels "117","120","138",..: 2 1 5 3 7 4 6 9 3 8
    R> cbind(name = dat$A, foo = dat$B)
          name foo
     [1,]    2   2
     [2,]    2   1
     [3,]    3   5
     [4,]    5   3
     [5,]    2   7
     [6,]    5   4
     [7,]    5   6
     [8,]    4   9
     [9,]    4   3
    [10,]    1   8
    

    The reason is that cbind() produces a matrix and that is where the conversion happens. It would be easier to create a new data frame in this instance:

    R> dat2 <- data.frame(name = dat$A, foo = dat$B)
    R> dat2
       name foo
    1     2 120
    2     2 117
    3     3 169
    4     5 138
    5     2 177
    6     5 150
    7     5 172
    8     4 200
    9     4 138
    10    1 178
    

    rather than a cbind() followed by an as.data.frame() pair of calls.

    But the real source of the problem is the numeric data stored as a factor in q2. How were these data read in or generated in R? If the were read in to R, why do the end up as a factor? Usually is the data are all numeric in a column R will read in the values as numerics. If there is anything text-like in the data column though, it will get converted to a factor. So I’d try to solve that issue – why were the data in q2 factors – as it might indicate some issues with reading or generating the data that you are not aware of.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to get into the Clojure community. I've been working a lot with
I'm struggling a lot trying to get our build server going. I am currently
Hello everyone I been trying get php uploader working but having a lot of
I'm trying to get a better understanding of the difference. I've found a lot
I'm trying to get a line as input from the command line. My problem
I've been having a lot of problems with emacs and trying to get the
I am trying to build a program that uses libusb and I get a
I'm currently trying to get the type that an object was casted as in
I am currently trying to get the following statement to work: SELECT t1.id, t1.row2
I'm having a lot of trouble trying to get my app on iTunes connect

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.