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
0
votes
0 answers

what does it mean by recode(x,y) in R

I am reading other's code but not get the recode part function (x){recode(x,5})-1 All the previous recode codes included = sign to give something some value, I don't understand what here the "5" mean. thank you!
Seashore
  • 3
  • 1
0
votes
3 answers

How to recode variables in table 1 using info from table 2 (in SAS)

The overal goal is to stratify quantitative variables based on their percentile. I would like to break it up into 10 levels (e.g. 10th, 20th, ...100th percentile) and recode it as 1 if it falls into the 10th percentile, 2 if it falls into the 20th…
NicChik
  • 73
  • 1
  • 9
0
votes
1 answer

How to compute a new variable based on the number of days since a particular type of record

I'm trying to create a variable that shows the number of days since a particular event occurred. This is a follow up to this previous question, using the same data. The data looks like this (note dates are in DD-MM-YYYY format): ID date drug …
mob
  • 293
  • 1
  • 9
0
votes
3 answers

How to recode integers to other values in python?

I was surprised this question has not been asked yet. Given an array of integers x = np.random.randint(1,4,10) > array([3, 2, 1, 2, 1, 1, 3, 3, 2, 1]) How can I (easily) change all values according to some systematic rule, such as x[x==1] =…
tomka
  • 2,516
  • 7
  • 31
  • 45
0
votes
0 answers

What is PCAmixdata's recodqual() doing, and what is its failure condition?

I'm trying to debug a call to kmeansvar in some data I'm working on, but before I can even try to reproduce the issue, I have to figure out what this error message from recodqual() is saying: Error in recodqual(X.quali) : There are columns in…
bright-star
  • 6,016
  • 6
  • 42
  • 81
0
votes
1 answer

Recode syntax in R SQL

I am trying to recode variable in R SQL. Below is syntax for the same. Data[,1] <- recode(Data[,1]," 'Yes' = 1; 'No' = 0 " ) But when we use single quote in R SQL (') it terminate the R SQL command, in R SQL we had to write R script within two…
user3734568
  • 1,311
  • 2
  • 22
  • 36
0
votes
2 answers

Recode values to a new variable using R

I have a dataset with a variable that i need to change anonymise by recoding into a different variable. There are 20,000 entries, some are duplicated so my data looks something like this: DCD97568 DCD23547 DCD27656 DCD27656 DCD87590 The end product…
Nottles82
  • 103
  • 7
0
votes
1 answer

recoding race with 4 categories to 3 categories and creating 2 dummies in R

I am working with a variable for race that takes on the following values:1 Black, 2 Hispanic, 3 Mixed Race (Non-Hispanic), 4 Non-Black / Non-Hispanic. I want to sum up 3 and 4 and make it the base category and keep Black and Hispanic. I tried to…
bree
  • 25
  • 1
  • 7
0
votes
1 answer

Error in dataframe in R when trying to recode a variable

I am workign with NLS data and try to recode the gender variable, where I called it female from the beginning and now I try to recode the following 1 Male 2 Female 0 No Information My code: nlsy$female[ nlsy$female == 1 ] <- 0 nlsy$female[…
bree
  • 25
  • 1
  • 7
0
votes
1 answer

Dplyr transmute reports error: unexpected ',' - but commas are part of the command?

This dplyr-command usually works just perfect for me, when I want to recode variables. But for some reason it all of the sudden hates the commas, but won't run without them... I have (re)installed both haven and dplyr several times. Any ideas? The…
Line Bach
  • 11
  • 1
0
votes
0 answers

Object not found error while piping in R

I am trying to recode the values of mixed alpha-number character variable with a data set I am running through pipes in R. I have loaded the following packages: tidyverse tidyr dplyr lubridate forcats My original dataset consisted of 4 obs. of 325…
Zet
  • 9
  • 2
0
votes
0 answers

How to re-code text that includes specific text

I am trying to re-code a large set of text data into either a text or numeric value. My data set includes names of coffee shops. I would like to re-code these coffee shops into either "corporation" or "small business". The problem is there are…
Tawk_Tomahawk
  • 139
  • 2
  • 8
0
votes
2 answers

cleanly generate and replace values based on a condition

I'm trying to do something very simple in R but I can't get it right. Let's take the "diamonds" dataset from ggplot 2 glimpse(diamonds) $ carat 0.23, 0.21, 0.23, 0.29, 0.31, 0.24, 0.24, 0.26, 0.22, 0.23, 0.30, 0.23, 0.22, 0.31, 0.20, 0.32,…
0
votes
1 answer

Recode multiple columns based on grep column label outcome in R

I have multiple columns which I'd like to recode (Yes - 1, No - 0, Null - NA) in R. These columns all contain the word 'Flag' as part of the column labels and I have about 60 of these columns to recode. I've also got column names ending with other…
byc
  • 121
  • 10
0
votes
2 answers

Convert Age variable into ordinal variable

I'm new to R here. How can I convert numeric variables into ordinal variables? For example, let's say I want to recode age into four categories (<65, 66-75, 75-85,…
user4687733