Categories
Mastering Development

ggplot2: symetric heatmap from long format

I am trying to get a symetric heatmap from this kind of data: ID1 <- c(1,1,1,2,2,3) ID2 <- c(2,3,4,3,4,4) value <- rnorm(6)^2 df <- data.frame(ID1=ID1,ID2=ID2, value=value) How can I force ggplot to make a symmetric heatmap with all values 1:4 on both axes and all tiles filled with corresponding colour? (the diameter are 0) I […]

Categories
Mastering Development

Split dataframe with all values in one row

I got the following dataframe which is created dynamically but saves all the relevant values into one row: df +—————-+—————-+—————-+—————-+ | 1 | 2 | 3 | 4 | +—————-+—————-+—————-+—————-+ | a1, b1, c1, d1 | a2, b2, c2, d2 | a3, b3, c3, d3 | a4, b4, c4, d4 | +—————-+—————-+—————-+—————-+ I need to […]

Categories
Mastering Development

Does Snowflake preserve retrieval order?

Posting two questions: 1. Let’s say there is a query: SELECT C1, C2, C3 from TABLE; When this query is fired for the first time,it retrieves all the values in a certain order. Next time, when the same query is fired, will the previous order be retained? There are 2 tables, TABLE1 and TABLE2, both […]

Categories
Mastering Development

minimization Converging to negative infinity despite constraints

I have the following optimization problem: from scipy import optimize import numpy as np def net_profit(x): return -(x[0] / (x[1] + x[2] + x[3]) * 365 * \ (x[4] – (x[5] + x[6])) * x[7] + \ x[8] * 12 – x[9] * 12) c0 = {‘type’: ‘ineq’, ‘fun’: lambda x: x[0]} c1 = {‘type’: […]

Categories
Mastering Development

Overlapping text on top of geom_bar in ggplot2

I have made a barplot similar to the one below using ggplot2. I cannot get the percentages on top of the bars to be centered and not overlapping of other bars and numbers. Sample code is below. library(tidyverse) cat1=c("cat1","cat1","cat1","cat1","cat1","cat1","cat1","cat1","cat1","cat1","cat1","cat1", "cat2","cat2","cat2","cat2","cat2","cat2","cat2","cat2","cat2","cat2","cat2","cat2", "cat3","cat3","cat3","cat3","cat3","cat3","cat3","cat3","cat3","cat3","cat3","cat3", "cat4","cat4","cat4","cat4","cat4","cat4","cat4","cat4","cat4","cat4","cat4","cat4") cat2=c("c1","c2","c3","c4","c5","c6","c7","c8","c9","c10","c11","c12", "c1","c2","c3","c4","c5","c6","c7","c8","c9","c10","c11","c12", "c1","c2","c3","c4","c5","c6","c7","c8","c9","c10","c11","c12", "c1","c2","c3","c4","c5","c6","c7","c8","c9","c10","c11","c12") count1=round(rnorm(48,10)) fakeperc=rnorm(48,9) df1=cbind(count1,fakeperc) df2=cbind(cat1,cat2) finaldf=as.data.frame(cbind(df1,df2)) finaldf$cat1=as.factor(finaldf$cat1) finaldf$fakeperc=as.numeric(finaldf$fakeperc) #finaldf$cat1=factor(finaldf$cat1,levels = […]

Categories
Mastering Development

How to remove or change pixels values under a shape python

I have a very long chain of image processing that gives me a final image as you see below. I am trying to detect and measure the inner circle but need to remove the outer one due to the finicky nature of Hough circles to detect it. When I try to crop it just inverses […]

Categories
User Help

How to sort letter-number-letter value in excel

I have values completely dispersed with a prefix, a number (up to 3 digits) and a suffix. I want a simple sorting scheme that would let me order them in ascending order with suffix taking priority then number and then suffix. If helper cells are used I need to know how to combine the results […]

Categories
Mastering Development

Informix SQL 11.5 Attach the result of one select to another select by columns

i have one select: select c1,c2,c3 from table1 where cond1 –result: a b c d e f g h i and another select is select m2 from table2 where cond2 –result: x y z What combination of the two can I achieve with this output? select m2 from table2 where cond2 **COMBIN** select c1,c2,c3 from […]

Categories
Mastering Development

How to divide an array into a tree of buckets sized by powers of two?

How do you take a number representing a list of items, and divide it into chunks, where the number of chunks is a power-of-two, AND where each chunk also has a power-of-two number of items (where size goes up to a max power of two, so 1, 2, 4, 8, 16, 32, 32 being the […]

Categories
User Help Web Apps

Google Sheets look for string in area

I have in my sheet a list of names in every second line (A2, B2, C2, D2, A4, B4, C4, D4, A6, and so on) and those names can appear in 1 of 4 areas(e.g. H3:I13 or K3:L13) in the same sheet. Now I want to change the background color of the names in the […]