spread

Spreadsheets: how do I SUM values in a column, only if the text column has a 1?

半城伤御伤魂 提交于 2019-12-04 03:33:14
问题 Let's say I have this data 4 1 4 0 4 1 3 0 5 1 How do I write a function (using SUM or something like that) to add all the values on the left, if the values on the right are 1, or true The total should be 13 回答1: Assuming columns A and B are used... Check just for 1: =SUMIF(B1:B5,"=1",A1:A5) If you want to check for TRUE also: =SUMIF(B1:B5,"=1",A1:A5) + SUMIF(B1:B5,"=TRUE",A1:A5) 回答2: sort by column b, then auto-sum the values you want in column a. cheap & lazy solution. 来源: https:/

Spreadsheets: how do I SUM values in a column, only if the text column has a 1?

。_饼干妹妹 提交于 2019-12-01 18:43:58
Let's say I have this data 4 1 4 0 4 1 3 0 5 1 How do I write a function (using SUM or something like that) to add all the values on the left, if the values on the right are 1, or true The total should be 13 Assuming columns A and B are used... Check just for 1: =SUMIF(B1:B5,"=1",A1:A5) If you want to check for TRUE also: =SUMIF(B1:B5,"=1",A1:A5) + SUMIF(B1:B5,"=TRUE",A1:A5) sort by column b, then auto-sum the values you want in column a. cheap & lazy solution. 来源: https://stackoverflow.com/questions/3832457/spreadsheets-how-do-i-sum-values-in-a-column-only-if-the-text-column-has-a-1

Spread with duplicate identifiers for rows [duplicate]

独自空忆成欢 提交于 2019-11-29 10:25:38
This question already has an answer here: Using spread with duplicate identifiers for rows 3 answers There has been questions on this topic before here , but I am still struggling with spreading this. I would like so each state to have its own column of temperatures values. Here is a dput() of my data. I'll call it df structure(list(date = c("2018-01-21", "2018-01-21", "2018-01-20", "2018-01-20", "2018-01-19", "2018-01-19", "2018-01-18", "2018-01-18", "2018-01-17", "2018-01-17", "2018-01-16", "2018-01-16", "2018-01-15", "2018-01-15", "2018-01-14", "2018-01-14", "2018-01-12", "2018-01-12",

tidyr - spread multiple columns

瘦欲@ 提交于 2019-11-28 12:34:38
I'm preparing data for a network meta-analysis and I am having difficult in tyding the columns. If I have this initial dataset: Study Trt y sd n 1 1 -1.22 3.70 54 1 3 -1.53 4.28 95 2 1 -0.30 4.40 76 2 2 -2.60 4.30 71 2 4 -1.2 4.3 81 How can I finish with this other one? Study Treatment1 y1 sd1 n1 Treatment2 y2 sd2 n2 Treatment3 y3 sd3 n3 1 1 1 -1.22 3.70 54 3 -1.53 4.28 95 NA NA NA NA 2 3 1 -0.30 4.40 76 2 -2.60 4.30 71 4 -1.2 4.3 81 I'm really stuck in this step, and I'd really appreciate some help... We can gather to 'long' format, then unite multiple columns to single and spread it to wide

How to use the spread function properly in tidyr

ⅰ亾dé卋堺 提交于 2019-11-28 12:22:34
How do I change the following table from: Type Name Answer n TypeA Apple Yes 5 TypeA Apple No 10 TypeA Apple DK 8 TypeA Apple NA 20 TypeA Orange Yes 6 TypeA Orange No 11 TypeA Orange DK 8 TypeA Orange NA 23 Change to: Type Name Yes No DK NA TypeA Apple 5 10 8 20 TypeA Orange 6 11 8 23 I used the following codes to get the first table. df_1 <- df %>% group_by(Type, Name, Answer) %>% tally() Then I tried to use the spread command to get to the 2nd table, but I got the following error message: "Error: All columns must be named" df_2 <- spread(df_1, Answer) Following on the comment from ayk, I'm

how to spread or cast multiple values in r [duplicate]

纵然是瞬间 提交于 2019-11-27 09:06:16
This question already has an answer here: can the value.var in dcast be a list or have multiple value variables? 3 answers Convert data from long format to wide format with multiple measure columns 4 answers Here is toy data set for this example: data <- data.frame(x=rep(c("red","blue","green"),each=4), y=rep(letters[1:4],3), value.1 = 1:12, value.2 = 13:24) x y value.1 value.2 1 red a 1 13 2 red b 2 14 3 red c 3 15 4 red d 4 16 5 blue a 5 17 6 blue b 6 18 7 blue c 7 19 8 blue d 8 20 9 green a 9 21 10 green b 10 22 11 green c 11 23 12 green d 12 24 How can I cast or spread variable y, to

tidyr - spread multiple columns

微笑、不失礼 提交于 2019-11-27 07:13:07
问题 I'm preparing data for a network meta-analysis and I am having difficult in tyding the columns. If I have this initial dataset: Study Trt y sd n 1 1 -1.22 3.70 54 1 3 -1.53 4.28 95 2 1 -0.30 4.40 76 2 2 -2.60 4.30 71 2 4 -1.2 4.3 81 How can I finish with this other one? Study Treatment1 y1 sd1 n1 Treatment2 y2 sd2 n2 Treatment3 y3 sd3 n3 1 1 1 -1.22 3.70 54 3 -1.53 4.28 95 NA NA NA NA 2 3 1 -0.30 4.40 76 2 -2.60 4.30 71 4 -1.2 4.3 81 I'm really stuck in this step, and I'd really appreciate

How to use the spread function properly in tidyr

≯℡__Kan透↙ 提交于 2019-11-27 06:11:09
问题 How do I change the following table from: Type Name Answer n TypeA Apple Yes 5 TypeA Apple No 10 TypeA Apple DK 8 TypeA Apple NA 20 TypeA Orange Yes 6 TypeA Orange No 11 TypeA Orange DK 8 TypeA Orange NA 23 Change to: Type Name Yes No DK NA TypeA Apple 5 10 8 20 TypeA Orange 6 11 8 23 I used the following codes to get the first table. df_1 <- df %>% group_by(Type, Name, Answer) %>% tally() Then I tried to use the spread command to get to the 2nd table, but I got the following error message:

how to spread or cast multiple values in r [duplicate]

只谈情不闲聊 提交于 2019-11-26 11:28:23
问题 This question already has an answer here: can the value.var in dcast be a list or have multiple value variables? 3 answers Convert data from long format to wide format with multiple measure columns 5 answers Here is toy data set for this example: data <- data.frame(x=rep(c(\"red\",\"blue\",\"green\"),each=4), y=rep(letters[1:4],3), value.1 = 1:12, value.2 = 13:24) x y value.1 value.2 1 red a 1 13 2 red b 2 14 3 red c 3 15 4 red d 4 16 5 blue a 5 17 6 blue b 6 18 7 blue c 7 19 8 blue d 8 20 9