r pivot table code example
Example 1: pivot table in r dplyr
## make a table with our new variable
siteyear_summary %>%
kable()
Example 2: pivot table
SELECT * -- Total invoices per gender
FROM (
SELECT invoice, gender
FROM sales
) d
PIVOT (
sum(invoice)
FOR gender IN ('F' AS "Women", 'M' AS "Men")
);
-- Table Sales:
CREATE TABLE sales (
gender VARCHAR2(1 BYTE), -- 'F' or 'M'
invoice NUMBER
);