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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T12:40:38+00:00 2026-06-14T12:40:38+00:00

I have two data frames with two different dimensions : 1: head(x) Year GDP_deflator

  • 0

I have two data frames with two different dimensions :

1:

head(x)
   Year GDP_deflator
1  1825           NA
2  1826           NA
3  1827           NA
4  1828           NA
5  1829           NA
6  1829           NA
7  1830           NA
8  1830           NA
9  1830           NA
10 1831           NA

dim(x)
  1733    2

2:

head(dataDef)
   Year GDP_deflator
1  1825     1.788002
2  1826     1.884325
3  1827     2.016997
4  1828     1.802907
5  1829     1.781999
6  1830     1.866437
7  1831     1.960316
8  1832     2.029601
9  1833     1.880957
10 1834     1.845750

dim(dataDef)
 101   2

I would like to substitute values from dataDef$GDP_deflator column into x$GDP_deflator column conditioned on Year column. In other words, I would like the answer to be:

head (x)

   Year GDP_deflator
1  1825           1.788002
2  1826           1.884325
3  1827           2.016997
4  1828           1.802907
5  1829           1.781999
6  1829           1.781999
7  1830           1.866437
8  1830           1.866437
9  1830           1.866437
10 1831           1.960316

So the repeating years (i.e. 1830) get the same value, 1.866437. Any suggestions?

Best Regards

  • 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-14T12:40:39+00:00Added an answer on June 14, 2026 at 12:40 pm

    One possibility is to use match:

    x$GDP_deflator <- dataDef$GDP_deflator[match(x$Year, dataDef$Year)]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two R data frame with differing dimensions. However but data frames have
I have two data frames with two columns each. The first column is timestamps
I am using R and I have two data frames: carrots and cucumbers. Each
I have two small data frames, this_tx and last_tx . They are, in every
I have a list L of data frames with two columns each...a key, and
I have a zoo object that contains velocity data from two different points (V1
I have two data frames that look like something like the following: df1 <-
Here are my two data frames, both have the same amount of rows which
Let's say I have two data frames. Each has a DAY, a MONTH, and
I have two data frames: A and B of the same number of columns

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.