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

  • Home
  • SEARCH
  • 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 8537059
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T10:48:29+00:00 2026-06-11T10:48:29+00:00

I have faced some strange behavior in the R’s all.equal function. Basically, I create

  • 0

I have faced some strange behavior in the R’s all.equal function. Basically, I create two same data.frames differently and then call the all.equal function (checking data and attributes as well).

The code to reproduce the behavior is as follows:

var.a <- data.frame(cbind(as.integer(c(1,5,9)), as.integer(c(1,5,9))))
colnames(var.a) <- c("C1", "C2")
rownames(var.a) <- c("1","5","9")

var.b <- data.frame(matrix(NA, nrow = 10, ncol = 2))
var.b[, 1] <- 1:10
var.b[, 2] <- 1:10
colnames(var.b) <- c("C1", "C2")
var.b <- var.b[seq(1, nrow(var.b), 4), ]

all.equal(var.a, var.b)

Is this a bug or am I just missing something? I did quite some debugging of the all.equall function and it appears the problem is the the rownames of the data.frames (once them being a character the other time a numeric vector). The response of the all.equall function:

[1] “Attributes: < Component 2: Modes: character, numeric >”
[2] “Attributes: < Component 2: target is character, current is
numeric >”

However,

typeof(rownames(var.a)) == typeof(rownames(var.b))

returns TRUE, which confuses me.

P.S.: The structure of the objects seems the same:

> str(var.a)
'data.frame':   3 obs. of  2 variables:
$ C1: int  1 5 9
$ C2: int  1 5 9
> str(var.b)
'data.frame':   3 obs. of  2 variables:
$ C1: int  1 5 9
$ C2: int  1 5 9

I would appreciate if someone could shed some light on this.

  • 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-11T10:48:30+00:00Added an answer on June 11, 2026 at 10:48 am

    (I’m not exactly clear what bug you are thinking you have found. The data frames were not created the same way.) There are two differences in the structures of var.a and var.b: The mode of the elements in the columns: numeric in ‘var.a’ and integer in ‘var.b’; and the mode of the rownames: integer for ‘var.a’ and character in ‘var.b’:

    > dput(var.b)
    structure(list(C1 = c(1L, 5L, 9L), C2 = c(1L, 5L, 9L)), .Names = c("C1", 
    "C2"), row.names = c(1L, 5L, 9L), class = "data.frame")
    > dput(var.a)
    structure(list(C1 = c(1, 5, 9), C2 = c(1, 5, 9)), .Names = c("C1", 
    "C2"), row.names = c("1", "5", "9"), class = "data.frame")
    
    > mode(attr(var.b, "row.names"))
    [1] "numeric"
    > storage.mode(attr(var.b, "row.names"))
    [1] "integer"
    > mode(attr(var.a, "row.names"))
    [1] "character"
    

    Added note: If you wanted to check for numerical equality you should use the ‘check.attributes’ switch:

    > all.equal(var.a, var.b, check.attributes=FALSE)
    [1] TRUE
    

    If you look at var.b with dput, you can see that the rownames are numeric:

    > dput(var.b)
    structure(list(C1 = c(1L, 5L, 9L), C2 = c(1L, 5L, 9L)), .Names = c("C1", 
    "C2"), row.names = c(1L, 5L, 9L), class = "data.frame")
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Today I faced a strange problem. I have an application which is the same
Today I have faced very strange behavior of sqlite3_finalize statement. I am using sqlite
I have faced the same problem many times. The Same Problem was With This
We've faced strange problem. We have log on service, that authenticates user, adds auth
Today I faced a strange problem in C#. I have an ASP.NET page where
I have a strange problem which I have been trying to fix for some
I have a strange issue: there is a SectionPart with composite, which is create
I'm solving simple math task, and I have faced with some problems. I have
i have faced some problem , when i want to display some static Title
i have faced some problem while navigating from one class to another with the

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.