Hello,
When I run a query for datatype WC07015 in a snapshot request (in R) the value it gives me is a character value of numbers that I cannot translate into a date. This data type is supposed to be the day that a company was delisted. How do I convert this value into a date?
sf <- dsws$snapshotRequest(instrument = c("A:EVMX", "A:CBAX"), datatype = c("ISIN", "NAME", "WC07015"), requestDate = "0D")
Running this gives me these outputs:
However if I run the query without the CBA company ticker I get the result I'd expect like this:
Can someone please help me understand why it is doing this, and let me know how to get it to give me a proper date when I run more than one company query.
Thanks,
Ed.
The column type of WC07015 is converted to <chr> when requesting two items c("A:EVMX", "A:CBAX") because the WC07015 of A:CBAX is "NA".
The workaround is checking if the column of WC07015 is a date, or not.
If it is not date, first you need to remove the "NA" values and then convert the numeric values to date.
The example code is:
sf <- mydsws$snapshotRequest(instrument = c("A:EVMX", "A:CBAX"), datatype = c("ISIN", "NAME", "WC07015"), requestDate = "0D") if("FALSE"%in%sapply(sf$WC07015, function(x) !all(is.na(as.Date(as.character(x),format="%Y-%m-%d"))))){ sf[sf == "NA"] <- "" sf <- mutate(sf, WC07015= as.Date(as.numeric(WC07015), origin= "1970-1-1")) } sf
This code may not cover all use cases.
Otherwise, you may report this issue at DatastreamDSWS2R GitHub.