Skip to content

Commit b17f32d

Browse files
committed
io campaign metadata, as_tweet_network()
1 parent a77e085 commit b17f32d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+2032
-154
lines changed

.Rbuildignore

+2
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,5 @@
1818
^test\.graphml$
1919
^playground$
2020
^\.github$
21+
^io-campaigns-twitter$
22+
^playground$

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,4 @@ src-i386
99
src-x64
1010
test.graphml
1111
playground
12+
io-campaigns-twitter

DESCRIPTION

+5-3
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ Imports:
2626
jsonify,
2727
Rcpp,
2828
stringi,
29-
magrittr
29+
magrittr,
30+
utils
3031
Suggests:
3132
covr,
3233
geojsonsf,
@@ -35,13 +36,14 @@ Suggests:
3536
knitr,
3637
future,
3738
future.apply,
39+
network,
3840
openxlsx,
3941
rtweet,
4042
sf,
4143
testthat (>= 2.1.0),
42-
tibble,
43-
utils
44+
tibble
4445
Remotes:
46+
knapply/network,
4547
SymbolixAU/jsonify,
4648
ycphs/openxlsx
4749
URL: https://github.com/knapply/tweetio, https://knapply.github.io/tweetio

NAMESPACE

+9-3
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,23 @@
11
# Generated by roxygen2: do not edit by hand
22

3-
S3method(as_igraph,data.frame)
4-
S3method(as_igraph,proto_net)
3+
S3method(as_tweet_igraph,data.frame)
4+
S3method(as_tweet_igraph,proto_net)
5+
S3method(as_tweet_network,data.frame)
6+
S3method(as_tweet_network,proto_net)
57
export("%>%")
68
export(as_igraph)
79
export(as_proto_net)
10+
export(as_tweet_igraph)
11+
export(as_tweet_network)
812
export(as_tweet_sf)
913
export(example_tweet_file)
1014
export(extract_statuses)
1115
export(extract_users)
1216
export(read_tweets)
1317
export(read_tweets_bulk)
18+
export(tweetio_as_tibble)
19+
export(tweetio_options)
20+
export(tweetio_verbose)
1421
export(write_graphml)
1522
export(write_tweet_csv)
1623
export(write_tweet_excel)
@@ -22,7 +29,6 @@ importFrom(data.table,as.data.table)
2229
importFrom(data.table,copy)
2330
importFrom(data.table,data.table)
2431
importFrom(data.table,fifelse)
25-
importFrom(data.table,fread)
2632
importFrom(data.table,fwrite)
2733
importFrom(data.table,is.data.table)
2834
importFrom(data.table,rbindlist)

R/geo.R

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ as_tweet_sf <- function(tweet_df,
4747
geom_col = c("bbox_coords", "quoted_bbox_coords",
4848
"retweet_bbox_coords",
4949
"ist_complex_value", "all"),
50-
as_tibble = getOption("tweetio.as_tibble", FALSE),
50+
as_tibble = tweetio_as_tibble(),
5151
.geometry = NULL,
5252
...) {
5353
# silence R CMD Check NOTE

R/igraph.R

+23-12
Original file line numberDiff line numberDiff line change
@@ -20,31 +20,44 @@
2020
#' @param x Tweet data frame or `proto_net`.
2121
#' @param ... Arguments passed to `as_proto_net()`.
2222
#'
23+
#' @seealso [as_proto_net()], [as_tweet_network()]
24+
#'
2325
#' @template author-bk
2426
#'
2527
#' @examples
2628
#' path_to_tweet_file <- example_tweet_file()
2729
#' tweet_df <- read_tweets(path_to_tweet_file)
2830
#'
2931
#' tweet_df %>%
30-
#' as_igraph()
32+
#' as_tweet_igraph()
3133
#'
3234
#' tweet_df %>%
3335
#' as_proto_net() %>%
34-
#' as_igraph()
36+
#' as_tweet_igraph()
3537
#'
38+
#' tweet_df %>%
39+
#' as_tweet_igraph(all_status_data = TRUE)
40+
#'
41+
#' tweet_df %>%
42+
#' as_tweet_igraph(all_user_data = TRUE)
43+
#'
3644
#' @export
37-
as_igraph <- function(x, ...) {
38-
UseMethod("as_igraph")
45+
as_tweet_igraph <- function(x, ...) {
46+
UseMethod("as_tweet_igraph")
3947
}
4048

49+
# TODO deprecate `as_igraph()` in favor of `as_tweet_igraph()`
50+
#' @rdname as_tweet_igraph
51+
#'
52+
#' @export
53+
as_igraph <- as_tweet_igraph
4154

42-
#' @rdname as_igraph
55+
#' @rdname as_tweet_igraph
4356
#'
4457
#' @importFrom data.table %chin%
4558
#'
4659
#' @export
47-
as_igraph.proto_net <- function(x, ...) {
60+
as_tweet_igraph.proto_net <- function(x, ...) {
4861
if (!requireNamespace("igraph", quietly = TRUE)) {
4962
stop("{igraph} package is required for this funcitonality.", call. = FALSE)
5063
}
@@ -58,9 +71,7 @@ as_igraph.proto_net <- function(x, ...) {
5871
igraph::make_empty_graph(n = nrow(x$nodes)),
5972
el
6073
)
61-
62-
# x$edges[, -(1:2L)]
63-
74+
6475
igraph::edge_attr(out) <- as.list(x$edges[, -(1L:2L)])
6576
igraph::vertex_attr(out) <- as.list(x$nodes)
6677

@@ -74,10 +85,10 @@ as_igraph.proto_net <- function(x, ...) {
7485
}
7586

7687

77-
#' @rdname as_igraph
88+
#' @rdname as_tweet_igraph
7889
#'
7990
#' @export
80-
as_igraph.data.frame <- function(x, ...) {
81-
as_igraph(as_proto_net(x, ...))
91+
as_tweet_igraph.data.frame <- function(x, ...) {
92+
as_tweet_igraph(as_proto_net(x, ...))
8293
}
8394

0 commit comments

Comments
 (0)