Created
December 6, 2016 09:14
-
-
Save alpo-p/0be46db857b34e926ae4d67b0a0da706 to your computer and use it in GitHub Desktop.
R googlesheets api
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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