0

I am trying to read text files, but get an error

read.table(file = "body_acc_x_train", header = TRUE, sep = "")

Error:
Error in file(file, "rt") : cannot open the connection
In addition: Warning message:
In file(file, "rt") :
  cannot open file 'Inertial Signals': No such file or directory
David Arenburg
  • 91,361
  • 17
  • 137
  • 196
  • Can you try with the full path of the file (something like `/home/user/.../body_acc_x_train`), and confirdm it doesn't have an extension. If this works check which folder R thinks it is in? The `getwd()` command gives this info. – bdecaf Sep 06 '20 at 08:21
  • Welcome to Stack Overflow! Please take the [tour] and read through the [help center](http://stackoverflow.com/help), in particular how to [ask]. Your best bet here is to do your research, search for related topics on SO, and give it a go. After doing more research and searching, post a [Minimal, Complete, and Verifiable example](https://stackoverflow.com/help/mcve) of your attempt and say specifically where you're stuck, which can help you get better answers. – help-info.de Sep 06 '20 at 08:48

1 Answers1

0

Use setwd for a working directory in your environment and set the parameters according to your data correctly e.g.:

# --- set working directory ----
setwd("D:/Data/R-Studio/develop/data-develop/maps")

gauge.data <- read.table("gauge-WSP.txt", header=TRUE, 
                         sep="\t", na.strings="NA", dec=".", strip.white=TRUE,
                         stringsAsFactors = FALSE)
gauge.data

The gauge data here are separated with tabs and have some NA's as an example.

If you meant with your question "import some files simultaneously rather than having to import them all individually" have alook at How to import multiple .csv files at once?.

This assumes that you have your files in a single directory - the current working directory - (see above) and that all of them have an extension.

help-info.de
  • 6,695
  • 16
  • 39
  • 41