liserman / handcodeR

R-Package to fascilitate the annotation of textdata by hand in R
18 stars 1 forks source link

error using handcode() #3

Closed gibsj closed 9 months ago

gibsj commented 1 year ago

Hello - I apologize if this is the wrong place to ask this question, as I'm not super familiar with github. I'm trying to use your awesome new package, but keep getting an error and can't get the app to open.

Here's an example using the first few observations of my data:

`

text <- c("22 Business deals with Iran undermine international efforts to bring Iran into compliance w ith UN Security Council resolutions regarding its nuclear activities in addition oil and gas investments raise concerns under US ", "37 The USG always regrets the loss of any innocent life in Iraq or anywhere else ", "42 We are particularly concerned about and focused on all Iraqi refugees especially the most vulnerable among them and are working vigorously with the international community including other governments international organizations and NGOs ", "48 Commission on International Religious Freedom is an independent commission established by Congress to monitor the status of freedom of religion abroad and to make policy recommendations to the President the Secretary of State and Congress on the issue ", "70 In view of the fluid political and security situation we are recommending that American citizens limit their movements and monitor announcements in the local media ", "70 We are monitoring the situation closely and will keep American citizens in Bangladesh informed as information becomes available ")

test <- handcode(data = text, country = c("adversary", "ally", "other")) `

I keep getting the following error, no matter how I try to process the text vector:

Error in handcode(data = text, country = c("adversary", : data must be a character vector of texts you want to annotate or a data frame that has been returned in an earlier run of this function.

I have handcodeR and shiny packages loaded (plus the usual tidyverse, etc).

liserman commented 1 year ago

Hi, I am unfortunately not able to replicate your error currently. Can you tell me which system you are using? Are you able to run the examples that are given, or do you get the same error there?

gibsj commented 1 year ago

Thanks for your response! I tried the example code and it's also throwing the exact same error, which means it's a problem on my end somehow...I updated RStudio to see if that helps and no dice. I'm now running RStudio Version 2023.06.1+524 on Mac.

On Fri, Aug 18, 2023 at 3:33 AM Lukas Isermann @.***> wrote:

Hi, I am unfortunately not able to replicate your error currently. Can you tell me which system you are using? Are you able to run the examples that are given, or do you get the same error there?

— Reply to this email directly, view it on GitHub https://github.com/liserman/handcodeR/issues/3#issuecomment-1683561920, or unsubscribe https://github.com/notifications/unsubscribe-auth/AN62DT5MY5Q3JWEQJZUMTRTXV4SGNANCNFSM6AAAAAA3TCENYQ . You are receiving this because you authored the thread.Message ID: @.***>

-- Jenna Gibson (she/her/hers) PhD Candidate, Political Science Student Coordinator, Workshop on International Politics University of Chicago

liserman commented 1 year ago

I tried to replicate your problem on different machines including Mac and tried to find any potential issues that could lead to your problem with no success. I cannot really explain where your problem may come from. At the moment I can only advise you to update R and all dependencies to the newest versions and hope that fixes the problem.

If that does not help, you could try to locate the problem by checking the following few things:

  1. Does R recognize your vector as character vector? text <- c("22 Business deals with Iran undermine international efforts to bring Iran into compliance w ith UN Security Council resolutions regarding its nuclear activities in addition oil and gas investments raise concerns under US ", "37 The USG always regrets the loss of any innocent life in Iraq or anywhere else ", "42 We are particularly concerned about and focused on all Iraqi refugees especially the most vulnerable among them and are working vigorously with the international community including other governments international organizations and NGOs ", "48 Commission on International Religious Freedom is an independent commission established by Congress to monitor the status of freedom of religion abroad and to make policy recommendations to the President the Secretary of State and Congress on the issue ", "70 In view of the fluid political and security situation we are recommending that American citizens limit their movements and monitor announcements in the local media ", "70 We are monitoring the situation closely and will keep American citizens in Bangladesh informed as information becomes available ")

is.character(text)

  1. Is handcodeR able to correctly process your vector?

arg_list <- list(country = c("adversary", "ally", "other"))

test_data <- handcodeR:::character_to_data(text, arg_list, missing = "Not applicable")

This should give you a dataframe with the variables "texts" and "country". Here, "country" must be a factor variable.

names(test_data)

is.factor(test_data$country)

  1. Can the handcodeR use the data provided?

test <- handcode(test_data)

If any of those fail, I can see if I can find a workaround for you.