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-function.R 1.5KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. repeat {
  2. c_samno <- sample(1:nrow(c_tweets), 1)
  3. c_samtext <- as.character(c_tweets$text[c_samno])
  4. c_samissue <- as.character(c_tweets$issue[c_samno])
  5. c_samtags <- as.character(c_tweets$tags[c_samno])
  6. c_samid <- as.character(c_tweets$id_str[c_samno])
  7. repeat {
  8. cat("===================\n\n[TWEET]: ",c_samtext,"\n", "[ISSUES]: ", c_samissue, " (", c_samtags, ")", sep="")
  9. c_yn <- readYN("Is the categorization correct AND complete?\nEnter y or n: ")
  10. # Check if input is correct
  11. if(c_yn == "y" || c_yn == "n" || c_yn == "QUIT") {break} else {cat("Wrong input, please enter y or n (or QUIT if you want to exit safely).\n")}
  12. }
  13. # Exit codes:
  14. # 0 = Correct tagging
  15. # 1 = At least one tag was incorrect
  16. # 2 = At least one tag was missing
  17. # 3 = Both 1 and 2
  18. if(c_yn == "y") {
  19. c_result <- str_c("\"",c_samid,"\"",",0,","\"",c_samissue,"\",\"",c_samtags,"\",\"",c_samtext,"\"")
  20. write(c_result, file = "issuecomp-codingsample-correct.csv", append = T)
  21. }
  22. else if(c_yn == "n") {
  23. repeat {
  24. c_err <- readYN("Enter 1 if a tag is incorrect, 2 if a tag is missing, and 3 if a tag is incorrect AND missing: ")
  25. if(c_err == "1" || c_err == "2" || c_err == "3") {break} else {cat("Wrong input, please enter 1, 2 or 3.\n")}
  26. }
  27. c_result <- str_c("\"",c_samid,"\",",c_err,",\"",c_samissue,"\",\"",c_samtags,"\",\"",c_samtext,"\"")
  28. write(c_result, file = "issuecomp-codingsample-error.csv", append = T)
  29. }
  30. else {
  31. cat("Quitting now.")
  32. break
  33. }
  34. }