recode

Revalue attributes from multiple columns

自古美人都是妖i 提交于 2019-12-11 12:13:27
问题 I have a dataset like the following. dat1 <- read.table(header=TRUE, text=" ID Pa Gu Ta 8645 Rel345 Gel294 Tel452 6228 Rel345 Gel294 Tel467 5830 Rel345 Gel294 Tel467 1844 Rel345 Gel295 Tel467 4461 Rel345 Gel295 Tel467 2119 Rel345 Gel294 Tel452 1821 Rel345 Gel294 Tel467 6851 Rel345 Gel294 Tel467 4214 Rel345 Gel294 Tel452 2589 Rel346 Gel294 Tel467 2116 Rel347 Gel294 Tel452 8523 Rel348 Gel295 Tel468 2603 Rel348 Gel295 Tel468 2801 Rel348 Gel295 Tel452 1485 Rel348 Gel295 Tel468 2116 Rel348 Gel295

Translating a C++ (dealing with corona) function into C#

烂漫一生 提交于 2019-12-11 04:05:22
问题 i had a C++ .exe i was using as a standalone image cleaner. But i now want to use its fonction into my own c# app, so i started to translate it. But i REALLY TOTALLY know nothing about C++ and its logic. So i come here for some help. First, does anyone know any equivalent for this function? Corona "getPixels()" (yes with an "s" because i know c# have a built-in getPixel) : here is the function explaination from corona doc : getPixels() Corona dll it is used in the lines i am looking to

SPSS: summing up multiple variable scores depending on their score

倖福魔咒の 提交于 2019-12-11 01:47:09
问题 tl;dr: I need to first dichotomize a set of variables to 0/1, then sum up these values. I need to do this for 14x8 variables, so I am looking for a way to to this in a loop. Hi guys, I have a very specific problem I need your help with: Description of problem: In my dataset I have 14 sets of 8 variables each (e.g. a1 to a8, b1 to b8, c1 to c8, etc.) with scores ranging from 1 to 6. Note that the variables are non-contiguous, with string variables in between them (which I need for a different

recoding variables in R with a lookup table

纵饮孤独 提交于 2019-12-10 00:01:07
问题 I have a question about recoding data. I would like to use a lookup table and I am wondering how to recode NA and use an approach similar to %in%. Sample data: gender <- c("Female", "Not Disclosed", "Unknown" , "Male", "Male", "Female", NA) df_gender <- as.data.frame(gender) df_gender$gender <- as.character(gender) My first approach to recode is: df_gender$gender[df_gender$gender == "Female"] <- "F" df_gender$gender[df_gender$gender == "Male"] <- "M" df_gender$gender[df_gender$gender %in% c(

bunch recoding of variables in the tidyverse (functional / meta-programing)

会有一股神秘感。 提交于 2019-12-04 19:24:54
I want to recode a bunch of variables with as few function calls as possible. I have one data.frame where I want to recode a number of variables. I create a named list of all variable names and the recoding arguments I want to execute. Here I have no problem using map and dpylr . However, when it comes to recoding I find it much easier using recode from the car package, instead of dpylr 's own recoding function. A side question is whether there is a nice way of doing the same thing with dplyr::recode . As a next step I break the data.frame down into a nested tibble. Here I want to do specific

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

时间秒杀一切 提交于 2019-12-02 17:01:06
问题 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 percentile, etc. This method needs to be applicable across any data set I plug in and I want this process to be as automated as possible. Below I have generated some test data: data test (drop=i); do i=1 to 1000; a=round(uniform(1)*4,.01); b=round

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

陌路散爱 提交于 2019-12-02 10:08:42
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 percentile, etc. This method needs to be applicable across any data set I plug in and I want this process to be as automated as possible. Below I have generated some test data: data test (drop=i); do i=1 to 1000; a=round(uniform(1)*4,.01); b=round(uniform(1)*10,.01); c=round(uniform(1)*7.5,.01); output; end; stop; run; The following macro is used to

R data.table multi column recode/sub-assign [duplicate]

大兔子大兔子 提交于 2019-12-01 20:02:38
This question already has an answer here: Fastest way to replace NAs in a large data.table 8 answers Let DT be a data.table: DT<-data.table(V1=sample(10), V2=sample(10), ... V9=sample(10),) Is there a better/simpler method to do multicolumn recode/sub-assign like this: DT[V1==1 | V1==7,V1:=NA] DT[V2==1 | V2==7,V2:=NA] DT[V3==1 | V3==7,V3:=NA] DT[V4==1 | V4==7,V4:=NA] DT[V5==1 | V5==7,V5:=NA] DT[V6==1 | V6==7,V6:=NA] DT[V7==1 | V7==7,V7:=NA] DT[V8==1 | V8==7,V8:=NA] DT[V9==1 | V9==7,V9:=NA] Variable names are completely arbitrary and do not necessarily have numbers. Many columns (Vx:Vx) and one

Idiom for ifelse-style recoding for multiple categories

孤街醉人 提交于 2019-11-26 17:33:17
I run across this often enough that I figure there has to be a good idiom for it. Suppose I have a data.frame with a bunch of attributes, including "product." I also have a key which translates products to brand + size. Product codes 1-3 are Tylenol, 4-6 are Advil, 7-9 are Bayer, 10-12 are Generic. What's the fastest (in terms of human time) way to code this up? I tend to use nested ifelse 's if there are 3 or fewer categories, and type out the data table and merge it in if there are more than 3. Any better ideas? Stata has a recode command that is pretty nifty for this sort of thing, although

Idiom for ifelse-style recoding for multiple categories

谁说我不能喝 提交于 2019-11-26 05:29:27
问题 I run across this often enough that I figure there has to be a good idiom for it. Suppose I have a data.frame with a bunch of attributes, including \"product.\" I also have a key which translates products to brand + size. Product codes 1-3 are Tylenol, 4-6 are Advil, 7-9 are Bayer, 10-12 are Generic. What\'s the fastest (in terms of human time) way to code this up? I tend to use nested ifelse \'s if there are 3 or fewer categories, and type out the data table and merge it in if there are more