levels

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

倖福魔咒の 提交于 2020-01-13 02:53:10
问题 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. 回答1: The commandline option you are looking for is -white-threshold value{%} So a command of convert

How to change name of factor levels?

▼魔方 西西 提交于 2020-01-09 11:04:31
问题 training set trainSample <- cbind(data[1:980,1], data[1:980,2]) cl <- factor(c(data[1:980,3])) test set testSample <- data(data[981:1485,1], data[981:1485,2]) cl.test <- clknn prediction k <- knn(trainSample, testSample, cl, k = 5) output < k [1] 2 2 1 1 1 1 2 1 2 1 1 2 2 2 2 2 1 1 2 2 2 2 2 2 2 2 2 2 2 1 2 2 1 1 2 2 1 1 2 2 2 2 1 2 2 2 2 2 2 1 2 2 2 2 2 2 2 2 2 [60] 2 2 2 2 1 2 2 2 2 1 2 2 1 2 2 2 1 1 2 1 2 2 1 1 1 2 1 2 2 2 1 2 2 2 2 2 1 2 1 2 2 2 2 2 2 2 2 1 2 2 2 2 1 2 2 2 2 2 2 [119] 2 2

Is there any way to fit a `glm()` so that all levels are included (i.e. no reference level)?

大兔子大兔子 提交于 2019-12-30 05:30:09
问题 Consider the code: x <- read.table("http://data.princeton.edu/wws509/datasets/cuse.dat", header=TRUE)[,1:2] fit <- glm(education ~ age, family="binomial", data=x) summary(fit) Where age has 4 levels: "<25" "25-29" "30-39" "40-49" The results are: So by default, one of the levels is used as a reference level. Is there a way to have glm output coefficients for all 4 levels + the intercept (i.e. have no reference level)? Software packages like SAS do this by default, so I was wondering if there

Gesture recogniser crashing upon next level

你离开我真会死。 提交于 2019-12-25 06:49:37
问题 I am trying to implement a gesture recogniser and everything is working well until it comes to loading the next level, then at the next level stage, where can tap to go to the next level, if I use a gesture, the program crashes. To be clear, when a level is complete a title appears saying "Next Level - touch to go to next level". Until I added the gesture recogniser a tap would result in incrementing the level and presenting the same scene using [super initWithSize:size] with new variables

How to convert the values in a dataframe to a dummy values by levels() function?

只愿长相守 提交于 2019-12-24 00:43:26
问题 The given data is SNP1 <- c("AA","GG","AG") SNP2 <- c("AA","CC","AC") SNP3 <- c("GG","AA","AG") df<- data.frame(SNP1, SNP2, SNP3) colnames(df)<- c('rs10000438', 'rs10000500','rs1000055') I define a data function which is dominant_dummy . When I run the codes I found it goes wrong. Error in if (!check) { : argument is of length zero When I debug I found that the argument x in this is a dataframe , and I need to use the function levels(x) to check the level of x, and also assign levels(x)<- c(0

Removing Specific factor level from factor variable

℡╲_俬逩灬. 提交于 2019-12-21 04:49:35
问题 I have a data frame that has several variables that have 5 factor levels. I want to delete only one of those levels. First I assigned all instances of of that level to NA, and then used the droplevels command to get rid the empty levels. However for one variable in my data frame one of the levels I don't want dropped has no observations in it. Is there a way to remove only a specific factor level, and not just the empty ones. Here is a reproducible example df <- data.frame(var1=rep(letters[1

Recode/relevel data.frame factors with different levels

余生颓废 提交于 2019-12-18 10:56:38
问题 Each time when I have to recode some set of variables, I have SPSS recode function in mind. I must admit that it's quite straightforward. There's a similar recode function in car package, and it does the trick, but let's presuppose that I want to get things done with factor . I have data.frame with several variables with value range from 1 to 7. I want to "reverse" variable values, hence replacing 1s with 7s, 2s with 6s, 3s with 5s etc. I can utilize factor function: # create dummy factor set

Counting depth or the deepest level a nested list goes to

拟墨画扇 提交于 2019-12-17 10:46:13
问题 A have a real problem (and a headache) with an assignment... I'm in an introductory programming class, and I have to write a function that, given a list, will return the "maximum" depth it goes to... For example: [1,2,3] will return 1, [1,[2,3]] will return 2... I've written this piece of code (it's the best I could get T_T) def flat(l): count=0 for item in l: if isinstance(item,list): count+= flat(item) return count+1 However, It obviously doens't work like it should, because if there are

count number of times a factor appears during rolling window

为君一笑 提交于 2019-12-14 03:58:32
问题 I want to generate the column: "PriorityCountInLast7Days". For a given employee A, this column counts the number of CASES in the last 7 days where PRIORITY is the same as the current case. How would I do that in R with the first 4 columns? data <- data.frame( Date = c("2018-06-01", "2018-06-03", "2018-06-03", "2018-06-03", "2018-06-04", "2018-06-01", "2018-06-02", "2018-06-03"), Emp1 = c("A","A","A","A","A","A","B","B","B"), Case = c("A1", "A2", "A3", "A4", "A5", "A6", "B1", "B2", "B3"),

R - factor level orders (and ggplot group axis order)

大憨熊 提交于 2019-12-12 04:05:20
问题 I am trying to control the order of discrete groups on an axis in ggplot, so I am setting the order of my factor variable. Using the levels() function actually seems to change the data in the data frame - not the way R treats the underlying ordering of the data (see below). Am I doing something wrong? which function should I use instead of levels()? thanks! head(pctCStack,4) BRK Time x 1 ICs December 2013 0.6717300 2 Managers December 2013 0.8024344 3 ICs July 2014 2.0417851 4 Managers July