Skip to content

Instantly share code, notes, and snippets.

@alpo-p
Created December 6, 2016 09:14
Show Gist options
  • Select an option

  • Save alpo-p/0be46db857b34e926ae4d67b0a0da706 to your computer and use it in GitHub Desktop.

Select an option

Save alpo-p/0be46db857b34e926ae4d67b0a0da706 to your computer and use it in GitHub Desktop.
R googlesheets api
library("googlesheets")
suppressPackageStartupMessages(library("dplyr"))
gs_auth() #authorizes through browser
#register the spreadsheet and the show it to be sure it worked
urlForWt <- "<<add url for google sheet>>"
test <- gs_url(urlForWt)
test
worktimes <- gs_read(testi, ws = 2) ##reading all the data in the worksheet
worktimes
#duration <- gsub(",", ".", worktimes$Duration) #fixing the numbers (replace , with .)
duration <- as.numeric(worktimes_$Duration) #making char to num
user <- worktimes_$User
uniqUsers <- unique(user)
durationSum <- 0
for(i in 1 : length(uniqUsers)) {
durationSum[i] <- sum(duration[user == uniqUsers[i]])
}
durationSum <- data.frame(v=durationSum, f=uniqUsers)
durationSum
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment