0

I'm new to R so please don't blast me.

I've downloaded a dataset file from the web, and i correctly imported it using the read.table() function.

Auto = read.table("Path")

Now, if i run the ls() function i correctly see Auto in the user environment.

If i want to accede the dataset's columns as variables, i have to first attach the dataset, using for example the function attach("Package_path").

Is this necessity due to the function read.table() which creates a new and separate environment every time we import a dataset ? What i think is that the dataset's variables are already present after the using of read.table() , the only thing is that are not attached to user environment yet...

Koinos
  • 151
  • 3
  • 14
  • 9
    DO NOT USE attach, this is a really bad practice, if you want to use a variable from Auto, use something like `Auto$V1` – TC Zhang Jul 26 '18 at 06:08
  • Which are the differences from attach ? – Koinos Jul 26 '18 at 06:08
  • `attach` adds a database (a list, a data.frame like your Auto) to search path, This means that the database is searched when evaluating a variable, so objects in the database can be accessed by simply giving their names. – TC Zhang Jul 26 '18 at 06:12
  • 3
    I suggest you read [Why is it not advisable to use attach() in R, and what should I use instead?](https://stackoverflow.com/questions/10067680/why-is-it-not-advisable-to-use-attach-in-r-and-what-should-i-use-instead#10067681). – Rui Barradas Jul 26 '18 at 06:19
  • 4
    Possible duplicate of [Why is it not advisable to use attach() in R, and what should I use instead?](https://stackoverflow.com/questions/10067680/why-is-it-not-advisable-to-use-attach-in-r-and-what-should-i-use-instead) – Marius Jul 26 '18 at 06:34

0 Answers0