Yingjie4Science / SDGdetector

A novel R package that can identify and visualize 17 Sustainable Development Goals and associated 169 Targets in text
GNU General Public License v3.0
15 stars 1 forks source link

Where does the "Value" Column in "sdgstat" comes from? #5

Closed v-gestern closed 1 year ago

v-gestern commented 1 year ago

Thank you for creating an providing this super cool package!

Unfortunately I can´t perform all given functionalities on my own data. If I run SDGdetector on my data, it returns a df with the the new column "sdg" where the identified SDGs are shown. But it doesn´t return the values described in the help function ("Data frame with the same information as df and 18 extra columns: 17 columns marking the number of occurrence of each of the 17 SDGs and one column match_detail listing details of specific targets.").

And where do I get the "Value" column from to perform plot_sdg_bar on my own data?

Yingjie4Science commented 1 year ago

@v-gestern Thanks for spotting the confusing description in the help function. I have revised the description as:

' Data frame with the same columns as the df plus one extra column named "sdgs", which

' list the occurrence (or hits) of SDG goals or targets detected from each sentence in rows.

' Users can further use our function summarize_sdg() to clean the result for visulization.

For visualization, we need to further clean the data, so that one column is for individual SDG, and another column is about the total number of each SDG detected from the text. To achieve this, you can write your own function, but here is a new function summarize_sdg() I just added to save users' time. Please let me know if you have further questions.

' An example to use the function (you might need to update the package or re-install it in order to use the updated functions)

library(SDGdetector) df <- data.frame(col = c( 'our goal is to end poverty globally', 'this product contributes to slowing down climate change')) d <- SDGdetector(x = df, col = col) data <- summarize_sdg(d, sum_by = 'goal', quiet = FALSE) %>% dplyr::rename(Value = Freq)

plot_sdg_bar(data)

v-gestern commented 1 year ago

@Yingjie4Science Thank you for the update. I re-installed the package and tried to use the new function, but I got this error message: "Error in summarize_sdg(d, sum_by = "goal", quiet = FALSE) : could not find function "summarize_sdg" even though summarize_sdg is available in the package Help/Description

Bildschirmfoto vom 2023-05-22 17-48-11

Yingjie4Science commented 1 year ago

@v-gestern did you re-installed via cran or GitHub version? You may want to use the GitHub development version because getting the updated version on CRAN would take a while.

v-gestern commented 1 year ago

@Yingjie4Science I used the code you are suggesting in your README.md

if (!require("remotes")) { install.packages("remotes") }

remotes::install_github("Yingjie4Science/SDGdetector")

Yingjie4Science commented 1 year ago

@v-gestern could you test it again? I found a testing error, and guess that could be the reason that caused the error. I have fixed it and tested it on my end. Hope the updated one can work on your machine.

v-gestern commented 1 year ago

@Yingjie4Science, thanks a lot for investigating on this issue. I re-installed the package and tried to run the code again. Unfortunately, the error still exists.. Bildschirmfoto vom 2023-05-23 16-44-55

Yingjie4Science commented 1 year ago

@v-gestern this is interesting... how about removing the package first and re-install it? I just tested this on my machine and there is no error. But I will ask someone else to take a second look/test. Sorry for the inconvenience

remove.packages("SDGdetector")

v-gestern commented 1 year ago

@Yingjie4Science i removed the package first and then re-installed it. I've tried it again with remove.package() but the error still occurs.

Thank you for investigating :)

Yingjie4Science commented 1 year ago

@v-gestern An alternative way is to copy everything here and paste it into your code chunk and use the function directly.

Hi @caimeng2 , could you take a look and help address the error? Thanks!

Yingjie4Science commented 1 year ago

@v-gestern you may try CRAN version and see if it works or not. Otherwise, see the way above.

caimeng2 commented 1 year ago

@Yingjie4Science it works for me fine.

Screenshot 2023-05-24 at 2 16 10 PM

installed from Github

Yingjie4Science commented 1 year ago

@caimeng2 Thanks!!! @v-gestern see the above messages, we have updated the CRAN version.