1

I'm writing code which subsets from a dataframe a lot e.g. lots of dataframe_name$column_name and it's a pain to read and to write. Is there a way to tell R that I'm referencing dataframe_name so that I can just write column_name for each instance?

  • 1
    Please show a small reproducible example and expected output – akrun May 10 '21 at 00:10
  • 1
    If you want to avoid `$`, use `with` – akrun May 10 '21 at 00:14
  • 1
    It was surprisingly difficult to find the right terms to search for to find these probably duplicate questions. If they don't cover what you need, let us know the specific issue. – thelatemail May 10 '21 at 00:21
  • @thelatemail Yeah, the first one covers it - the answer I was looking for is ```attach```, and ```with``` is nice to know about as well. Thanks! – DisgruntledOne May 10 '21 at 00:45
  • 1
    @DisgruntledOne - i think it should be the other way around. Use `with` and not `attach`.- several reasons here in the answers: https://stackoverflow.com/questions/10067680/why-is-it-not-advisable-to-use-attach-in-r-and-what-should-i-use-instead – thelatemail May 10 '21 at 01:11

0 Answers0