I'm quite a beginner in R. I wrote a script that worked just fine. However, since yesterday, it just doesn't recognize my variables anymore. I can view the dataset, but can't do any analysis.
tba_hba <- read_excel(k.file)
tba_hba
AMT E0 M `X-Kto` S1 S2 S3 S4
<chr> <chr> <chr> <chr> <dbl> <dbl> <dbl> <dbl>
1 TBA D0 T248~ X1.2.1~ 1 2 1 0
2 TBA D0 T248~ X1.2.1~ 1 2 1 0
3 TBA D0 T248~ X0.3.1~ 0 3 1 0
4 TBA D0 T248~ X0.3.1~ 0 3 1 0
5 TBA D0 T248~ X0.3.1~ 0 3 1 0
6 TBA D0 T248~ X0.3.1~ 0 3 1 0
7 TBA D0 T248~ X0.3.1~ 0 3 1 0
8 TBA D0 T248~ X0.3.1~ 0 3 1 0
count(tba_hba, S1)
Error in count(tba_hba, S1) : object 'S1' not found
I can see the variable S1, but can't do a count on it.
I get the same error when using read.xlsx.
Any ideas why this happens since yesterday without changing anything on my data?
EDIT: This are my data:
structure(list(AMT = c("TBA", "TBA", "TBA", "TBA", "TBA", "TBA",
"TBA", "TBA", "TBA", "TBA", "TBA", "TBA", "TBA", "TBA", "TBA"
), E0 = c("D0", "D0", "D0", "D0", "D0", "D0", "D0", "D0", "D0",
"D0", "D0", "D0", "D0", "D0", "D0"), M = c("T248A15", "T248A15",
"T248A15", "T248A15", "T248A15", "T248A15", "T248A15", "T248A15",
"T248A15", "T248A15", "T248A15", "T248A15", "T248A15", "T248A15",
"T248A15"), S1 = c(1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0,
0), S2 = c(2, 2, 3, 3, 3, 3, 3, 3, 3, 2, 2, 3, 3, 3, 3), S3 = c(1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1), S4 = c(0, 0, 0, 0,
0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0), Projekt = c("Y02.9.8.1", "Y02.9.8.1",
"Y34.6.1.2", "Y01.6.1.1", "Y01.6.1.1", "Y05.6.1.1", "Y04.6.1.1",
"Y04.6.1.1", "Y05.6.1.1", "Y21.9.8.1", "Y23.9.8.1", "Y05.6.1.1",
"Y03.6.1.1", "Y03.6.1.1", "Y05.6.1.1")), row.names = c(NA, -15L
), class = c("tbl_df", "tbl", "data.frame"))
count(tba_hba, tba_hba$S1). Based on the code you provided, it looks like you haven't assignedk.filea value. So before you read in your Excel file, you need to specify:k.file <- "C:/filepath/file.xlsx"[using an object of class quoted. This also doen't work.#jährlich anzupassende Jahreszahlk.jahr = 2019#dynamischer Dateinamek.file = paste("Rohdaten-TBA-HBA-",k.jahr,"_orig.xlsx", sep="")k.file#Datei einlesensetwd(file.path("P:/2_Statistikproduktion/SUBMISS/01 Bezogene Daten/Kreko", k.jahr))tba_hba <- read_excel(k.file)tba_hbaIn read_fun(path = enc2native(normalizePath(path)), sheet_i = sheet, ... : Coercing text to numeric in W1583 / R1583C23: '8590'dput(head(data)).> ls()[1] "k.file" "tba_hba"> str(tba_hba)Classes ‘tbl_df’, ‘tbl’ and 'data.frame': 15 obs. of 8 variables:$ AMT : chr "TBA" "TBA" "TBA" "TBA" …$ E0 : chr "D0" "D0" "D0" "D0" …$ M : chr "T248A15" "T248A15" "T248A15" "T248A15" …$ S1 : num 1 1 0 0 0 0 0 0 0 1 …$ S2 : num 2 2 3 3 3 3 3 3 3 2 …$ S3 : num 1 1 1 1 1 1 1 1 1 1 …$ S4 : num 0 0 0 0 0 0 0 0 0 1 …$ Projekt: chr "Y02.9.8.1" "Y02.9.8.1" "Y34.6.1.2" "Y01.6.1.1" …