In many instances, I have seen code that is poorly formatted or all in one line (like below using R). Is it appropriate to edit the code so that it is more legible? I know in some instances these are necessary edits that would improve the post (according to here and here).
However, recently, someone nicely pointed out that I was doing too many small/minor edits on questions (as I usually fix issues when I see them), but I did not realize I was bumping some questions up in the active queue. So, I am trying to make sure my edits are "necessary".
One example that I recently saw was where someone provided their data (a dataframe in R), but it was all in one line, such as:
df <- structure(list(Site = structure(c(1L, 1L, 1L), .Label = "Agriculture", class = "factor"), CowId = 1000:1002, Result = list(c("A", "B"), "C", "C")), class = c("grouped_df", "tbl_df", "tbl", "data.frame"), row.names = c(NA, -3L), groups = structure(list( Site = structure(c(1L, 1L, 1L), .Label = "FarmA", class = "factor"), CowId = 1000:1002, .rows = structure(list(1L, 2L, 3L), ptype = integer(0), class = c("vctrs_list_of", "vctrs_vctr", "list"))), class = c("tbl_df", "tbl", "data.frame" ), row.names = c(NA, -3L), .drop = TRUE))
So, in this case, is it worth formatting the code so that the data structure is more visible? Something like this:
df <- structure( list( Site = structure(c(1L, 1L, 1L), .Label = "Agriculture", class = "factor"), CowId = 1000:1002, Result = list(c("A", "B"), "C", "C") ), class = c("grouped_df", "tbl_df", "tbl", "data.frame"), row.names = c(NA,-3L), groups = structure( list( Site = structure(c(1L, 1L, 1L), .Label = "FarmA", class = "factor"), CowId = 1000:1002, .rows = structure( list(1L, 2L, 3L), ptype = integer(0), class = c("vctrs_list_of", "vctrs_vctr", "list") ) ), class = c("tbl_df", "tbl", "data.frame"), row.names = c(NA,-3L), .drop = TRUE ) )
I am just wondering where the balance is for improving posts but not causing frustration to people when things get bumped up in the active queue.
This could be a duplicate question, but was not able to find an immediate answer.