I want to get values from an excel file, and assign certain values of them to arrays. At the beginning I tried the code below, and it worked. But after restarting r studio, and did everything again, it shows me this error
Error in USComp2005_2000_3000[m] = USComp2005$SIC[i] : object 'USComp2005_2000_3000' not found
I don't know how it worked in the beginning!
library(readxl)
USComp2005 <- read_excel("USCompanies2005.xlsx",sheet = "Data")
getValues <- function()
{
n=0
m=0
for (i in 1:6992) {
if ((USComp2005$SIC[i] >= 6000) && (USComp2005$SIC[i] < 7000)) {
n=n+1
USComp2005_6000[n] = USComp2005$SIC[i]
}
else if ((USComp2005$SIC[i] >= 2000) && (USComp2005$SIC[i] < 4000)) {
m=m+1
USComp2005_2000_3000[m] = USComp2005$SIC[i]
}
}
}