• python
  • javascript
  • reactjs
  • sql
  • c#
  • java
Facebook Twitter Instagram
Devs Fixed
  • python
  • javascript
  • reactjs
  • sql
  • c#
  • java
Devs Fixed
Home ยป Resolved: Deal with occasional numeric(0) inside group_by()

Resolved: Deal with occasional numeric(0) inside group_by()

0
By Isaac Tonny on 16/06/2022 Issue
Share
Facebook Twitter LinkedIn

Question:

I have a dataset of ids, months and some metric x.
and would like to create new columns that are values of the 2nd and 4th months’ x of each customer. I tried the code below but it failed because for id == "a1", the 2nd month’s x is NA. (error: Input x_growth_start can’t be recycled to size 3.)
I realize what it actually returns when the value doesn’t exist is integer(0). Can I make the code run (say, by letting it return NA if integer(0))? I tried what was suggested here but it didn’t work Input `typ` can’t be recycled to size in R
Thanks in advance.

Answer:

You should use match(). It returns NA when no match is found.

If you have better answer, please add a comment about this, thank you!

dplyr r
Share. Facebook Twitter LinkedIn

Related Posts

Resolved: Convert function is not working with {fn } in SQL Server

24/03/2023

Resolved: Why reference in pointer array doesn’t have data?

24/03/2023

Resolved: EntityFramework creates/runs migrations using parameterless DataContext instance

24/03/2023

Leave A Reply

© 2023 DEVSFIX.COM

Type above and press Enter to search. Press Esc to cancel.