Category "tidyverse"

A better way to write dplyr pipes? (without using dollar sign) [closed]

Quite often when using the tidyverse to manipulate data, I come up with a situation like the one below. Can someone explain why option 3 works

tidyverse: data transformation, gather()

I am trying to transform a dataset: [1]: https://i.stack.imgur.com/09Ioo.png To something like this: [2]: https://i.stack.imgur.com/vKKu2.png How can I do this

Conditional mutate - creating a new variable with coalesce

I'm scraping data from a website and depending on the structure of the page. I have an inner join in my final table that either joins clean on WON and LOST vari

What are the differences between R's new native pipe `|>` and the magrittr pipe `%>%`?

In R 4.1 a native pipe operator was introduced that is "more streamlined" than previous implementations. I already noticed one difference between the native |&g

Multi-level list to data frame in R

I'd like to convert the below list to a data frame but I'm failing at doing it. The list is taken from Microsoft Azure's API listing all resource types with tec

R Dataframe By Group Calculation

I have a dataframe like below (the real data has many more people and club): Year Player Club 2005 Phelan Chicago Fire 2007 Phelan Boston Pant 2

How to left_join() two datasets but only select specific columns from one of the datasets?

Here are two datasets: (this is fake data) library(tidyverse) myfruit <- tibble(fruit_name = c("apple", "pear", "banana", "cherry"), number

How to look at differences between 2 columns in R

I just need to write some code that will look at the difference between the "est_age" and "known_age" columns in my data set. Then I need to know what percenta

R how to group part of overlapped values among rows?

I have a data frame that some rows that need to be further grouped by some of the overlapped values among rows col1, col2 a1, 2;3 a2, 2 a3, 3;4 a4, 4 a

Can I bound an st_distance call by a polygon?

I have seen similar posts on this topic (see, for example, here and here) but not one that is specific to the sf-tidyverse ecosystem. I have a series of lakes,

combine rows in data frame containing NA to make complete row

I know this is a duplicate Q but I can't seem to find the post again Using the following data df <- data.frame(A=c(1,1,2,2),B=c(NA,2,NA,4),C=c(3,NA,NA,5),D