transpose

Transpose lists elements and match to value in R

妖精的绣舞 提交于 2019-12-24 11:03:45
问题 Here is the code written by @Ken S to extract data from OCR'd pdf, which gives a dataframe like name Status Page Words test.pdf Present test_1, test_3 gym, school test1.pdf Present test1_4, test1_7 gym, swimming pool test2.pdf Not Present - - . But I want the data to be flattened so that the output would look like fileName Status Page Words TEXT test.pdf Present test_1 gym I go gym and school regularly test.pdf Present test_1 school I go gym and school regularly test.pdf Present test_3 school

Excel Converting rows to columns with groups

冷暖自知 提交于 2019-12-24 10:18:35
问题 Let's say that I have my columns in excel set up like this: Name A B C D George 10 5 4 6 And I want it to instead be like this: Name Category Amount George A 10 George B 5 George C 4 George D 6 Is there an easy way to do a copy and paste with transpose, or with a pivot table, or does it have to be done with VBA? I've been trying to only do it with VBA but I havent gotten very far. 回答1: As per comment, you can follow that link. A related SO answer that describes similar steps for Excel 2010 is

Transposing Values in Java 2D ArrayList

泄露秘密 提交于 2019-12-24 09:41:50
问题 Good evening all, I'm trying to write a method that creates and returns a 2D array whose elements in each location are the same as the elements in the mirror image location of the parameter array. Unfortunately, no matter what pair of numbers I enter into the method call I get an "out of bounds" error in my compiler. Below is my program. Tell me where I've gone wrong! Thanks! public static int[][] transpose(int [][] a) { int r = a.length; int c = a[r].length; int [][] t = new int[c][r]; for

Transpose Diagonal to row in Google Spreadsheet?

痞子三分冷 提交于 2019-12-24 09:39:17
问题 I've tried to find a formula that would return the diagonal of an array A1:D4 as follows: A1 B2 C3 D4 I found this one, which returns a column, but I can't find out how to order the values in a row instead. =INDEX(A1:D1,,ROWS($1:1)) (paste in the columns below) A TRANSPOSE on the result would of course do the trick, but I'd appreciate something slightly more elegant. Thanks! 回答1: If you use the exact range you mentioned (A1:D4) then this should work =ARRAYFORMULA(TRIM(QUERY(IF(ROW(A1:D4)

Transposing rows into columns, then split them

心不动则不痛 提交于 2019-12-24 07:59:44
问题 I have a data set containing data sorted in rows like this: *VarName1* - *VarValue1* *VarName2* - *VarValue2* *Etc.* I want it to be that the VarNames become individual columns. I have achieved this by using the following code: DFP1 <- as.data.frame(t(DFP)) #DFP contains the data Now, this is a very big data set. It contains multiple years (millions of rows) of data. Above code creates a dataframe which has > 1E6 columns. I need to split these columns by each entry. I saw that in the first

Melting two sets of two columns into two rows (one row for each column in the set) [duplicate]

孤街浪徒 提交于 2019-12-24 06:11:06
问题 This question already has answers here : Reshaping multiple sets of measurement columns (wide format) into single columns (long format) (7 answers) Closed 5 days ago . I have a data.table as follows: DT <- fread( "ID country year Event_A Event_B Event_A_succ Event_B_succ 4 NLD 2002 0 1 0 0 5 NLD 2002 0 1 0 1 6 NLD 2006 1 1 1 1 7 NLD 2006 1 0 1 0 8 NLD 2006 1 1 0 0 9 GBR 2002 0 1 0 0 10 GBR 2002 0 0 0 0 11 GBR 2002 0 1 0 1 12 GBR 2006 1 1 1 1 13 GBR 2006 1 1 0 1", header = TRUE) I want to cast

pig - transform data from rows to columns while inserting placeholders for non-existent fields in specific rows

醉酒当歌 提交于 2019-12-24 03:53:17
问题 Suppose I have the following flat file on HDFS (let's call this key_value): 1,1,Name,Jack 1,1,Title,Junior Accountant 1,1,Department,Finance 1,1,Supervisor,John 2,1,Title,Vice President 2,1,Name,Ron 2,1,Department,Billing Here is the output I'm looking for: (1,1,Department,Finance,Name,Jack,Supervisor,John,Title,Junior Accountant) (2,1,Department,Billing,Name,Ron,,,Title,Vice President) In other words, the first two columns form a unique identifier (similar to a composite key in db

SQL Transpose Rows to undefined number of columns

不打扰是莪最后的温柔 提交于 2019-12-24 03:53:10
问题 I have a table containing graduate ids, degree titles and graduation years. The table can contain any number of rows for each graduate. I would like to create a view that would transpose all the rows into as many columns as required, with 'null' being entered in columns where there is no data. I have seen this question asked quite a few times on here but I'm afraid they have either been not marked as answered or I don't understand the solution. So I have asked the question again in the hope

SQL Transpose Rows to undefined number of columns

落爺英雄遲暮 提交于 2019-12-24 03:53:04
问题 I have a table containing graduate ids, degree titles and graduation years. The table can contain any number of rows for each graduate. I would like to create a view that would transpose all the rows into as many columns as required, with 'null' being entered in columns where there is no data. I have seen this question asked quite a few times on here but I'm afraid they have either been not marked as answered or I don't understand the solution. So I have asked the question again in the hope

Join two tables, merge and transpose the result

余生颓废 提交于 2019-12-24 03:25:10
问题 Ok, say i have two tables products and product_options . structure table products be like: +--------------------------------------+ | p_id | product_name | product_status | +--------------------------------------+ | 1 | Keyboard ABC | PENDING | | 2 | Mouse ABC | ORDERED | | 3 | Monitor ABC | ORDERED | +--------------------------------------+ And table product_options be like: +--------------------------------------+ | po_id | p_id | opt_name | opt_value + +------------------------------------