Skip to content

Instantly share code, notes, and snippets.

View kleinlennart's full-sized avatar
💭
Busy reading your mind...

Lennart Klein kleinlennart

💭
Busy reading your mind...
View GitHub Profile
@kleinlennart
kleinlennart / zotero_remove_eprint_extra.ipynb
Created May 26, 2024 17:56
zotero_remove_eprint_extra.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@kleinlennart
kleinlennart / .quartoignore
Created January 16, 2024 15:25
.quartoignore Recommended Defaults for Quarto Extensions
template.Rproj
template.html
*_files/
*_cache/

Lennart's Dotfiles

GitHub Gist last commit

@kleinlennart
kleinlennart / .Rprofile
Last active January 29, 2024 09:23
.Rprofile
if (interactive()) {
suppressMessages(require(usethis))
}
if (interactive()) {
suppressMessages(require(devtools))
}
if (interactive()) {
suppressMessages(require(cput))
@kleinlennart
kleinlennart / markdown.md
Created February 17, 2021 19:10
Markdown Snippets
expand stuff
@kleinlennart
kleinlennart / sorting.R
Last active January 27, 2021 20:50
R Sort Columns alphabetically
# Sort all columns alphabetically
dat <- dat[,order(colnames(dat))]
dat <- dat %>% select(sort(current_vars())) # Alternatively
# Reorder each column alphabetically
dat <- map_df(dat, function(x) {sort(x, na.last = TRUE)})
@kleinlennart
kleinlennart / tweet_count.R
Created November 12, 2020 21:08
Add Total Tweet Count per User to twitter dataset, user aggregation level
add_tweet_count <- function(dat) {
return(
dat %>%
group_by(user_id) %>%
mutate(
tweet_count = n()
) %>%
ungroup() # to remove grouped_df class
)
}
@kleinlennart
kleinlennart / hashtags.R
Created November 12, 2020 20:33
Extract hashtags from tweets
# clean Hashtag extraction method
## evtl. noch Umlaute entfernen!
add_hashtags <- function(dat) {
return(
dat %>%
mutate(
hashtags = text %>% tolower() %>% str_extract_all("#[[:alnum:]_]+")
)
)
@kleinlennart
kleinlennart / unlist_col.R
Created October 25, 2020 15:47
Unlist a column rowwise
dat <- dat %>%
rowwise() %>%
mutate(bundesland = unlist(bundesland),
community = unlist(community),
fach = unlist(fach)) %>%
ungroup() # important to remove rowwise_df class! (slows down all other operations)