Reputation: 21
I'm working on a project in RStudio where I need to know the number of times an issue was commented on. Each issue is represented by a row, where a comment is included in the first column for the first comment. The second comment is in the second column, and so forth. This means that an issue that was commented on 45 times would have a column that was titled "comments", "comments_1", "comments_2",... "comments_44". Each row that does not have a 45th comment would have a value of NA in the "comments_44" column. I want to make this project work for multiple datasets of the same type. How could I make a code block that counts the number of comments for each row?
Right now, I am able to count the number of comments using
for(i in 1:length(df$A){
if(is.na(df$comments_##[i] == FALSE)
df$n_comments[i] <- ##
}
}
and an else if for every column name after in descending order
structure(list(Summary = c("Visualizer fails to launch with manual story threads",
"Problems Accessing Projects Page", "Visualizer: Unexpected \"reverse array iterator\" when expanding all in the timeline",
"Visualizer: Expansion count control no longer visible", "Connection information exposed to unprivileged users",
"Advanced Filter: Add status color criteria"), `Issue key` = c("INF-3749",
"INF-3564", "INF-3223", "INF-3224", "INF-3024", "INF-1940"),
`Issue id` = c(40652, 40026, 38607, 38608, 38111, 33339),
`Parent id` = c(NA_real_, NA_real_, NA_real_, NA_real_, NA_real_,
NA_real_), `Issue Type` = c("Bug", "Bug", "Pre-Release Bug",
"Pre-Release Bug", "Bug", "New Feature"), Status = c("Resolved",
"Resolved", "Resolved", "Resolved", "Resolved", "Todo"),
`Project key` = c(Inf, Inf, Inf, Inf, Inf, Inf), `Project name` = c("Informedb",
"Informedb", "Informedb", "Informedb", "Informedb", "Informedb"
), `Project type` = c("software", "software", "software",
"software", "software", "software"), `Project lead` = c("MattChild",
"MattChild", "MattChild", "MattChild", "MattChild", "MattChild"
), `Project description` = c(NA, NA, NA, NA, NA, NA), `Project url` = c(NA,
NA, NA, NA, NA, NA), Priority = c("R4", "R4", "R4", "R4",
"R4", "R4"), Resolution = c(NA, NA, NA, NA, NA, NA), Assignee = c("JosephWallace",
"NancyKraus", NA, NA, "NancyKraus", NA), Reporter = c("RyanFord",
"PeterMorrissey", "MattChild", "MattChild", "MattChild",
"MattChild"), Creator = c("RyanFord", "PeterMorrissey", "MattChild",
"MattChild", "MattChild", "MattChild"), Created = c("1/29/2020 16:23",
"11/26/2019 15:53", "8/28/2019 0:04", "8/28/2019 0:17", "7/16/2019 9:30",
"3/6/2018 14:20"), Updated = c("2/18/2020 14:32", "1/14/2020 8:23",
"9/9/2019 12:31", "9/9/2019 12:31", "7/16/2019 22:26", "7/5/2019 16:46"
), `Last Viewed` = c("6/2/2021 9:25", "5/20/2021 10:32",
"6/2/2021 9:26", "6/2/2021 9:26", "6/2/2021 9:26", "6/2/2021 9:26"
), Resolved = c("2/18/2020 14:32", "1/14/2020 8:23", "9/9/2019 12:31",
"9/9/2019 12:31", "7/16/2019 22:26", NA), `Fix Version/s` = c(NA,
"Future", "4.9.14.0", "4.9.14.0", "4.9.13.0", NA), `Due Date` = c(NA,
NA, NA, NA, NA, NA), Votes = c(0, 0, 0, 0, 0, 0), Labels = c(NA,
"Ready", NA, NA, NA, "Pending"), Labels_1 = c(NA_character_,
NA_character_, NA_character_, NA_character_, NA_character_,
NA_character_), Labels_2 = c(NA_character_, NA_character_,
NA_character_, NA_character_, NA_character_, NA_character_
), Labels_3 = c(NA_character_, NA_character_, NA_character_,
NA_character_, NA_character_, NA_character_), Description = c("Brad Impact: 13\r\n\r\nWhen the user clicks \"Launch Informedb\", the visualizer file downloads successfully, but when launching the file, an error box appears with \"The scenario could not be found because the story thread does not exist...\"\r\n\r\nthe visualizer does not render objects correctly (at all) in this state\r\n\r\nPotential Fixes:\r\n- (Big?) Make scenarios work with manual story threads\r\n- *(Medium?) Fix launch and disable scenarios*\r\n- (Small?) Fix launch and let scenarios crash\r\n- (Small?) Disable launching manual story threads\r\n\r\nTechnical Details:\r\n- Update getNodeIdentifiers to inform visualizer about thread type\r\n- Track thread type state in visualizer\r\n- Disable features for manual story threads",
"The projects page in Enterprise Manager fails to load / loads very slowly. This is likely due to having to create a model for every project in the database.",
"When prepping for the sprint review on 8/27/2019, I received an unexpected error in the visualizer when 'showing all' on a story thread when major gridlines were enabled. Stack trace is attached.\n\nServer: informedb-sprint\nStory thread: MH-60R Integration\n\nAfter receiving the error, the application continually shows the error forever.",
"When looking at an item in the timeline view, the control that provides a count of the number of hidden related items is no longer visible. It appears to be under the background cells, as in certain scenarios you can see a part of it behind the row cell.",
"The ProjectController methods \"GetCurrentProject\" and \"GetAllowedProjects\" methods are allowed to be called by any user of the Informedb system. The data returned by these calls include connection string information, which is very sensitive and could contain database passwords.\n\nThis is an example response to GetCurrentProject:\n{\"active\":true,\"connectionString\":\"Data Source=sql2012-2.dev.simventions.com\\\\INFENTLATESTSQL;Initial Catalog=IE_DEV_Matt_Filter_Test;User Id=foo;Password=bar;Persist Security Info=True\",\"databaseType\":\"SqlServer\",\"DBCatalog\":\"IE_DEV_Matt_Filter_Test\",\"description\":\"Matt C's project for testing combinations of filter criteria\",\"ID\":\"0cb36d04-fbd5-4d5e-a183-d43041a1725a\",\"owner\":\"Matt Child\",\"projectName\":\"Matt_Filter_Test\",\"numberOfStaleUsers\":0}",
"Behaves like single select fixed."), Environment = c(NA_character_,
NA_character_, NA_character_, NA_character_, NA_character_,
NA_character_), `Log Work` = c(NA, NA, NA, NA, NA, NA), `Original Estimate` = c(NA_real_,
NA_real_, NA_real_, NA_real_, NA_real_, NA_real_), `Remaining Estimate` = c(NA_real_,
NA_real_, NA_real_, NA_real_, NA_real_, NA_real_), `Time Spent` = c(NA,
NA, NA, NA, NA, NA), `Work Ratio` = c(NA_character_, NA_character_,
NA_character_, NA_character_, NA_character_, NA_character_
), `S Original Estimate` = c(NA_real_, NA_real_, NA_real_,
NA_real_, NA_real_, NA_real_), `S Remaining Estimate` = c(NA_real_,
NA_real_, NA_real_, NA_real_, NA_real_, NA_real_), `S Time Spent` = c(NA,
NA, NA, NA, NA, NA), `Security Level` = c(NA, NA, NA, NA,
NA, NA), `Outward issue link (Blocks)` = c(NA_character_,
NA_character_, NA_character_, NA_character_, NA_character_,
NA_character_), `Outward issue link (Blocks)_1` = c(NA_character_,
NA_character_, NA_character_, NA_character_, NA_character_,
NA_character_), `Outward issue link (Blocks)_2` = c(NA_character_,
NA_character_, NA_character_, NA_character_, NA_character_,
NA_character_), `Outward issue link (Blocks)_3` = c(NA_character_,
NA_character_, NA_character_, NA_character_, NA_character_,
NA_character_), `Outward issue link (Blocks)_4` = c(NA_character_,
NA_character_, NA_character_, NA_character_, NA_character_,
NA_character_), `Outward issue link (Blocks)_5` = c(NA_character_,
NA_character_, NA_character_, NA_character_, NA_character_,
NA_character_), `Outward issue link (Blocks)_6` = c(NA_character_,
NA_character_, NA_character_, NA_character_, NA_character_,
NA_character_), `Outward issue link (Cloners)` = c(NA, NA,
NA, NA, NA, NA), `Outward issue link (Duplicate)` = c(NA_character_,
NA_character_, NA_character_, NA_character_, NA_character_,
NA_character_), `Outward issue link (Relates)` = c(NA_character_,
NA_character_, NA_character_, NA_character_, NA_character_,
NA_character_), `Outward issue link (Relates)_1` = c(NA_character_,
NA_character_, NA_character_, NA_character_, NA_character_,
NA_character_), `Outward issue link (Relates)_2` = c(NA_character_,
NA_character_, NA_character_, NA_character_, NA_character_,
NA_character_), `Outward issue link (Relates)_3` = c(NA_character_,
NA_character_, NA_character_, NA_character_, NA_character_,
NA_character_), `Outward issue link (Relates)_4` = c(NA_character_,
NA_character_, NA_character_, NA_character_, NA_character_,
NA_character_), `Outward issue link (Relates)_5` = c(NA_character_,
NA_character_, NA_character_, NA_character_, NA_character_,
NA_character_), `Outward issue link (Relates)_6` = c(NA,
NA, NA, NA, NA, NA), `Outward issue link (Relates)_7` = c(NA,
NA, NA, NA, NA, NA), `Outward issue link (Relates)_8` = c(NA,
NA, NA, NA, NA, NA), `Outward issue link (Relates)_9` = c(NA,
NA, NA, NA, NA, NA), `Outward issue link (Relates)_10` = c(NA,
NA, NA, NA, NA, NA), `Outward issue link (Tests)` = c(NA_character_,
NA_character_, NA_character_, NA_character_, NA_character_,
NA_character_), Attachment = c(NA, NA, "28/Aug/19 12:05 AM;MattChild;Expand all reverse array iterator error stack trace.txt;https://jira.dev.simventions.com/secure/attachment/17854/Expand+all+reverse+array+iterator+error+stack+trace.txt",
NA, NA, NA), Attachment_1 = c(NA_character_, NA_character_,
NA_character_, NA_character_, NA_character_, NA_character_
), Attachment_2 = c(NA_character_, NA_character_, NA_character_,
NA_character_, NA_character_, NA_character_), Attachment_3 = c(NA_character_,
NA_character_, NA_character_, NA_character_, NA_character_,
NA_character_), Attachment_4 = c(NA_character_, NA_character_,
NA_character_, NA_character_, NA_character_, NA_character_
), Attachment_5 = c(NA_character_, NA_character_, NA_character_,
NA_character_, NA_character_, NA_character_), Attachment_6 = c(NA_character_,
NA_character_, NA_character_, NA_character_, NA_character_,
NA_character_), Attachment_7 = c(NA_character_, NA_character_,
NA_character_, NA_character_, NA_character_, NA_character_
), Attachment_8 = c(NA_character_, NA_character_, NA_character_,
NA_character_, NA_character_, NA_character_), Attachment_9 = c(NA_character_,
NA_character_, NA_character_, NA_character_, NA_character_,
NA_character_), Attachment_10 = c(NA_character_, NA_character_,
NA_character_, NA_character_, NA_character_, NA_character_
), Attachment_11 = c(NA_character_, NA_character_, NA_character_,
NA_character_, NA_character_, NA_character_), Attachment_12 = c(NA_character_,
NA_character_, NA_character_, NA_character_, NA_character_,
NA_character_), Attachment_13 = c(NA_character_, NA_character_,
NA_character_, NA_character_, NA_character_, NA_character_
), Attachment_14 = c(NA_character_, NA_character_, NA_character_,
NA_character_, NA_character_, NA_character_), Attachment_15 = c(NA_character_,
NA_character_, NA_character_, NA_character_, NA_character_,
NA_character_), Attachment_16 = c(NA_character_, NA_character_,
NA_character_, NA_character_, NA_character_, NA_character_
), Attachment_17 = c(NA_character_, NA_character_, NA_character_,
NA_character_, NA_character_, NA_character_), `Custom field (Acceptance Criteria)` = c("- Filtered story thread and scenarios still work with visualizer\r\n- Visualizer launches again from manual story thread and home page\r\n- User cannot save scenarios for manual threads.",
"#NAME?", NA, NA, "- Non-enterprise managers cannot see sensitive information in the responses api responses they can query:\n - Connection String\n - DB Catalog\n - Number of stale users\n - Database type",
"- Behaves like multiple choice criteria\n- Shows the status color and name in a little box on the left of the option list.\n- Options are the union of color and label (two object types that have a status color field with the same name and an option value with the same label for \"yellow\" show but different label show up as two separate options in the option list)\n- Options in the option list are in user defined order.\n- If combining options from multiple object types, order by item order, then by label, undefined if labels are equal\n- Show only the options that are defined in that field (not the default list)\n- Shows the status color and name in the rule line of the advanced filter\n-\n"
), `Custom field (Assign to team)` = c(NA, NA, NA, NA, NA,
NA), `Custom field (Backlog Weight)` = c(NA, NA, NA, NA,
NA, NA), `Custom field (Business Value)` = c(NA, NA, NA,
NA, NA, NA), `Custom field (Due Date)` = c(NA, NA, NA, NA,
NA, NA), `Custom field (Epic Colour)` = c(NA_character_,
NA_character_, NA_character_, NA_character_, NA_character_,
NA_character_), `Custom field (Epic Link)` = c(NA_character_,
NA_character_, NA_character_, NA_character_, NA_character_,
NA_character_), `Custom field (Epic Name)` = c(NA_character_,
NA_character_, NA_character_, NA_character_, NA_character_,
NA_character_), `Custom field (Epic Status)` = c(NA_character_,
NA_character_, NA_character_, NA_character_, NA_character_,
NA_character_), `Custom field (Flagged)` = c(NA_character_,
NA_character_, NA_character_, NA_character_, NA_character_,
NA_character_), `Custom field (Functional Area)` = c(NA_character_,
NA_character_, NA_character_, NA_character_, NA_character_,
NA_character_), `Custom field (Funding Source)` = c(NA_character_,
NA_character_, NA_character_, NA_character_, NA_character_,
NA_character_), `Custom field (Impact)` = c(13, NA, NA, NA,
NA, NA), `Custom field (Pre-Condition)` = c(NA, NA, NA, NA,
NA, NA), `Custom field (Previous Names)` = c("Manual Story Thread Launch Vis fails to find Scenario Data",
NA, NA, NA, NA, NA), `Custom field (Product Line(s))` = c(NA,
NA, NA, NA, NA, NA), `Custom field (Rank)` = c("2|hzzrt3:",
"2|hzzmiv:", "2|hzzi4f:", "2|hzzi47:", "2|hzyucv:", "2|hzzh0v:"
), `Custom field (Rank (Obsolete))` = c(9.22337e+18, 9.22337e+18,
9.22337e+18, 9.22337e+18, 9.22337e+18, 9.22337e+18), `Custom field (Requirements)` = c(NA,
NA, NA, NA, NA, NA), `Custom field (SimV Story Points Deprecated)` = c(NA,
NA, NA, NA, NA, NA), Sprint = c("2/13 - 2/26", "12/5 - 12/18 - 4.9.15 rc1",
"8/29 - 9/11 - rc1 MVP", "8/29 - 9/11 - rc1 MVP", "7/5 - 7/19: 4.9.13.0 RC1",
NA), Sprint_1 = c(NA_character_, NA_character_, NA_character_,
NA_character_, NA_character_, NA_character_), Sprint_2 = c(NA_character_,
NA_character_, NA_character_, NA_character_, NA_character_,
NA_character_), Sprint_3 = c(NA_character_, NA_character_,
NA_character_, NA_character_, NA_character_, NA_character_
), Sprint_4 = c(NA_character_, NA_character_, NA_character_,
NA_character_, NA_character_, NA_character_), `Custom field (Story Points)` = c(5,
3, 2, 2, 3, NA), `Custom field (T-Shirt)` = c(NA_character_,
NA_character_, NA_character_, NA_character_, NA_character_,
NA_character_), `Custom field (Zephyr Teststep)` = c(NA,
NA, NA, NA, NA, NA), Comment = c("18/Feb/20 1:22 PM;JohnSieck;Passes test.",
"03/Dec/19 9:51 AM;NancyKraus;The projects page is looping through all projects to calculate the number of stale users. Two things could be done to fix this:\r\n # Only initialize the dynamic EF model when it is needed, not when the regular EF model is used\r\n # Change how the number of stale users is calculated via stored procedures in the enterprise database\r\n\r\nA similar problem will occur on any Enterprise Manager page that needs to traverse all the projects and uses the new repositories to get data.",
"06/Sep/19 5:32 PM;JohnSieck;Steps to reproduce\n * Turn major gridlines on\n * Turn subheader on to Months\n * Turn subheader gridlines on\n * Wait for it to completely load\n * Show all items",
"09/Sep/19 11:28 AM;MichaelJones;Passes test. When links are created/present for a node, the small circle is there indicating how many links are associated to the node.",
"16/Jul/19 1:18 PM;NancyKraus;When testing, the two pages to check for leaks:\n * Any page - check api/project/GetCurrentProject\n * Project Transfer page - check api/project/GetAlowedProjects\n\n \n\nSmoke test things related to projects:\n * create\n * delete\n * update\n * places where projects are listed",
NA), Comment_1 = c("18/Feb/20 1:54 PM;PeterMorrissey;Passes test",
"05/Dec/19 2:35 PM;PeterMorrissey;POC: Nancy\r\n\r\nTime: Less than half a day\r\n\r\nDependencies: None",
"06/Sep/19 5:45 PM;JohnSieck;Tested with several story threads (manual, basic and adv) in different projects on Latest. No problems. Passed test.",
"09/Sep/19 12:10 PM;NancyKraus;Passes test.", "16/Jul/19 2:12 PM;NancyKraus;Follow on story: INF-3025 ",
NA), Comment_2 = c(NA, "05/Dec/19 2:56 PM;NancyKraus;Things to smoke test:\r\n # Spreadsheet Edit Modal\r\n ## Change between projects and make sure it still works\r\n ## Change taxonomy (add/remove/rename object types and attributes) and make sure it still works",
"09/Sep/19 12:29 PM;NancyKraus;Passed test.", NA, "16/Jul/19 4:54 PM;PeterMorrissey;Passes Test",
NA), Comment_3 = c(NA, "05/Dec/19 4:50 PM;JosephWallace;Seems to be working for me. No spreadsheet misbehavior.",
NA, NA, "16/Jul/19 10:26 PM;MattChild;Test Passed.\n- (Pass) GetCurrentProject does not have sensitive information. Verified on an old RAZR page (Objects) and a new React page (Reports).\n- (Pass) GetAllowedProjects does not have sensitive information. Verified on the Project Transfers page.\n- (Pass) Profiles page (which lists projects) does not expose any sensitive information.\n- (Pass) Creating new projects completes successfully.\n- (Pass) Renaming a project in enterprise manager completes successfully.\n- (Pass) Deleting a project in enterprise manager completes successfully.",
NA), Comment_4 = c(NA, "06/Dec/19 8:45 AM;MichaelJones;passed",
NA, NA, NA, NA), Comment_5 = c(NA_character_, NA_character_,
NA_character_, NA_character_, NA_character_, NA_character_
), Comment_6 = c(NA_character_, NA_character_, NA_character_,
NA_character_, NA_character_, NA_character_), Comment_7 = c(NA_character_,
NA_character_, NA_character_, NA_character_, NA_character_,
NA_character_), Comment_8 = c(NA_character_, NA_character_,
NA_character_, NA_character_, NA_character_, NA_character_
), Comment_9 = c(NA_character_, NA_character_, NA_character_,
NA_character_, NA_character_, NA_character_), Comment_10 = c(NA_character_,
NA_character_, NA_character_, NA_character_, NA_character_,
NA_character_), Comment_11 = c(NA_character_, NA_character_,
NA_character_, NA_character_, NA_character_, NA_character_
), Comment_12 = c(NA_character_, NA_character_, NA_character_,
NA_character_, NA_character_, NA_character_), Comment_13 = c(NA_character_,
NA_character_, NA_character_, NA_character_, NA_character_,
NA_character_), Comment_14 = c(NA_character_, NA_character_,
NA_character_, NA_character_, NA_character_, NA_character_
), Comment_15 = c(NA_character_, NA_character_, NA_character_,
NA_character_, NA_character_, NA_character_), Comment_16 = c(NA_character_,
NA_character_, NA_character_, NA_character_, NA_character_,
NA_character_), Comment_17 = c(NA_character_, NA_character_,
NA_character_, NA_character_, NA_character_, NA_character_
), Comment_18 = c(NA_character_, NA_character_, NA_character_,
NA_character_, NA_character_, NA_character_), Comment_19 = c(NA_character_,
NA_character_, NA_character_, NA_character_, NA_character_,
NA_character_), Comment_20 = c(NA_character_, NA_character_,
NA_character_, NA_character_, NA_character_, NA_character_
), Comment_21 = c(NA_character_, NA_character_, NA_character_,
NA_character_, NA_character_, NA_character_), Comment_22 = c(NA_character_,
NA_character_, NA_character_, NA_character_, NA_character_,
NA_character_), Comment_23 = c(NA_character_, NA_character_,
NA_character_, NA_character_, NA_character_, NA_character_
), Comment_24 = c(NA_character_, NA_character_, NA_character_,
NA_character_, NA_character_, NA_character_), Comment_25 = c(NA_character_,
NA_character_, NA_character_, NA_character_, NA_character_,
NA_character_), Comment_26 = c(NA_character_, NA_character_,
NA_character_, NA_character_, NA_character_, NA_character_
), Comment_27 = c(NA_character_, NA_character_, NA_character_,
NA_character_, NA_character_, NA_character_), Comment_28 = c(NA_character_,
NA_character_, NA_character_, NA_character_, NA_character_,
NA_character_), Comment_29 = c(NA_character_, NA_character_,
NA_character_, NA_character_, NA_character_, NA_character_
), Comment_30 = c(NA_character_, NA_character_, NA_character_,
NA_character_, NA_character_, NA_character_), Comment_31 = c(NA_character_,
NA_character_, NA_character_, NA_character_, NA_character_,
NA_character_), Comment_32 = c(NA_character_, NA_character_,
NA_character_, NA_character_, NA_character_, NA_character_
), Comment_33 = c(NA_character_, NA_character_, NA_character_,
NA_character_, NA_character_, NA_character_), Comment_34 = c(NA_character_,
NA_character_, NA_character_, NA_character_, NA_character_,
NA_character_), Comment_35 = c(NA_character_, NA_character_,
NA_character_, NA_character_, NA_character_, NA_character_
), Comment_36 = c(NA_character_, NA_character_, NA_character_,
NA_character_, NA_character_, NA_character_), Comment_37 = c(NA_character_,
NA_character_, NA_character_, NA_character_, NA_character_,
NA_character_), Comment_38 = c(NA_character_, NA_character_,
NA_character_, NA_character_, NA_character_, NA_character_
), Comment_39 = c(NA_character_, NA_character_, NA_character_,
NA_character_, NA_character_, NA_character_), Comment_40 = c(NA_character_,
NA_character_, NA_character_, NA_character_, NA_character_,
NA_character_), Comment_41 = c(NA_character_, NA_character_,
NA_character_, NA_character_, NA_character_, NA_character_
), Comment_42 = c(NA_character_, NA_character_, NA_character_,
NA_character_, NA_character_, NA_character_), Comment_43 = c(NA_character_,
NA_character_, NA_character_, NA_character_, NA_character_,
NA_character_), n_sprints = c(1, 1, 1, 1, 1, 0), completed = c(1,
1, 1, 1, 1, 0), Parent = c(NA_real_, NA_real_, NA_real_,
NA_real_, NA_real_, NA_real_), Issue = c(40652, 40026, 38607,
38608, 38111, 33339), Type = c("Bug", "Bug", "Pre-Release Bug",
"Pre-Release Bug", "Bug", "New Feature"), date_created = structure(c(18290,
18226, 18136, 18136, 18093, 17596), class = "Date"), date_updated = structure(c(18310,
18275, 18148, 18148, 18093, 18082), class = "Date"), date_resolved = structure(c(18310,
18275, 18148, 18148, 18093, NA), class = "Date"), time_spent = structure(c(20,
49, 12, 12, 0, 486), class = "difftime", units = "days"),
repair_time = structure(c(20, 49, 12, 12, 0, NA), class = "difftime", units = "days")), row.names = c(NA,
-6L), class = c("tbl_df", "tbl", "data.frame"), problems = structure(list(
row = c(1253L, 1253L, 1253L, 1253L, 1253L, 1338L, 1338L,
1338L, 1343L, 1542L, 1660L, 1703L, 1965L, 1971L, 2076L, 2076L,
2532L), col = c("Outward issue link (Relates)_6", "Outward issue link (Relates)_7",
"Outward issue link (Relates)_8", "Outward issue link (Relates)_9",
"Outward issue link (Relates)_10", "Log Work", "Time Spent",
"S Time Spent", "Outward issue link (Cloners)", "Outward issue link (Cloners)",
"Outward issue link (Cloners)", "Custom field (Product Line(s))",
"Custom field (Product Line(s))", "Custom field (Product Line(s))",
"Outward issue link (Relates)_6", "Outward issue link (Relates)_7",
"Outward issue link (Cloners)"), expected = c("1/0/T/F/TRUE/FALSE",
"1/0/T/F/TRUE/FALSE", "1/0/T/F/TRUE/FALSE", "1/0/T/F/TRUE/FALSE",
"1/0/T/F/TRUE/FALSE", "1/0/T/F/TRUE/FALSE", "1/0/T/F/TRUE/FALSE",
"1/0/T/F/TRUE/FALSE", "1/0/T/F/TRUE/FALSE", "1/0/T/F/TRUE/FALSE",
"1/0/T/F/TRUE/FALSE", "1/0/T/F/TRUE/FALSE", "1/0/T/F/TRUE/FALSE",
"1/0/T/F/TRUE/FALSE", "1/0/T/F/TRUE/FALSE", "1/0/T/F/TRUE/FALSE",
"1/0/T/F/TRUE/FALSE"), actual = c("INF-2553", "INF-2534",
"INF-2535", "INF-2531", "INF-2452", "Completed 3 training modules;04/Dec/18 2:08 PM;NancyKraus;7200",
"7200", "7200", "INF-2344", "INF-1784", "INF-1820", "4.9.8.1",
"4.9.8.1", "4.9.8.0", "MWA-1304", "MWA-1311", "INF-110"),
file = c("'Informedb Jira Data.csv'", "'Informedb Jira Data.csv'",
"'Informedb Jira Data.csv'", "'Informedb Jira Data.csv'",
"'Informedb Jira Data.csv'", "'Informedb Jira Data.csv'",
"'Informedb Jira Data.csv'", "'Informedb Jira Data.csv'",
"'Informedb Jira Data.csv'", "'Informedb Jira Data.csv'",
"'Informedb Jira Data.csv'", "'Informedb Jira Data.csv'",
"'Informedb Jira Data.csv'", "'Informedb Jira Data.csv'",
"'Informedb Jira Data.csv'", "'Informedb Jira Data.csv'",
"'Informedb Jira Data.csv'")), row.names = c(NA, -17L), class = c("tbl_df",
"tbl", "data.frame")))
Upvotes: 0
Views: 151
Reputation: 2626
If your other columns are never NA, this should work:
library(dplyr)
YOUR_DATA %>%
tidyr::pivot_longer(cols = starts_with("comments"),
names_prefix = "comments",
names_to = "comment_number") %>%
na.omit() %>%
count(issue) # or whatever your ID column is
Upvotes: 0
Reputation: 263301
I took a stab at pasting that structure into an R console session but the parser thought it was malformed. (It has a bunch of unescaped double-quotes inside strings.) So I tried to create a much smaller extract. I didn't make it a tibble, but this might still succeed if your more complex structure does not have those "Comment"-columns inside an embedded dataframe.
dat <- structure(list(Comment_1 = c("18/Feb/20 1:54 PM;PeterMorrissey;Passes test", "05/Dec/19 2:35 PM;PeterMorrissey;POC: Nancy\r\n\r\nTime: Less than half a day\r\n\r\nDependencies: None", "06/Sep/19 5:45 PM;JohnSieck;Tested with several story threads (manual, basic and adv) in different projects on Latest. No problems. Passed test.", "09/Sep/19 12:10 PM;NancyKraus;Passes test.", "16/Jul/19 2:12 PM;NancyKraus;Follow on story: INF-3025 ", NA), Comment_2 = c(NA, "05/Dec/19 2:56 PM;NancyKraus;Things to smoke test:\r\n # Spreadsheet Edit Modal\r\n ## Change between projects and make sure it still works\r\n ## Change taxonomy (add/remove/rename object types and attributes) and make sure it still works", "09/Sep/19 12:29 PM;NancyKraus;Passed test.", NA, "16/Jul/19 4:54 PM;PeterMorrissey;Passes Test", NA), Comment_3 = c(NA, "05/Dec/19 4:50 PM;JosephWallace;Seems to be working for me. No spreadsheet misbehavior.", NA, NA, "16/Jul/19 10:26 PM;MattChild;Test Passed.\n- (Pass) GetCurrentProject does not have sensitive information. Verified on an old RAZR page (Objects) and a new React page (Reports).\n- (Pass) GetAllowedProjects does not have sensitive information. Verified on the Project Transfers page.\n- (Pass) Profiles page (which lists projects) does not expose any sensitive information.\n- (Pass) Creating new projects completes successfully.\n- (Pass) Renaming a project in enterprise manager completes successfully.\n- (Pass) Deleting a project in enterprise manager completes successfully.", NA), Comment_4 = c(NA, "06/Dec/19 8:45 AM;MichaelJones;passed", NA, NA, NA, NA) ), class = "data.frame", row.names = c(NA, -6L))
Then you can focus on just the columns named "Comment" and sum the number of NOT-<NA>
values. with the expression apply(is.na(dat[ , grepl("Comment", names(dat))]), 1, sum)
. And assign it to a suitably named column:
dat$cmnt_cnt <- apply(!is.na(dat[ , grepl("Comment", names(dat))]), 1, sum)
#-----------------------
str(dat)
'data.frame': 6 obs. of 5 variables:
$ Comment_1: chr "18/Feb/20 1:54 PM;PeterMorrissey;Passes test" "05/Dec/19 2:35 PM;PeterMorrissey;POC: Nancy\r\n\r\nTime: Less than half a day\r\n\r\nDependencies: None" "06/Sep/19 5:45 PM;JohnSieck;Tested with several story threads (manual, basic and adv) in different projects on "| __truncated__ "09/Sep/19 12:10 PM;NancyKraus;Passes test." ...
$ Comment_2: chr NA "05/Dec/19 2:56 PM;NancyKraus;Things to smoke test:\r\n # Spreadsheet Edit Modal\r\n ## Change between projects "| __truncated__ "09/Sep/19 12:29 PM;NancyKraus;Passed test." NA ...
$ Comment_3: chr NA "05/Dec/19 4:50 PM;JosephWallace;Seems to be working for me. No spreadsheet misbehavior." NA NA ...
$ Comment_4: chr NA "06/Dec/19 8:45 AM;MichaelJones;passed" NA NA ...
$ cmnt_cnt : int 1 4 2 1 3 0
Upvotes: 1