简体   繁体   中英

write.table() error cannot open file permission denied in R

I'm trying to execute the following command in R to export a dataset as .txt to my current working directory (my Desktop):

write.table(grouped_dataset, "tidy_dataset.txt", row.names=FALSE)

But I'm getting the same result:

Error in file(file, ifelse(append, "a", "w")) :
  cannot open the connection
In addition: Warning message:
In file(file, ifelse(append, "a", "w")) :
   cannot open file 'tidy_dataset.txt': Permission denied

I have been searching all over StackOverflow as well as other forums but there's no answer to my problem, and it's being really frustrating. I specifically need to use "write.table()", and no other function.

Here's my sessionInfo() data:

R version 4.0.2 (2020-06-22)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 8.1 x64 (build 9600)

Matrix products: default

locale:
[1] LC_COLLATE=Spanish_Bolivarian Republic of Venezuela.1252  LC_CTYPE=Spanish_Bolivarian Republic of 
Venezuela.1252   
[3] LC_MONETARY=Spanish_Bolivarian Republic of Venezuela.1252 LC_NUMERIC=C                                             
[5] LC_TIME=Spanish_Bolivarian Republic of Venezuela.1252    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] forcats_0.5.0   stringr_1.4.0   dplyr_1.0.2     purrr_0.3.4     readr_1.3.1     tidyr_1.1.2     
tibble_3.0.3   
[8] ggplot2_3.3.2   tidyverse_1.3.0

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.5       cellranger_1.1.0 pillar_1.4.6     compiler_4.0.2   dbplyr_1.4.4     tools_4.0.2     
 [7] jsonlite_1.7.0   lubridate_1.7.9  lifecycle_0.2.0  gtable_0.3.0     pkgconfig_2.0.3  rlang_0.4.7     
[13] reprex_0.3.0     cli_2.0.2        DBI_1.1.0        rstudioapi_0.11  haven_2.3.1      withr_2.2.0     
[19] xml2_1.3.2       httr_1.4.2       fs_1.5.0         generics_0.0.2   vctrs_0.3.4      hms_0.5.3       
[25] grid_4.0.2       tidyselect_1.1.0 glue_1.4.2       R6_2.4.1         fansi_0.4.1      
readxl_1.3.1    
[31] modelr_0.1.8     blob_1.2.1       magrittr_1.5     backports_1.1.9  scales_1.1.1     
ellipsis_0.3.1  
[37] rvest_0.3.6      assertthat_0.2.1 colorspace_1.4-1 utf8_1.1.4       stringi_1.4.6    
munsell_0.5.0   
[43] broom_0.7.0      crayon_1.3.4

Thank you!

Solved it! The problem was my antivirus, Avast. Once I disabled it for a while I was able to write "tidy_dataset.txt" in my working directory without errors or warnings from the R script.

Hope this helps someone in the future.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM