vosonlab / vosonSML

R package for collecting social media data and creating networks for analysis.
https://vosonlab.github.io/vosonSML/
GNU General Public License v3.0
78 stars 13 forks source link

ImportData function from latest GitHub release #50

Closed GabriellaSpence closed 2 years ago

GabriellaSpence commented 2 years ago

Hello,

I would like to learn network analysis and I came across your blog post. I pulled data from rtweet package and I would like to use your package to create different network data frames. However, when I use the ImportData function I get the following error: Error in if (!type %in% supported_types) { : the condition has length > 1.

Can you please help me figure out what I am doing wrong?

library(dplyr)
library(vosonSML)

# Load in data (rt data frame)
rt = readRDS("Data.rds")

# Convert to work with vosonSML package
class(rt) = append(c("datasource", "twitter"), class(rt))
rt = rt %>% ImportData("twitter")

Thank you for your help!

bryn-g commented 2 years ago

Hi @GabriellaSpence,

Apologies for this error, it occurs because the ImportData function does not yet support objects of data.frame type in the CRAN version of the package (and github release). The blog post was written using a github version of vosonSML that has not made its way to CRAN yet unfortunately.

The ImportData function typically converts data into a data.frame and applies the classes, as you have done in your code snippet. As the data is already a tibble(data.frame) and you have applied the classes manually, you actually don't need to import and can proceed to the Create function:

library(dplyr)
library(vosonSML)

# Load in data (rt data frame)
rt <- readRDS("Data.rds")

# Convert to work with vosonSML package
class(rt) <- append(c("datasource", "twitter"), class(rt))
# can now skip this step
# rt <- rt %>% ImportData("twitter")

actor_net <- rt %>% Create("actor")

Alternatively, you can install the github version of vosonSML and use the import function as follows (recommended approach):

# install github version of vosonSML
install.packages("remotes")
remotes::install_github("vosonlab/vosonSML")

library(dplyr)
library(vosonSML)

# version should be 0.30.6
packageVersion("vosonSML")

# Load in data (rt data frame)
rt <- readRDS("Data.rds")

# Convert to work with vosonSML package
rt <- rt %>% ImportData("twitter")

actor_net <- rt %>% Create("actor")

Hope this helps, please let me know if you encounter any further problems.