Quantcast
Channel: Active questions tagged r - Stack Overflow
Viewing all articles
Browse latest Browse all 201945

I wish to keep/discard items in a PURRR nested list based on a sublist within each grouped level

$
0
0

I have sets of weather station data which I wish to compare by site. I need to do this efficiently because each set is large and I wish to build my experience with PURRR. My issue concerns use of the keep/discard (or list.exclude (rlist)) to remove days (id) with incomplete data - it should be a doozy but I can't get the syntax right. I have tried to approach this problem by computing the dimensions of each tibble, and then use the length to give me a unitary list). I am using R 3.6.1 on a PC running Windows 10. Here is a trivial example. I wish 'mylist' to comprise id = 'a' only in this example.

mylist <- tibble(id = c(rep("a",5),rep("b",4)),
                 dl = c(seq(1,5,1), seq(1,4,1)),
                 v = c(seq(0, 40, 10), seq(50, 80, 10))) %>%
  group_by(id) %>%
  nest() %>%
  mutate(ddim = map(data, dim)) %>%
  mutate(nn = map(ddim, extract(1)))
mylist
# A tibble: 2 x 4
# Groups:   id [2]
  id              data ddim      nn       
  <chr> <list<df[,2]>> <list>    <list>   
1 a            [5 x 2] <int [2]> <int [1]>
2 b            [4 x 2] <int [2]> <int [1]>

Viewing all articles
Browse latest Browse all 201945

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>