levels

Imageview issue with zoom in and out,drag with maximum and minimum levels

纵饮孤独 提交于 2019-11-30 16:56:40
I had implemented an image view with the zoom and drag functionalities.I am using matrix for the zoom and drag functionality.But my problem is that I cant set my minimum and maximum zoom level and the drag space limit.can any on e tell me how I can do that. private float spacing(MotionEvent event) { float x = event.getX(0) - event.getX(1); float y = event.getY(0) - event.getY(1); return FloatMath.sqrt(x * x + y * y); } private void midPoint(PointF point, MotionEvent event) { float x = event.getX(0) + event.getX(1); float y = event.getY(0) + event.getY(1); point.set(x / 2, y / 2); } private

Remove first levels of identifier in array

两盒软妹~` 提交于 2019-11-30 07:04:22
问题 I think this has been up before, but could'nt find any answer to it. If it's already answered please point me in the right direction with a link. I have an array that I wan't to remove the first levels of identifier. I think there is a function for this? Example of how it is: [0] => Array ( [8] => Röd ) [1] => Array ( [8] => Blå ) [2] => Array ( [6] => Bobo ) [3] => Array ( [8] => Grön ) [4] => Array ( [7] => Sten ) [5] => Array ( [8] => Vit ) [6] => Array ( [7] => Guld ) [7] => Array ( [6] =

Recode/relevel data.frame factors with different levels

ε祈祈猫儿з 提交于 2019-11-30 00:48:48
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.seed(100) x <- as.factor(round(runif(100,1,7))) y <- factor(x, levels = rev(levels(x))) And if I run:

Imageview issue with zoom in and out,drag with maximum and minimum levels

家住魔仙堡 提交于 2019-11-29 23:54:34
问题 I had implemented an image view with the zoom and drag functionalities.I am using matrix for the zoom and drag functionality.But my problem is that I cant set my minimum and maximum zoom level and the drag space limit.can any on e tell me how I can do that. private float spacing(MotionEvent event) { float x = event.getX(0) - event.getX(1); float y = event.getY(0) - event.getY(1); return FloatMath.sqrt(x * x + y * y); } private void midPoint(PointF point, MotionEvent event) { float x = event

Remove first levels of identifier in array

杀马特。学长 韩版系。学妹 提交于 2019-11-28 23:52:54
I think this has been up before, but could'nt find any answer to it. If it's already answered please point me in the right direction with a link. I have an array that I wan't to remove the first levels of identifier. I think there is a function for this? Example of how it is: [0] => Array ( [8] => Röd ) [1] => Array ( [8] => Blå ) [2] => Array ( [6] => Bobo ) [3] => Array ( [8] => Grön ) [4] => Array ( [7] => Sten ) [5] => Array ( [8] => Vit ) [6] => Array ( [7] => Guld ) [7] => Array ( [6] => Lyxig ) What I wan't [8] => Röd [8] => Blå [6] => Bobo [8] => Grön [7] => Sten [8] => Vit [7] => Guld

R- split histogram according to factor level

柔情痞子 提交于 2019-11-28 22:54:12
问题 This is my data: type<-rep(c(0,1),100) diff<-rnorm(100) data<-data.frame(type,diff) If I want to plot historgram of diff , I do this: hist(data$diff) But what I want to do to split my histogram according to type . I could do this: par(mfrow=c(1,2)) hist(data$diff[data$type==0]) hist(data$diff[data$type==1]) But what this is giving me are two different histograms side by side. What I want to do is produce a single histogram with diff of 0 at one side and diff of 1 at other side. Something like

How to change name of factor levels?

*爱你&永不变心* 提交于 2019-11-28 12:02:26
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 2 1 2 2 2 2 2 2 2 1 2 2 2 2 2 2 2 2 2 1 2 2 2 2 1 2 1 1 1 1 2 2 2 2 2 2 2 2 1 2 1 2 2 2 2 2 2 1 2 2 1

Counting depth or the deepest level a nested list goes to

断了今生、忘了曾经 提交于 2019-11-27 12:45:34
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 lists that do not count for the maximum deepness, it still raises the counter... For example: when I use

Why is the terminology of labels and levels in factors so weird?

老子叫甜甜 提交于 2019-11-27 11:28:22
An example of a non-settable function would be labels . You can only set factor labels when they are created with the factor function. There is no labels<- function. Not that 'labels' and 'levels' in factors make any sense.... > fac <- factor(1:3, labels=c("one", "two", "three")) > fac [1] one two three Levels: one two three > labels(fac) [1] "1" "2" "3" OK, I asked for labels, which one might assume were as set by the factor call, but I get something quite ... what's the word, unintuitive? > levels(fac) [1] "one" "two" "three" So it appears that setting labels is really setting levels. > fac

How can I drop unused levels from a data frame?

爱⌒轻易说出口 提交于 2019-11-27 06:48:35
Given the following mock data: set.seed(123) x <- data.frame(let = sample(letters[1:5], 100, replace = T), num = sample(1:10, 100, replace = T)) y <- subset(x, let != 'a') Creating a table of y$let yields a b c d e 0 20 21 22 18 But I don't want a to show anymore. If I try to do this: levels(y$let) <- factor(y$let) I mess the frequencies, since now table(y$let) gives me b d c e 0 20 21 40 I'm aware I could do xtabs(~ y$let, drop.unused.levels = T) and work around the problem, but it doesn't reset the variable levels at its core (which is important to me, since this is an early change I'm