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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T20:20:54+00:00 2026-06-13T20:20:54+00:00

I have a matrix with numeric column labels, for example: 1,2,3 1,2,3 4,5,6 7,8,9

  • 0

I have a matrix with numeric column labels, for example:

1,2,3
1,2,3
4,5,6
7,8,9

When I load this data into a variable in R using as.matrix(read.table("myfile", sep=",", header=TRUE) and print the resulting matrix, the column headers have been prepended with X, and this extra character appears in plots and the like:

     X1     X2     X3
[1,]  1      2      3
[2,]  4      5      6
[3,]  7      8      9

How can I stop this behaviour?

  • 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-13T20:20:55+00:00Added an answer on June 13, 2026 at 8:20 pm

    Supply check.names=FALSE to read.table.

    Be aware that when data.frames have non-standard names such as this any reference to their columns must be surrounded with tick marks, e.g.

    my.df <- read.table(text='1,2,3
    1,2,3
    4,5,6
    7,8,9', header=TRUE, sep=',', check.names=FALSE)
    
    my.df$`1`
    with(my.df, `1`)
    attach(k)
    `1`
    

    Also, calls to transform, such as transform(my.df,1=1:3), will replace the column names with their standardized forms (X1, X2, X3) because transform calls data.frame() with its default arguments.

    Setting check.names=FALSE, while useful in some very particular situations, will allow duplicate column names and non syntactic names, which could cause any number of problems later on. Be cautious when using this.

    data.frame() uses check.names=TRUE by default because in many contexts R tries to interpret the column names of a data frame as variables in their own right; if the column names are not syntactically valid names (see ?make.names), or protected with back-ticks as described above, then errors will occur in these contexts.

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

Sidebar

Related Questions

I have this: using namespace boost::numeric::ublas; matrix<double> m (3, 2); int k = 0;
I have a matrix A which I want to convert into a data.frame of
I have a matrix of objects that contains data in this form: name A,2,name
hi guys i have this matrix : m<-matrix(data=c(1,2,3,4,5,6*K,7,8,9,10,11,12),nrow=3,ncol=4) but i can't define it because
I have an R matrix with nonnegative numeric values. The matrix is effectively a
I have implemented one matrix multiplication with boost::numeric::ublas::matrix (see my full, working boost code
I have a matrix of data (the columns represent time, and the rows spectrum
I have a data frame with 22239 rows & 200 columns. The first column
I have a matrix that is outputted like this: maximums = [ -9.9043877608991468201413092380493, 426.34796945271797204125533010993]
I have a class which contains a few boost::numeric::ublas::matrix's within it. I would like

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.