ropensci / git2r

R bindings to the libgit2 library
https://docs.ropensci.org/git2r
GNU General Public License v2.0
216 stars 58 forks source link

Add vignette #19

Open stewid opened 10 years ago

stewid commented 10 years ago

Add vignette with examples and use cases

trosendal commented 10 years ago

Do you want the vignette in sweave or knitr?

stewid commented 10 years ago

@karthik what do you think is the best strategy?

karthik commented 10 years ago

Sorry, meant to reply earlier. I think we should go with knitr and not sweave. I'll add an example shortly.

stewid commented 10 years ago

@sckott I think your git2r_post (https://gist.github.com/sckott/10473818) is a great example to have in the vignette. Is that ok?

sckott commented 10 years ago

Sounds good, And the code was originally from you - i just added the figure :) It's updated with the Sara Varela gsub.

stewid commented 10 years ago

The figure makes the difference :)

karthik commented 10 years ago

Nice, we should definitely include it as a use case! @stewid Just getting my head back above water. No more deadlines in the near future. Dives back into code. Crosses fingers

stewid commented 10 years ago

I sketched on some code to create a punch card graph

library(git2r)
library(ggplot2)

## repo <- repository("path/to/git2r")

## Extract information from repository
df <- as(repo, "data.frame")
df$when <- as.POSIXlt(df$when)
df$hour <- df$when$hour
df$weekday <- df$when$wday

## Create an index and tabulate
df$index <- paste0(df$weekday, "-", df$hour)
df <- as.data.frame(table(df$index), stringsAsFactors=FALSE)
names(df) <- c("index", "Commits")

## Convert index to weekday and hour
df$Weekday <- sapply(strsplit(df$index, "-"), "[", 1)
df$Weekday <- factor(df$Weekday,
                     levels = c(6, 5, 4, 3, 2, 1, 0),
                     labels = c("Saturday", "Friday", "Thursday",
                         "Wednesday", "Tuesday", "Monday", "Sunday"))
df$Hour <- as.integer(sapply(strsplit(df$index, "-"), "[", 2))

ggplot(df, aes(x = Hour, y = Weekday, size = Commits)) +
    geom_point() +
    scale_x_continuous(breaks = 0:23, limits = c(0, 23)) +
    scale_y_discrete(labels = levels(df$Weekday)) +
    theme(axis.title.x = element_blank(),
          axis.title.y = element_blank())
karthik commented 10 years ago

Looks great. I've started work on replicating the commit graph from the main profile page as well.

karthik commented 10 years ago

I'll post that this weekend once I get it working correctly.

karthik commented 10 years ago

Your punch card looks slick! image

We can extract the repo name too and add to the title.

stewid commented 10 years ago

Thanks. Great idea with title. Should we include it as a method punch_card?

sckott commented 10 years ago

looks great

stewid commented 10 years ago

Added method punch_card to package.

petermeissner commented 8 years ago

Hey, I just wanted to state, that I was surprised to find this package without any vignette on CRAN - I suggest simply re-using the current README on Github as a simple introduction vignette.