Error when use nest() in a tibble

Hi there! I have a dataframe like this:

players<-data.frame(
  stringsAsFactors = FALSE,
          seat = c("Seat 1","Seat 2","Seat 3",
                   "Seat 4","Seat 5","Seat 6"),
       jugador = c("MSC1266","Cereghetti16",
                   "Trytopredict","klariti","P.H.F.17","FerzRu"),
         stack = c("1.90 ", "2.03 ", "2 ", "2.60 ", "1.52 ", "3.99 "),
      posicion = c("BU", "SB", "BB", "EP", "MP", "CO"),
          hand = c("218755078355","218755078355",
                   "218755078355","218755078355","218755078355",
                   "218755078355")

)

And I would like to nest it based in "hand" column, in order to have one row, with all the values of the column in one vector. But when i do that:

jugadores %>% nest(hand)

 # A tibble: 6 x 5
   seat   jugador      stack   posicion data            
   <chr>  <chr>        <chr>   <chr>    <list>          
 1 Seat 1 MSC1266      "1.90 " BU       <tibble [1 x 1]>
 2 Seat 2 Cereghetti16 "2.03 " SB       <tibble [1 x 1]>
 3 Seat 3 Trytopredict "2 "    BB       <tibble [1 x 1]>
 4 Seat 4 klariti      "2.60 " EP       <tibble [1 x 1]>
 5 Seat 5 P.H.F.17     "1.52 " MP       <tibble [1 x 1]>
 6 Seat 6 FerzRu       "3.99 " CO       <tibble [1 x 1]>
 Warning message:
 All elements of `...` must be named.
 Did you want `data = c(hand)`?

Please can you provide a sample table or data frame showing the structure of your intended result?

Hi @cereghetti, good to see you moving forward with this.

What you have done has worked correctly in so much as the hand column has been nested in to a list column for each seat. Incidentally, this is a warning, not an error, and the outcome has been guessed at, hence the nested hand column - try it with two hands, and you should get both hand numbers in the list column.

Are you perhaps going for

nest(players1, cols = -hand)

# A tibble: 1 x 2
  hand         cols            
  <chr>        <list>          
  218755078355 <tibble [6 x 4]>
1 Like

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.