library(DatastreamR) # Login using Configuration timeseriesClient = TimeSeriesClient$new('Config.ini') if (!is.null(timeseriesClient) & timeseriesClient$IsValid()) { tryCatch({ print('Requesting all timeseries available for your datastream ID.') itemsResp = timeseriesClient$GetAllItems() if (!is.null(itemsResp)) { if (itemsResp$ResponseStatus != DSUserObjectResponseStatus$UserObjectSuccess) { print(paste('GetAllItems failed with error', names(DSUserObjectResponseStatus)[itemsResp$ResponseStatus+1], itemsResp$ErrorMessage)) } else if ((is.null(itemsResp$UserObjects)) | (itemsResp$UserObjectsCount == 0)) print(paste('GetAllItems returned zero timeseries items.', '\n\n')) else { print(paste('GetAllItems returned ', itemsResp$UserObjectsCount, ' timeseries items.')) colnames = c('Id','LastModified', 'startDate', 'endDate','Frequency', 'NoOfValues', 'Desc') df = data.frame() for (tsItem in itemsResp$UserObjects) { coldata = NULL if (!is.null(tsItem)) { rowdata = c (Id = tsItem$Id, Desc = tsItem$Description, LastModified = as.character(tsItem$LastModified), StartDate = ifelse (!is.null(tsItem$DateInfo), as.character(tsItem$DateInfo$StartDate), NULL), EndDate = ifelse(!is.null(tsItem$DateInfo),as.character(tsItem$DateInfo$EndDate), NULL), Frequency = ifelse(!is.null(tsItem$DateInfo), tsItem$DateInfo$Frequency, NULL), NoOfValues = ifelse(!is.null(tsItem$DateRange), tsItem$DateRange$ValuesCount , 0)) df = rbind(df, rowdata) } } colnames(df) = colnames print(df) } } }, error = function(e) { print(paste('TimeseriesClient request failed with error message:', message(e))) stop(message(e)) }) }