ivan-rivera / RedditExtractor

A minimalistic R wrapper for the Reddit API
GNU General Public License v3.0
89 stars 23 forks source link

Getting the Timestamp #4

Closed woodydeck closed 3 years ago

woodydeck commented 6 years ago

Is there a way to get the timestamp from get_reddit()? e.g. {"created_utc": 1543846575.0}

comm_date = format(as.Date(as.POSIXct(unlist(lapply(main.node, function(x){GetAttribute(x,"created_utc")})), origin="1970-01-01")),"%d-%m-%y"),

Edit: It seems it is converted. Is there a simple way to recover the Unix stamp?

woodydeck commented 6 years ago

I rebuilt and tried setting comm_date = to meta.node$created_utc, but the timestamps were all the same. The second effort produced the same result when I tried format(as.Date(as.POSIXct(unlist(lapply(main.node, function(x){GetAttribute(x,"created_utc")})), origin="1970-01-01")),"%Y-%m-%d %H:%M:%S")

I added the HMS to the timestamp, but they all returned as zeroes. The comments are sporadic, so I couldn't figure out the logic, but I will try again tomorrow.

woodydeck commented 6 years ago

I solved it: comm_date = unlist(lapply(main.node, function(x){GetAttribute(x,"created_utc")})),

Remove the formatting, and change the data type on line 41 to numeric().

woodydeck commented 5 years ago

Reopened and added a pull request.

paragemini commented 3 years ago

Hey, is this issue solved ? when I pull the data using the command

get_reddit( subreddit = "wallstreetbets",
                   cn_threshold = 1, page_threshold = 1, sort_by = "comments",
                   wait_time = 2)

it does not return timestamps

ivan-rivera commented 3 years ago

I've updated the package to version 3.0.0 so the interface and the outputs have changed, but I expose the parsed UTC date which you can convert back to a timestamp if needed.