max

script to get the max from column based on other column values

那年仲夏 提交于 2020-03-06 10:53:05
问题 I need a script to read in a csv file(orig.csv) and output a reformatted csv file(format.csv) The orig csv file will look like this: Time,Label,frame,slot,SSN,Board,BT,SRN,LabelFrame,SRNAME,LabelID,Integrity,MAX_val 2014-03-17,lableA,1,8,0,,SPUB,1,NNN,NNN,1,100%,60 2014-03-17,lableA,2,22,0,,GOUC,2,NNN02,NNN02,1,100%, 2014-03-17,lableB,2,8,0,,CCCB,2,NNN02,NNN02,1,100%,59 2014-03-17,lableB,1,2,4,,CCCB,1,NNN,NNN,1,100%,48 2014-03-17,lableB,1,0,6,,CCCB,1,NNN,NNN,1,100%,59 2014-03-17,lableC,2,6,0,

min for each row with dataframe in R

心不动则不痛 提交于 2020-02-14 02:42:05
问题 I'm try to do a simple minimum across multiple columns in a data frame but the min function automatically returns the min across the whole of each column rather than for each row separately. I'm sure I'm missing something really simple here? Any ideas much appreciated. x<-c(1,2,7) y<-c(1,5,4) minIwant <- c(1,2,4) df <- data.frame(x,y,minIwant) df$minIget <- min(df$x,df$y) df x y minIwant minIget 1 1 1 1 1 2 2 5 2 1 3 7 4 4 1 回答1: You can use apply to go through each row apply(df, 1, FUN=min)

Select row with max value in one column

流过昼夜 提交于 2020-02-08 01:35:29
问题 I have a select statement that returns two columns: office names and total per office: select o.OfficeName, c.Total from Offices o left join ( select OfficeID, count(*) Total from Customers c group by OfficeID ) c on o.OfficeID = c.OfficeID where o.ClusterID = 29 How can I get the row that has max total? "Customers" table has an "OfficeID" colummn. For a given "ClusterID", I select all offices within the cluster identified by cluster id (e.g. 29) and count the customers belongin to those

Select min or max values within one cell (delimited string)

岁酱吖の 提交于 2020-02-04 03:37:04
问题 I have a data frame where for each sample the columns can have multiple values, for example: Gene Pvalue1 Pvalue2 Pvalue3 Beta Ace 0.0381, ., 0.00357 0.01755, 0.001385 0.0037, NA , 0.039 -0.03,1,15 NOS NA 0.02 0.001, 0.00067 0.00009,25,30 I want to apply min() and max() for each gene's data (I have thousands of genes in total) in each column and get the smallest value for the pvalues but the largest value for columns such as the beta. So the output data would look like this: Gene Pvalue1

Select min or max values within one cell (delimited string)

心不动则不痛 提交于 2020-02-04 03:36:27
问题 I have a data frame where for each sample the columns can have multiple values, for example: Gene Pvalue1 Pvalue2 Pvalue3 Beta Ace 0.0381, ., 0.00357 0.01755, 0.001385 0.0037, NA , 0.039 -0.03,1,15 NOS NA 0.02 0.001, 0.00067 0.00009,25,30 I want to apply min() and max() for each gene's data (I have thousands of genes in total) in each column and get the smallest value for the pvalues but the largest value for columns such as the beta. So the output data would look like this: Gene Pvalue1

Measure maximum PHP memory usage

╄→尐↘猪︶ㄣ 提交于 2020-02-01 06:20:05
问题 Setting php_value memory_limit always involves a bit of guesswork and I myself tend to use higher than necessary values just to make sure that the odd memory hungry call does not result in a fatal error. Still, I am looking for a shell script that would behave kind of like htop or top but instead of showing the current values it would remember only the maximum memory consumed by a PHP script and retain it. Such value, over a few days, would be a very valuable indicator of what php_value

Error when attempting to use max_element to figure out the highest number in an array

帅比萌擦擦* 提交于 2020-01-30 13:17:48
问题 int a = max_element(highesthuman[0], highesthuman[2]); if( win > loss) { cout << "You won " << (win-loss) << " games more than the computer did! You used " << a << " the most."; } } The above array is given by int humanrock = 0; int humanpaper = 0; int humanscissors = 0; int highesthuman [3] = {humanrock, humanpaper, humanscissors}; When running my whole program I get an error saying "invalid type argument of unary". I looked this up but was not able to understand "pointers" or what people

Find value corresponding to maximum in other column [duplicate]

时光毁灭记忆、已成空白 提交于 2020-01-30 10:32:25
问题 This question already has answers here : Finding row index containing maximum value using R (3 answers) Closed 2 years ago . I have a data frame similar to as follows: x <- c(1, 2, 3, 4, 5) y <- c(1, 2, 3, 2, 1) df <- data.frame(x, y) I want to find the value of x when y is at its maximum. I know that I can find the max of y with this: max(df$y) But I don't know how to match it, and I think there's probably a better way. 回答1: Using dplyr : # install.packages(dplyr) library(dplyr) df %>%

How to get the 3 items with the highest value from dictionary? [duplicate]

强颜欢笑 提交于 2020-01-30 09:24:05
问题 This question already has answers here : How do I sort a dictionary by value? (34 answers) Closed 3 years ago . Suppose i have this dictionary: {"A":3,"B":4,"H":1,"K":8,"T":0} I want to get the keys of the highest 3 values (so in this case I will get the keys: K B and A) 回答1: You may use simple list comprehension expression as: >>> sorted(my_dict, key=my_dict.get, reverse=True)[:3] ['K', 'B', 'A'] OR, you may use collections.Counter() if you need value as well: >>> from collections import

Using Java 8 stream methods to get a max value

爱⌒轻易说出口 提交于 2020-01-30 07:45:49
问题 I would like to get the max value out of a list using java 8 stream methods. The structure is the following: I read a csv file and store the data of every line in a separate object of type Round . all these Round objects are stored in an ArrayList called arrRound all Round objects have a field: List<Hit> hits a Hit consists of 2 fields: int numberOfGames and int prizeAmount public class Round{ private List<Hits> hits; } public class Hits{ private int numberOfGames; private int prizeAmount; }