git2r icon indicating copy to clipboard operation
git2r copied to clipboard

Add vignette

Open stewid opened this issue 11 years ago • 15 comments

Add vignette with examples and use cases

stewid avatar Mar 31 '14 20:03 stewid

Do you want the vignette in sweave or knitr?

trosendal avatar Apr 01 '14 13:04 trosendal

@karthik what do you think is the best strategy?

stewid avatar Apr 01 '14 16:04 stewid

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

karthik avatar Apr 01 '14 16:04 karthik

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

stewid avatar Apr 11 '14 15:04 stewid

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

sckott avatar Apr 11 '14 15:04 sckott

The figure makes the difference :)

stewid avatar Apr 11 '14 15:04 stewid

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

karthik avatar Apr 11 '14 17:04 karthik

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())

stewid avatar Apr 11 '14 21:04 stewid

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

karthik avatar Apr 11 '14 21:04 karthik

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

karthik avatar Apr 11 '14 21:04 karthik

Your punch card looks slick! image

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

karthik avatar Apr 11 '14 21:04 karthik

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

stewid avatar Apr 11 '14 21:04 stewid

looks great

sckott avatar Apr 11 '14 22:04 sckott

Added method punch_card to package.

stewid avatar Apr 12 '14 12:04 stewid

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.

petermeissner avatar Jul 15 '16 08:07 petermeissner