Questions tagged [recode]

Recoding refers to the process of modifying the values of dataset, matrix, or vector according to a set of rules by which input values are changed to replacement values.

Recoding refers to the process of modifying the values of dataset, matrix, or vector according to a set of rules by which input values are changed to replacement values.

624 questions
-2
votes
1 answer

Generate variable by country for missing years?

Stata and R: I have two cross-sectional datasets I'm merging. The two datasets have an equal amount of countries and only one dataset has zero missing years (year). The problem is that the missing years are simply not recorded, so I need to make a…
Max
  • 1
-2
votes
2 answers

Change values in a matrix

I have two text files: ped1.txt and ped2.txt. The field separation character is tab/space. ped1.txt 222 333 444 333 458 458 458 774 556 500K lines... ped2.txt 222 -12006 333 -11998 I need to recode the numbers in file 1 using key from file 2, for…
Zoomman
  • 37
  • 5
-2
votes
1 answer

Using variables from different years to create a model

Is there a way to do the following Stata code in R? I want to create a staggered model, and I want to use the values of certain variables for 1994 for people who turned 40 in 1998; and want to use the values of the same variables for 1996 for people…
Aslı Gürer
  • 39
  • 1
  • 9
-2
votes
1 answer

How to fast convert (recode) int64 to character-limited String?

I am looking for a method to recode a String that only consists of digits [0,1,2,...8,9] into another String of a different character set like digits and letters [0,1,...9,a,b,...z] (as an example). The resulting string should typically be shorter…
ares_games
  • 1,019
  • 2
  • 15
  • 32
-2
votes
1 answer

R: Recoding several characters into one new factor

I am new to R, and could not find specific help for my question on this site. I have (among others) ten character variables in my dataframe $grant_database, country_1 through country_10. Each contains either a country code, for example E20, F27 or…
veyesor
  • 3
  • 3
-3
votes
1 answer

Clean up this int64 variable in python

This is the raw distribution of the var FREQUENCY NaN 22131161 1.0 4182626 7.0 218343 3.0 145863 1 59432 0.0 29906 2.0 28129 4.0 15237 5.0 4553 8.0 3617 3 2754 7 2635 9.0 …
opt135
  • 141
  • 1
  • 8
-3
votes
3 answers

How to recode and score multiple variables in R

New to R - I think there should be a simple solution to this, but I'm having trouble getting it right. I have results from a questionnaire in the form of 18 variables (each corresponds with a questionnaire item) that I want to score. Results for…
Sarah
  • 3
  • 1
-3
votes
1 answer

Recoding a data set into another

Please see below a simplified data set, which is on a country-year basis: country <- c("CountryA", "CountryA", "CountryA", "CountryA", "CountryB", "CountryB", "CountryB", "CountryB", "CountryC", "CountryC", "CountryC", "CountryC") year <- c(2001,…
neutral
  • 107
  • 4
  • 13
-3
votes
2 answers

conditionally replace values in next row

How can I write a conditional function that compares entries in rows of a data frame in R. For example if entry in row 1 is greater than entry in row 2 replace row 2 entry with "lower" row1 row2 667 668 673 674 665 679 664 668 Entries in…
Soulkrates
  • 17
  • 1
  • 4
1 2 3
41
42