Value goes missing when pivoting table

I am trying to pivot a table from long to wide but it would appear that some of the values go missing when I try to pivot the table. The original data frame looks like this (with a new id, the same dates repeat themselves all over again):
image

This table has a data frame dimension of 1520 times 4. Below is the code that I used to pivot the table:

SecurityPrice_1 <- SecurityPrice_1 %>% rename(Ticker_name = Id)

SecurityPrice_1<- spread(SecurityPrice_1, Ticker_name, p_price)

It now only has a dimension of 80 times 21, which is a lot smaller and makes no sense whatsoever. I can only show one picture because I am a new user but essentially all the duplicated dates from the previous table get deleted. Is there a way that I can simply preserve all the dates and still count all the values while using spread? Can someone please help me out? It would be greatly appreciated!

Hello,
I'm sure you shared this image with the best intentions, but perhaps you didnt realise what it implies.
If someone wished to use example data to test code against, they would type it out from your screenshot...

This is very unlikely to happen, and so it reduces the likelihood you will receive the help you desire.
Therefore please see this guide on how to reprex data. Key to this is use of either datapasta, or dput() to share your data as code

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.