I am in training on R and during cleaning the data.an error mentioned that database not found

############################
# Example analysis 1
############################

# install and load packages
pacman::p_load(rio, here, janitor, tidyverse,datapasta,reprex)

# import data
surv_raw <- import(here("data", "raw", "surveillance_linelist_20141201.csv"))
#> Error: No such file: C:/Users/or0267951/AppData/Local/Temp/Rtmp8oxBJz/reprex-53b442f246fd-piny-loon/data/raw/surveillance_linelist_20141201.csv

# clean the surveillance data
surv_clean <- surv_raw %>% 
  clean_names()
#> Error in eval(expr, envir, enclos): object 'surv_raw' not found

# make a horizontal bar plot of cases per district, filled by sex
ggplot(
  data = Surv_clean,
  mapping = aes(y = adm3_name_res, fill = sex))+
  geom_bar()
#> Error in eval(expr, envir, enclos): object 'Surv_clean' not found

demo_data <- surv_clean%>%
  head(10) %>%
  select(case_id,onset_date,sex)# keep only first 10 rows
#> Error in eval(expr, envir, enclos): object 'surv_clean' not found

dpasta(demo_data)
#> Error in eval(expr, envir, enclos): object 'demo_data' not found


list_demo<-data.frame(
  stringsAsFactors = FALSE,
  case_id = c("694928","86340d","92d002",
              "544bd1","6056ba","eb5aeb","e64e04","5a65bb","2ae019",
              "7ca4c0"),
  onset_date = c("11/9/2014","10/30/2014",
                 "8/16/2014","8/29/2014","10/20/2014","10/28/2014",
                 "10/6/2014","9/21/2014","5/6/2014","9/29/2014"),
  sex = c("m", "f", "f", "f", "f", "f", "f", "m", "m", "m")
)
sessionInfo()
#> R version 4.3.0 (2023-04-21 ucrt)
#> Platform: x86_64-w64-mingw32/x64 (64-bit)
#> Running under: Windows 10 x64 (build 19044)
#> 
#> Matrix products: default
#> 
#> 
#> locale:
#> [1] LC_COLLATE=English_United States.utf8 
#> [2] LC_CTYPE=English_United States.utf8   
#> [3] LC_MONETARY=English_United States.utf8
#> [4] LC_NUMERIC=C                          
#> [5] LC_TIME=English_United States.utf8    
#> 
#> time zone: America/Los_Angeles
#> tzcode source: internal
#> 
#> attached base packages:
#> [1] stats     graphics  grDevices utils     datasets  methods   base     
#> 
#> other attached packages:
#>  [1] reprex_2.1.0    datapasta_3.1.0 lubridate_1.9.3 forcats_1.0.0  
#>  [5] stringr_1.5.1   dplyr_1.1.4     purrr_1.0.2     readr_2.1.5    
#>  [9] tidyr_1.3.1     tibble_3.2.1    ggplot2_3.4.4   tidyverse_2.0.0
#> [13] janitor_2.2.0   here_1.0.1      rio_1.0.1      
#> 
#> loaded via a namespace (and not attached):
#>  [1] utf8_1.2.4        generics_0.1.3    stringi_1.8.3     hms_1.1.3        
#>  [5] digest_0.6.34     magrittr_2.0.3    evaluate_0.23     grid_4.3.0       
#>  [9] timechange_0.3.0  fastmap_1.1.1     R.oo_1.26.0       rprojroot_2.0.4  
#> [13] R.utils_2.12.3    fansi_1.0.6       scales_1.3.0      cli_3.6.2        
#> [17] rlang_1.1.3       R.methodsS3_1.8.2 munsell_0.5.0     withr_3.0.0      
#> [21] yaml_2.3.8        tools_4.3.0       tzdb_0.4.0        colorspace_2.1-0 
#> [25] pacman_0.5.1      vctrs_0.6.5       R6_2.5.1          lifecycle_1.0.4  
#> [29] snakecase_0.11.1  fs_1.6.3          pkgconfig_2.0.3   pillar_1.9.0     
#> [33] gtable_0.3.4      glue_1.7.0        xfun_0.41         tidyselect_1.2.0 
#> [37] rstudioapi_0.15.0 knitr_1.45        htmltools_0.5.7   rmarkdown_2.25   
#> [41] compiler_4.3.0

Hi,

Based on the output I see, your file surveillance_linelist_20141201.csv does not exist in the folder created by the here() function. Are you using an RProject, based on the file path returned it doesn’t look that way. Can you verify the location of your data and make sure the file path created by here() matches that?

All the best,

Tim