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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T06:38:58+00:00 2026-05-25T06:38:58+00:00

I have created a dataset using WHO ATC/DDD Index a few months before and

  • 0

I have created a dataset using WHO ATC/DDD Index a few months before and I want to make sure if the database online remains unchanged today, so I downloaded it again and try to use the digest package in R to do the comparison.

The two dataset (in txt format) can be downloaded here. (I am aware that you may think the files are unsafe and may have virus, but I don’t know how to generate a dummy dataset to replicate the issue I have now, so I upload the dataset finally)

And I have written a little script as below:

library(digest)

ddd.old <- read.table("ddd.table.old.txt",header=TRUE,stringsAsFactors=FALSE)
ddd.new <- read.table("ddd.table.new.txt",header=TRUE,stringsAsFactors=FALSE)


ddd.old[,"ddd"] <- as.character(ddd.old[,"ddd"])
ddd.new[,"ddd"] <- as.character(ddd.new[,"ddd"])

ddd.old <- data.frame(ddd.old, hash = apply(ddd.old, 1, digest),stringsAsFactors=FALSE)
ddd.new <- data.frame(ddd.new, hash = apply(ddd.new, 1, digest),stringsAsFactors=FALSE)

ddd.old <- ddd.old[order(ddd.old[,"hash"]),]
ddd.new <- ddd.new[order(ddd.new[,"hash"]),]

And something really interesting happens when I do the checking:

> table(ddd.old[,"hash"]%in%ddd.new[,"hash"]) #line01

TRUE 
 506 
> table(ddd.new[,"hash"]%in%ddd.old[,"hash"]) #line02

TRUE 
 506 
> digest(ddd.old[,"hash"])==digest(ddd.new[,"hash"]) #line03
[1] TRUE
> digest(ddd.old)==digest(ddd.new) #line04
[1] FALSE
  • line01 and line02 shows that every rows in ddd.old can be found in ddd.new, and vice versa.
  • line03 shows that the hash column for both dataframe are the same
  • line04 shows that the two dataframe are different

What happen? Both dataframe with the identical rows (from line01 and line02), same order (from line03), but are different? (from line04)

Or do I have any misunderstanding about digest? Thanks.

  • 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-25T06:38:59+00:00Added an answer on May 25, 2026 at 6:38 am

    Read in data as before.

    ddd.old <- read.table("ddd.table.old.txt",header=TRUE,stringsAsFactors=FALSE)
    ddd.new <- read.table("ddd.table.new.txt",header=TRUE,stringsAsFactors=FALSE)
    ddd.old[,"ddd"] <- as.character(ddd.old[,"ddd"])
    ddd.new[,"ddd"] <- as.character(ddd.new[,"ddd"])
    

    Like Marek said, start by checking for differences with all.equal.

    all.equal(ddd.old, ddd.new)
    [1] "Component 6: 4 string mismatches" 
    [2] "Component 8: 24 string mismatches"
    

    So we just need to look at columns 6 and 8.

    different.old <- ddd.old[, c(6, 8)]   
    different.new <- ddd.new[, c(6, 8)]
    

    Hash these columns.

    hash.old <- apply(different.old, 1, digest)
    hash.new <- apply(different.new, 1, digest)
    

    And find the rows where they don’t match.

    different_rows <- which(hash.old != hash.new)  #which is optional
    

    Finally, combine the datasets.

    cbind(different.old[different_rows, ], different.new[different_rows, ])
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We have created a custom dataset and populating it with some data. Before adding
I have created ODBS user DNS for database, opened VS, created DataSet and imported
I have created a crystal report using MySql 5.1, using XML (Dataset save as
I have created a dataset in my visual studio project which is connected to
I have a strongly typed DataTable created with the VS2005/VS2008 DataSet designer. The table
I have created a basic site using ASP.NET routing according to Mike Ormond's example
I have created a file with XmlDocument xmldoc = new XmlDocument(); Can I make
I am having trouble updating my Database from my code using a DataSet. I'm
I have created a data frame from a SQL query using the RODBC package.
I have a dataset that is dynamically created from a csv file. What I

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.