I have a large vector of strings such as "SALE" and "BRK" and hope to make a histogram of them and other plots. Ideally, I hope to assign "SALE" to the value 1 and so forth. I made an empty vector for the number affiliations.
LicenseType=TexasData$License.Type
LicenseType=LicenseType[!TexasData$County.Code==0]
LicenseTypeNumber=integer(length = length(LicenseType))
dput(LicenseType)
for (i in LicenseType) {
if(i=="SALE")
LicenseTypeNumber(i)=1
if(i=="BRK")
LicenseTypeNumber(i)=2
if(i=="BLLC")
LicenseTypeNumber(i)=3
if(i=="BCRP")
LicenseTypeNumber(i)=4
if(i=="6")
LicenseTypeNumber(i)=6
}
hist(LicenseType)
I get the error "Error in if (i == "SALE") i = 1 : missing value where TRUE/FALSE needed" What am I doing wrong?
Dput Output: "SALE", "SALE", "BRK", "SALE", "SALE", "SALE", "SALE", "SALE", "SALE", "SALE", "SALE", "SALE", "SALE", "SALE", "SALE", "SALE", "SALE", "SALE", "SALE", "SALE", "SALE", "SALE", "SALE", "SALE", "SALE", "SALE", "SALE", "SALE", "SALE", "SALE", "SALE", "SALE", "SALE", "SALE", "SALE", "SALE", "SALE", "SALE", "SALE", "SALE", "SALE", "SALE", "SALE", "SALE", "SALE", "SALE", "SALE", "SALE", "SALE", "SALE", "SALE", "BLLC", "SALE", "SALE", "BCRP", "BCRP", "SALE", "SALE", "SALE", "SALE", "SALE", "BRK", "BLLC", "SALE", "SALE", "BCRP", "SALE", "SALE", "SALE", "SALE", "SALE", "BRK", "SALE", "SALE", "SALE", "SALE", "SALE", "SALE", "BRK", "SALE", "SALE", "SALE", "SALE", "SALE", "SALE", "SALE", "BRK", "SALE",
Aucun commentaire:
Enregistrer un commentaire