Categories

## How to force multiple r plots to have the same length of x-ticks? [duplicate]

Several packages in R are able to arrange mulitple plots into a grid, such as gridExtra and cowplot. The plots in the same row/column is by default aligned on their boundary. The following is an example. Three histograms are vertically arranged on the same plot. You can notice that the x-ticks are not algned and […]

Categories

## Editing a file based on a pattern appearance

I have a file that contains text and numbers like this: state(1, s(1,a), [s(1,b)]). state(1, s(1,b), [s(1,a)]). state(1, s(2,a), [s(2,b)]). state(1, s(2,b), [s(2,a)]). state(1, s(3,a), [s(3,b)]). state(1, s(3,b), [s(3,a)]). state(1, s(4,a), [t(1), t(2)]). state(1, s(5,a), [t(1), t(3)]). state(1, s(6,a), [s(6,b)]). state(1, s(6,b), [s(6,a)]). …so on I want the numbering with in s(x,y) to change as […]

Categories

## How to add labels to multiple ggplot graphs (A, B, C)

I am trying to add the labels A, B, and C to the top left hand corner of each of these graphs. I have tried cowplot::draw_plot_label(), but nothing seems to work. Can anyone help? These A, B and C labels are not the main title of each plot. # Packages library(ggplot2) library(gridExtra) library(cowplot) # 1st […]

Categories

## How to calculate the angles between each two successive lines in polygon

I tried to calculate the angles between each two successive lines in the polygon using the law of Cosines: $cos(C) = \frac{a^2+b^2-c^2}{2ab}$, but I’m getting the Error: ValueError: math domain error, because the value of the cos obtained from that rule was out of range [-1, +1]. can you please advise me how […]

Categories

## ROS – SerializationError when writing a bagfile with custom ROS message

I have a created a custom ros message which has the following format # Header information std_msgs/Header header # Model string model # Data uint8[] data The data is a list of 4D lists reading from csv file def createData(csv_file): x,y,z,w = np.loadtxt(dataFile, usecols=(0,1,2,3), \ skiprows=0, delimiter="\t", unpack=True) p = [] for p1, p2, p3, […]

Categories

## Prepared statement with parameters repeated multiple times throughout the query

I have a complex query issued via JDBC consisting of 2 string parameters and multiple SELECT statements, some of which nested. The same DB TABLE is queried multiple times and each query parameter is reused twice throughout the body. Looking at the JDBC driver logs I see that the 2 parameters (each of which appears […]

Categories

## Prepared statement with parameters repeated multiple times throughout the query

I have a complex query issued via JDBC consisting of 2 string parameters and multiple SELECT statements, some of which nested. The same DB TABLE is queried multiple times and each query parameter is reused twice throughout the body. Looking at the JDBC driver logs I see that the 2 parameters (each of which appears […]

Categories

## create nested JSON from Pandas DataFrame with grouped rows as attributes inside deepest nest

I’m looking for a solution to build a nested dict / JSON with the last three columns "name", "color", "amount" as attributes inside a "products" list. The values from the cat1-cat3 columns should be the keys. The provided DataFrame looks like this: import pandas as pd df = pd.DataFrame({ ‘cat1’: [‘A’, ‘A’, ‘A’, ‘B’, ‘B’, […]

Categories

## Can Excel autofill one range but copy another in the same autofill operation?

I have a table in Excel which I need to copy 80 times, and have each one be numbered sequentially. (Table 1, Table 2, Table 3 … Table 80) However, one of the columns in this table contains the text (P1, P2, P3, P4, P5, P6). When I drag the autofill thing down to copy […]

Categories

## Maintain order of processing data same order in which data received using multi-treading design

In one of the interview below question asked to me Suppose there is a stream of emails that we are fetching from a mail server. We need to do some processing on these emails and print the output in the same order in which we received the emails. If we fetch emails in the order […]