levels

Need Help turning matching factors to a vector to create a dummy variable

喜你入骨 提交于 2019-12-11 15:19:13
问题 I am working on a project analyzing natural disasters effect on interest rates. I am trying to control for countries that use the euro. I want to match a vector that describes the countries that use the euro and create a column that has a dummy variable for each country: 1 if they use the euro and 0 if not. Country EURO ARG 0 FRA 1 GBR 0 CHN 0 I've tried to set the euro category to a Boolean variable, but I have not had any success. I am relatively new to R so I am not confident I am coding

Mathematica Lists - Search Level Two and Return Level One?

☆樱花仙子☆ 提交于 2019-12-11 07:48:31
问题 I need to string match in the second level of a list but have true cases returned at the first level (there's information in the first level that I need to categorize the returns). First /@ GatherBy[#, #[[3]] &] &@ Cases[#, x_List /; MemberQ[x, s_String /; StringMatchQ[s, ("*PHYSICAL EXAMINATION*"), IgnoreCase -> True]], {2}] &@ Cases[MemoizeTable["Diagnostic_table.txt"], {_, 11111, __}] The GatherBy command at the top is just organizing all the entries by date so I don't get any duplicates.

R: Make unique the duplicated levels in all factor columns in a data frame

蹲街弑〆低调 提交于 2019-12-07 20:28:45
问题 For several days already I've been stuck with a problem in R, trying to make duplicate levels in multiple factor columns in data frame unique using a loop. This is part of a larger project. I have more than 200 SPSS data sets where the number of cases vary between 4,000 and 23,000 and the number of variables vary between 120 and 1,200 (an excerpt of one of the SPSS data sets can be found here). The files contain both numeric and factor variables and many of the factor ones have duplicated

R: Make unique the duplicated levels in all factor columns in a data frame

妖精的绣舞 提交于 2019-12-06 05:44:37
For several days already I've been stuck with a problem in R, trying to make duplicate levels in multiple factor columns in data frame unique using a loop. This is part of a larger project. I have more than 200 SPSS data sets where the number of cases vary between 4,000 and 23,000 and the number of variables vary between 120 and 1,200 (an excerpt of one of the SPSS data sets can be found here ). The files contain both numeric and factor variables and many of the factor ones have duplicated levels. I have used read.spss from the foreign package to import them in data frames, keeping the value

ImageMagick - How do I flatten white levels to pure white?

China☆狼群 提交于 2019-12-04 08:33:55
I have a png image with a white background which I'd like to turn transparent. This is fairly simple with this command: $ convert image.png -transparent white image-trans.png However, if the white background is not completely white (i.e, #FFFFFF , rgb(255,255,255) , etc), then this doesn't work well. Is there a way to set reduce everything below a certain threshold to complete white? Thanks. The commandline option you are looking for is -white-threshold value{%} So a command of convert image.png \ -white-threshold 90% \ -transparent white \ image-trans.png Note: Order of the respective

How do I do this ? - Producing a Dir listing by level - not by following structure

泪湿孤枕 提交于 2019-12-02 16:49:55
问题 I hope that you can save my sanity here. I have been asked to produce a report showing all the files and folders on a windows server. Not you would think a problem - dir /s > report.txt and your done right? Wrong. I have been told that the report must be by level and not following the folder structure. To explain. Imagine we have a server laid out like this - E: ├───Animals │ ├───Birds │ ├───Mammals │ └───Reptiles ├───Cities │ └───Continents │ ├───Africa │ ├───Europe │ └───North America └──

How do I do this ? - Producing a Dir listing by level - not by following structure

左心房为你撑大大i 提交于 2019-12-02 09:49:34
I hope that you can save my sanity here. I have been asked to produce a report showing all the files and folders on a windows server. Not you would think a problem - dir /s > report.txt and your done right? Wrong. I have been told that the report must be by level and not following the folder structure. To explain. Imagine we have a server laid out like this - E: ├───Animals │ ├───Birds │ ├───Mammals │ └───Reptiles ├───Cities │ └───Continents │ ├───Africa │ ├───Europe │ └───North America └───Plants ├───Flowers ├───Grasses └───Trees Dir /s would produce - Directory of E: 23/11/2017 11:57 <DIR> .

How can I keep NA when I change levels

丶灬走出姿态 提交于 2019-12-02 07:13:39
问题 I build a vector of factors containing NA. my_vec <- factor(c(NA,"a","b"),exclude=NULL) levels(my_vec) # [1] "a" "b" NA I change one of those levels. levels(my_vec)[levels(my_vec) == "b"] <- "c" NA disappears. levels(my_vec) # [1] "a" "c" How can I keep it ? EDIT @rawr gave a nice solution that can work most of the time, it works for my previous specific example, but not for the one I'll show below @Hack-R had a pragmatic option using addNA, I could make it work with that but I'd rather a

Levels in R Dataframe

旧街凉风 提交于 2019-12-01 17:42:07
I imported data from a .csv file, and attached the dataset. My problem: one variable is in integer form and has 295 levels. I need to use this variable to create others, but I don't know how to deal with the levels. What are these, and how do I deal with them? When you read in the data with read.table (or read.csv? - you didn't specify), add the argument stringsAsFactors = FALSE. Then you will get character data instead. If you are expecting integers for the column then you must have data that is not interpretable as integers, so convert to numeric after you've read it. txt <- c("x,y,z", "1,2

Levels in R Dataframe

梦想与她 提交于 2019-12-01 15:31:06
问题 I imported data from a .csv file, and attached the dataset. My problem: one variable is in integer form and has 295 levels. I need to use this variable to create others, but I don't know how to deal with the levels. What are these, and how do I deal with them? 回答1: When you read in the data with read.table (or read.csv? - you didn't specify), add the argument stringsAsFactors = FALSE. Then you will get character data instead. If you are expecting integers for the column then you must have