Forum Discussion
R script error when exporting data
Hey Anonymous,
Looks like that trim function doesn't exist. Try the following, it uses the "stringr" package:
library(stringr) # Write.csv (dataset.file = "PowerBIExport.csv") "Write.table (str_trim (dataset), file ="C: /Users/vitor.oliveira/Desktop/teste.txt ", sep =" \ t ", row.names = FALSE)
Hope this helps,
Alan
Now the following error is occurring, I have installed all the packages referring to the Write function, but the ero still persists
Error Message:
R. Script Error
Error: could not find function "Write.table"
Execution stopped
- alanhodgson9 years ago
Solution Supplier
Anonymous
The write.table function is in the utils package and usually is installed by default. Possible you are missing the library(utils) statement before you write the table. I don't know if it is nessecary, but it doesn't hurt to try.
Let me know if the error persists.
library(stringr) library(utils) # Write.csv (dataset.file = "PowerBIExport.csv") Write.table (str_trim (dataset), file ="C: /Users/vitor.oliveira/Desktop/teste.txt ", sep =" \ t ", row.names = FALSE)
- Anonymous9 years agoNot applicable
I tried but the same error is still occurring
I did a test with the direct script in r studio and the error log is the same
- alanhodgson9 years ago
Solution Supplier
Anonymous
Interesting...
Well lets start from the basics. Can you post the output of these 2 commands in RStudio console:
- sessionInfo()
- packageversion("utils")
This is mine:
> sessionInfo()R version 3.3.1 (2016-06-21) Platform: x86_64-w64-mingw32/x64 (64-bit) Running under: Windows 7 x64 (build 7601) Service Pack 1 locale: [1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United States.1252 [3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C [5] LC_TIME=English_United States.1252 attached base packages: [1] stats graphics grDevices utils datasets methods base other attached packages: [1] readxl_0.1.1 stringr_1.0.0 RevoUtilsMath_8.0.3 loaded via a namespace (and not attached): [1] magrittr_1.5 RevoUtils_10.0.1 tools_3.3.1 Rcpp_0.12.5 stringi_1.1.1 > packageVersion("utils")[1] ‘3.3.1’