1. Fixed single column matrix acccidentally being converted down to a vector. 2. Added feature keepHTMLTITLEtext #7
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
TheSystematicInvestor@gmail
[Pull request] SIT File: fundamental.data.r R function: fund.data
Michael Kapler,
The following are the
supporting
File: fundamental.data.r
R function: fund.data
PROBLEM #1
The situation exists that
When I run
outp <- fund.data31("AAOI", 20)
The following code is (eventually) executed,
Code
all.data[, colSums(nchar(trim(all.data))) > 0]
accidentally converts the single column matrix
( because only one column of information on the web page ) into a vector.
So next
fails with error
This is because, "vectors" do not have a "ncol" attribute
This is the fix
PROBLEM #2 ( RELATED TO PROBLEM #1 )
The situation exists that
When I run
When requesting only one quarter of information ( using n=1 )
again,
This Code
accidentally converts the single column matrix into a vector
It is tested by
Instead it is directly returned from the function by
as a vector ( but this should be a matrix )
This is the fix
ENHANCEMENT
One may want to capture the page title for reasons of
This is the enhancement
}
SIMPLE METHOD TO TEST
BELOW fund.data41 is actually fund.data function of
https://github.com/AndreMikulec/SIT/blob/hotfix/hotfix-vector_null_HTMLTitle/R/fundamental.data.r
AndreMikulec@0a14fea
library(SIT)
fund.data41 <- function
(
Symbol, # ticker
n=10, # number of periods
mode=c('quarterly','annual'), # periodicity
max.attempts=5, # maximum number of attempts to download before exiting
keepHTMLTITLEtext = FALSE # last row includes HTML TITLE text
)
{
all.data = c()
option.value = -1
if( len(grep('INDICATORS', txt, ignore.case = T)) == 0 ) {
cat('No Data Found for', Symbol, '\n')
return(all.data)
}
}
library(SIT)
BLUE: CONTROL ( NEVER DID 'NOT WORK' )
outp <- fund.data41("THM", 10 )
RED: A PROBLEM ( FIXED )
outp <- fund.data41("AAOI", 10)
NEVER A PROBLEM
outp <- fund.data41("THM", 2)
library(SIT)
BLUE: CONTROL ( NEVER DID 'NOT WORK' )
outp <- fund.data41("THM", 10, keepHTMLTITLEtext = TRUE)
RED: A PROBLEM ( FIXED )
outp <- fund.data41("AAOI", 10, keepHTMLTITLEtext = TRUE)
NEVER A PROBLEM
outp <- fund.data41("THM", 2, keepHTMLTITLEtext = TRUE)
A PROBLEM ( FIXED )
outp <- fund.data41("THM", 1, keepHTMLTITLEtext = TRUE)