rows

How to get row index number for particular name(s)?

前提是你 提交于 2019-12-21 17:50:08
问题 How can one determine the row index-numbers corresponding to particular row names? I have a vector of row names, and I would like to use these to obtain a vector of the corresponding row indices in a matrix. I tried row() and as.integer(rownames(matrix.object)) , but neither seems to work. 回答1: In addition to which , you can look at match : m <- matrix(1:25, ncol = 5, dimnames = list(letters[1:5], LETTERS[1:5])) vec <- c("e", "a", "c") match(vec, rownames(m)) # [1] 5 1 3 回答2: Try which :

Splitting a large, complex one column file into several columns with awk

前提是你 提交于 2019-12-21 05:27:08
问题 I have a text file produced by some commercial software, looking like below. It consists in brackets delimited sections, each of which counts several million elements but the exact value changes from one case to another. (1 2 3 ... ) (11 22 33 ... ) (111 222 333 ... ) I need to achieve an output like: 1; 11; 111 2; 22; 222 3; 33; 333 ... ... ... I found a complicated way that is: perform sed operations to get 1 2 3 ... # 11 22 33 ... # 111 222 333 ... use awk as follows to split my file in

Alternating row color for JasperReports

落爺英雄遲暮 提交于 2019-12-20 10:11:41
问题 I want to get color to alternate for the rows in a JasperReports subreport. I have all rows with the same background color but I want it to alternate. Can this be done? 回答1: Yes you can set up a style inside the JRXML file like this: <style name="Zebra" mode="Transparent"> <conditionalStyle> <conditionExpression><![CDATA[$V{REPORT_COUNT}%2 == 1]]></conditionExpression> <style backcolor="#CAC5BB"/> </conditionalStyle> </style> and add it to your report elements like this: <reportElement style=

Expand data.frame by creating duplicates based on group condition (3)

断了今生、忘了曾经 提交于 2019-12-20 05:26:27
问题 Starting from this SO question. Example data.frame : df = read.table(text = 'ID Day Count Count_group 18 1933 6 15 33 1933 6 15 37 1933 6 15 18 1933 6 15 16 1933 6 15 11 1933 6 15 111 1932 5 9 34 1932 5 9 60 1932 5 9 88 1932 5 9 18 1932 5 9 33 1931 3 4 13 1931 3 4 56 1931 3 4 23 1930 1 1 6 1800 6 12 37 1800 6 12 98 1800 6 12 52 1800 6 12 18 1800 6 12 76 1800 6 12 55 1799 4 6 6 1799 4 6 52 1799 4 6 133 1799 4 6 112 1798 2 2 677 1798 2 2 778 888 4 8 111 888 4 8 88 888 4 8 10 888 4 8 37 887 2 4

Expand data.frame by creating duplicates based on group condition (3)

自古美人都是妖i 提交于 2019-12-20 05:26:07
问题 Starting from this SO question. Example data.frame : df = read.table(text = 'ID Day Count Count_group 18 1933 6 15 33 1933 6 15 37 1933 6 15 18 1933 6 15 16 1933 6 15 11 1933 6 15 111 1932 5 9 34 1932 5 9 60 1932 5 9 88 1932 5 9 18 1932 5 9 33 1931 3 4 13 1931 3 4 56 1931 3 4 23 1930 1 1 6 1800 6 12 37 1800 6 12 98 1800 6 12 52 1800 6 12 18 1800 6 12 76 1800 6 12 55 1799 4 6 6 1799 4 6 52 1799 4 6 133 1799 4 6 112 1798 2 2 677 1798 2 2 778 888 4 8 111 888 4 8 88 888 4 8 10 888 4 8 37 887 2 4

WPF How to set DataGrid.Group header text when it's actually collapsed

无人久伴 提交于 2019-12-20 04:14:04
问题 I am working with WPF application, and I grouped my items using <DataGrid.GroupStyle> , I am wondering how can I set header text when group is collapsed. I'm loading orders into that grouped grid, and when I collapse specific group I would like to see something like Order : number of order, because of easier orient. Right now I am seeing only number of order, but how could I add text to: <DockPanel> <TextBlock FontWeight="Bold" Text="{Binding Path=Name}" /> //+ some text </DockPanel> (Also,

R separate comma separated cells into rows and Cartesian product

徘徊边缘 提交于 2019-12-20 03:52:04
问题 I have mydf data frame below. I want to split any cell that contains comma separated data and put it into rows. I am looking for a data frame similar to y below. How could i do it efficiently in few steps? Currently i am using cSplit function on one column at a time. I tried cSplit(mydf, c("name","new"), ",", direction = "long") , but that didn`t work library(splitstackshape) mydf=data.frame(name = c("AB,BW","x,y,z"), AB = c('A','B'), new=c("1,2,3","4,5,6,7")) mydf x=cSplit(mydf, c("name"), "

Find row number from a row name in R

橙三吉。 提交于 2019-12-19 09:52:53
问题 How can I find the row number of a particular row name in R? I have found functions which allow you to find a row number for a particular matrix value, but not from a row name. 回答1: You can use which which(rownames(dat) == "theName") 来源: https://stackoverflow.com/questions/31437087/find-row-number-from-a-row-name-in-r

Insert into a row at specific position into SQL server table with PK

青春壹個敷衍的年華 提交于 2019-12-18 16:57:18
问题 I want to insert a row into a SQL server table at a specific position. For example my table has 100 rows and I want to insert a new row at position 9. But the ID column which is PK for the table already has a row with ID 9. How can I insert a row at this position so that all the rows after it shift to next position? 回答1: Relational tables have no 'position'. As an optimization , an index will sort rows by the specified key, if you wish to insert a row at a specific rank in the key order,

SQL count rows in a table

妖精的绣舞 提交于 2019-12-18 14:00:50
问题 I need to send a SQL query to a database that tells me how many rows there are in a table. I could get all the rows in the table with a SELECT and then count them, but I don't like to do it this way. Is there some other way to ask the number of the rows in a table to the SQL server? 回答1: Yes, SELECT COUNT(*) FROM TableName 回答2: select sum([rows]) from sys.partitions where object_id=object_id('tablename') and index_id in (0,1) is very fast but very rarely inaccurate. 回答3: Use This Query :