I try to run the following code:
library(checkLuhn)
library(gsheet)
data<-gsheet2tbl("https://docs.google.com/spreadsheets/d/145Wowgp6NXmcj-IqqKfZ-2B2aKwAOzZ1VuCjxAq7WeM/edit?usp=sharing")
df <- data.frame(Card = character(),
Active = character(),
issuer =character())
for (i in 1: nrow(data))
{
card <- data[i,2]
active <- checkLuhn(card)
issuer <- issuer(card)
df = rbind(df, data.frame(Card = card, Active = active, Issuer =issuer, stringsAsFactors = FALSE))
}
But it is showing the following error:
Error in data.frame(Card = card, Active = active, Issuer = issuer, stringsAsFactors = FALSE) :
arguments imply differing number of rows: 1, 0
Can anyone help me please?
The issue seems to be with
issuerwhich returns logicalFALSEif there is none or else return a two columntibble. We could check the output type and make changes-output
Or using the OP's code
-output