Bachelor thesis: "The influence of sensational issues on the political agenda setting in social media"
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

issuecomp-codingsample-function2.R 3.6KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. # A tweet was falsely categorized
  2. if(c_errcode == "1") {
  3. repeat {
  4. c_curissue <- readYN("Which issue is incorrect?: ")
  5. if(c_curissue == "QUIT") {cat("Quitting this item without changes or entries.\n"); break}
  6. c_curissue <- unlist(str_split(c_curissue, ","))
  7. status <- checkAllIssues(c_curissue, c_issueheads)
  8. # Only continue if every given issue really exists (all "status" have to be TRUE)
  9. if(all(status)) {
  10. # Revert str_split
  11. c_curissue <- str_join(c_curissue,collapse = ",")
  12. # <ID>,<all issues>,<faulty issue(s),<all tags>,<tweet text>
  13. c_result <- str_c("\"",c_errid,"\",\"",c_errissue,"\",\"",c_curissue,"\",\"",c_errtags,"\",\"",c_errtext,"\"")
  14. write(c_result, file = "issuecomp-codingsample-error1.csv", append = T)
  15. break
  16. }
  17. }
  18. # A tweet should be categorized with an additional issue
  19. } else if(c_errcode == "2") {
  20. repeat {
  21. c_curissue <- readYN("Which issue is missing?: ")
  22. if(c_curissue == "QUIT") {cat("Quitting this item without changes or entries.\n"); break}
  23. c_curissue <- unlist(str_split(c_curissue, ","))
  24. status <- checkAllIssues(c_curissue, c_issueheads)
  25. # Only continue if every given issue really exists (all "status" have to be TRUE)
  26. if(all(status)) {
  27. # Revert str_split
  28. c_curissue <- str_join(c_curissue,collapse = ",")
  29. # <ID>,<all issues>,<faulty issue(s),<all tags>,<tweet text>
  30. c_result <- str_c("\"",c_errid,"\",\"",c_errissue,"\",\"",c_curissue,"\",\"",c_errtags,"\",\"",c_errtext,"\"")
  31. write(c_result, file = "issuecomp-codingsample-error2.csv", append = T)
  32. break
  33. }
  34. }
  35. # There is an issue missing AND a issue was wrong
  36. } else if(c_errcode == "3") {
  37. # #cat("Which issue is incorrect and which one is missing?\n")
  38. # repeat {
  39. # c_tag <- readYN("Which issue is incorrect?: ")
  40. # c_tag <- unlist(str_split(c_tag, ","))
  41. # for(i in 1:length(c_tag)) {
  42. # if(checkIssue(c_tag[i], c_issueheads)) {} else {cat("Issue",c_tag[i],"does not exist. Please try again.\n")}
  43. # }
  44. repeat {
  45. c_curissue <- readYN("Which issue is incorrect?: ")
  46. if(c_curissue == "QUIT") {cat("Quitting this item without changes or entries.\n"); break}
  47. c_curissue <- unlist(str_split(c_curissue, ","))
  48. status <- checkAllIssues(c_curissue, c_issueheads)
  49. # Only continue if every given issue really exists (all "status" have to be TRUE)
  50. if(all(status)) {
  51. # Revert str_split
  52. c_curissue <- str_join(c_curissue,collapse = ",")
  53. # <ID>,<all issues>,<faulty issue(s),<all tags>,<tweet text>
  54. c_result <- str_c("\"",c_errid,"\",\"",c_errissue,"\",\"",c_curissue,"\",\"",c_errtags,"\",\"",c_errtext,"\"")
  55. write(c_result, file = "issuecomp-codingsample-error1.csv", append = T)
  56. break
  57. }
  58. }
  59. repeat {
  60. c_curissue <- readYN("Which issue is missing?: ")
  61. if(c_curissue == "QUIT") {cat("Quitting this item without changes or entries.\n"); break}
  62. c_curissue <- unlist(str_split(c_curissue, ","))
  63. status <- checkAllIssues(c_curissue, c_issueheads)
  64. # Only continue if every given issue really exists (all "status" have to be TRUE)
  65. if(all(status)) {
  66. # Revert str_split
  67. c_curissue <- str_join(c_curissue,collapse = ",")
  68. # <ID>,<all issues>,<faulty issue(s),<all tags>,<tweet text>
  69. c_result <- str_c("\"",c_errid,"\",\"",c_errissue,"\",\"",c_curissue,"\",\"",c_errtags,"\",\"",c_errtext,"\"")
  70. write(c_result, file = "issuecomp-codingsample-error2.csv", append = T)
  71. break
  72. }
  73. }
  74. # If this triggers the hell freezes...
  75. } else {
  76. cat("Neither 1, 2 or 3 as error code...")
  77. }