Skip to content

Some introductory questions

10 messages · Mike Feher, David Winsemius, Ken Beath +3 more

#
Greetings,

As I?m getting familiar with R, I have some basic questions that I thought
of to shoot to useRs:

1. When looking up library functions, symbols, objects, etc., is there a
Google-style ?global search? capability for all that is available with my
installation?  Or is it just all accessible via navigating the help() tree?
2. Are these objects, etc. stored on disk somewhere, or are they only
accessible via the interfaces?  For example, I would be interested to see
the source code for the demo examples to learn how to do certain things, if
this is possible.  (It appeared as if the code for each demo that is
executed as part of the ?demo()? command displayed in my R console, but I
just want to be sure about this.)
3. How does one restore a saved session automatically?  Is that saved in a
file or files anywhere on the local filesystem?
4. I tried to read in a set of dummy space-delimited data saved in an
absolute path on my computer, but it would not work.  I tried something in
another path that did not have a subfolder with a space in it (I.e. I plan
on storing my data in a folder called ?R Documents? or something similar)
and that didn?t work either, so I?m still wondering whether or not (a)
things have to be in the library location (it seems like you could
customize that) and (b) whether R recognizes spaces in file paths.

Please keep in mind that I am consulting the documentation first, but maybe
not doing a global Google search for examples of these things.  I?m trying
to remember to do both as I go along, so as not to bother everyone.

Regards and thanks in advance,
Mike
#
You should review the ListInfo material. Most of these questions have nothing to do with the Mac version of R.
You should be trying help.search() or it's shortcut `??`
Not sure what you are considering "interfaces". Pretty much everything is on disk.
They are generally automagically reloaded if you exited in a manner that saved them and restart from the same directory. The state of the previous session is stored in a special .Rdata file which is invisible to Macs and Windoze machines by default. You need to modify your system file manage to see them. Read about .Rdata files and how to use them.
Sadder words were never written, but most of the sadness derives from the failure to efficiently communicate what "it" actually was.
R does recognize space on a Mac. You need to provide actual code. I cannot intuit what errors you are making from this description.
Well you are not reading the documentation for this list (or any of the several R-project list) since you are posting in HTML.

Hth;
David.
#
How to find the demo files is contained in the demo help. Type ?demo
Try using file.choose() to locate files using a dialog and it will return the full name. Spaces shouldn?t matter provided that everything is enclosed in quotes. Most people don?t use absolute references. They set the working directory and then just use the name of the file. See under the Misc menu. 

Ken
#
[snip]
Also, how do you "read in" the data? Usually, read.table() or somesuch would be involved, although RStudio has an "Import data" functionality. 

-pd
#
Great, thank you.  I was following along the tutorial session provided in
the official documentation and I could not make sense of how they were
opening the Michelson-Morely experimental data.  It seemed as if they were
forcing the source file to be read in from some library location, where in
all likelihood, users would prefer to make custom locations.  I will check
into both of your suggestions.  I appreciate the help!

Mike
On September 7, 2020 at 1:11:13 AM, Ken Beath (ken at kjbeath.com.au) wrote:

            
if
How to find the demo files is contained in the demo help. Type ?demo
plan
Try using file.choose() to locate files using a dialog and it will return
the full name. Spaces shouldn?t matter provided that everything is enclosed
in quotes. Most people don?t use absolute references. They set the working
directory and then just use the name of the file. See under the Misc menu.

Ken
#
Hi Peter,

Here is a snippet of the code I was trying to start with:

filepath1 <- file("/Users/michaelfeher/Documents/R
Documents/COVID19/20200906-1822-total-cases-jones.data")
filepath1
TotalCasesJones <- read.table(filepath1)

This definitely did not work for me.

Mike
On September 7, 2020 at 3:50:19 AM, peter dalgaard (pdalgd at gmail.com) wrote:

            
[snip]
in
plan
similar)
the full name. Spaces shouldn?t matter provided that everything is enclosed
in quotes. Most people don?t use absolute references. They set the working
directory and then just use the name of the file. See under the Misc menu.

Also, how do you "read in" the data? Usually, read.table() or somesuch
would be involved, although RStudio has an "Import data" functionality.

-pd
#
Mike,

There are probably a couple of issues here to think about:

1. Do you have reason to think this is a Mac specific issue?? If not
?? this is likely not the right mailing list.? Perhaps r-help might be
?? better, although I do think you will find more people willing to
?? pitch in on Stackoverflow (but avoid cross-posting, so since you
?? have already posted here you might need to hope someone is willing
?? to provide you an answer).

2. The reason you are getting the reactions you are in this thread
?? (apart from the mac-specific issue) is that there is not enough
?? information for others to debug your problems.? E.g.? what does the
?? file look like, in what way does it "definitely not work"?.? Do you
?? get an error?? Or do you import something that doesn't look like
?? what you expected?? These are all things that are needed by anyone
?? that will want to help you, and it frustrates some that you are not
?? providing them of your own initiative.

If I were in your shoes I would try my luck on stackoverflow, or
alternatively, read through several threads on R-help to figure out
how the Q/A process works there and ask questions in ways that are
likely to elicit answers.? This is not easy to do and take some work
to figure out, but when asking for folks time to help you it is a good
idea to try to do some home work ahead of time.

I speak only for myself, and sincerely hope this non-answer is helpful
to you even if it doesn't actually address your questions.

Best,

Brodie.
#
Hi Brodie,

Thanks for your suggestions, I definitely appreciate it.

Yes, I realize these aren?t Mac-specific questions, so forgive a new member
the mistake of accidentally posting to the wrong listserv.  I realized that
after the fact, but there it is.

I think I discovered two problems today that I got worked out.  The first
was a permissions problem that is macOS-specific: I installed XQuartz, and
inside my xterms, I was unable even execute simple commands such as ?ls?.
Google to the rescue.  After that, I got the permissions sorted out, and
those commands worked just fine.  I suspect because I couldn?t even do
things like that, that that?s why I was getting (IIRC) ?Operation not
permitted? errors *inside of R* trying to open a file.  Being new to it, it
appeared to me that R was the cause of my problem.  Once I got that sorted
out, it was no issue.

The second problem was figuring out which file operation method to use.
 file.choose() worked for me, and it was quite easy to wrap this with a
read.table(), so that was a nice bit of learning.  (The CLI did not permit
me to do anything other than type in a fully-qualified path to my data
files, but in R.app, it nicely opened up a file selection dialog, about
which I was very pleased.)

One of the reasons I didn?t initially provide a lot of supplementary
information was that I figured if anyone had any suggestions based on what
the problem sounded like, they might have vectored me in the right
direction.  Typically I provide a lot of detail up front but that ends up
getting lost on people, so I?ve learned to start general and then if
they?re willing to be helpful, I?ll gladly supply the info.

I hadn?t thought of Stack Overflow, but based on the initial reax here, I
started Googling other sites that might provide more useful examples
without the backtalk.  Thirty years on the Internet and some things never
change. ;)

Thank you again!
Mike


On September 7, 2020 at 10:04:29 PM, brodie gaslam (brodie.gaslam at yahoo.com)
wrote:
mfeher1971 at gmail.com> wrote:
Mike,

There are probably a couple of issues here to think about:

1. Do you have reason to think this is a Mac specific issue?  If not
   this is likely not the right mailing list.  Perhaps r-help might be
   better, although I do think you will find more people willing to
   pitch in on Stackoverflow (but avoid cross-posting, so since you
   have already posted here you might need to hope someone is willing
   to provide you an answer).

2. The reason you are getting the reactions you are in this thread
   (apart from the mac-specific issue) is that there is not enough
   information for others to debug your problems.  E.g.  what does the
   file look like, in what way does it "definitely not work"?.  Do you
   get an error?  Or do you import something that doesn't look like
   what you expected?  These are all things that are needed by anyone
   that will want to help you, and it frustrates some that you are not
   providing them of your own initiative.

If I were in your shoes I would try my luck on stackoverflow, or
alternatively, read through several threads on R-help to figure out
how the Q/A process works there and ask questions in ways that are
likely to elicit answers.  This is not easy to do and take some work
to figure out, but when asking for folks time to help you it is a good
idea to try to do some home work ahead of time.

I speak only for myself, and sincerely hope this non-answer is helpful
to you even if it doesn't actually address your questions.

Best,

Brodie.
#
Not work how? You need to tell us what kind of errors you see, otherwise, we can only guess.

I'd lose the file() construct. It sets up a connection object, which can be less than useful when read.table reads the file several time in order to decipher the column structure of the file.

So plain

filepath1 <- "/Users/michaelfeher/Documents/R Documents/COVID19/20200906-1822-total-cases-jones.data"

should be OK, provided that the file actually exists. In particular, check that the space in "R Documents" really is a space and not something that just looks like a space (no-break space is a common culprit).

If you can read the file, but it comes out weird, then you need to diddle the arguments to read.table, e.g.
V1 V2
1  x  y
2  1  2
3  3  7
4  9 13
x  y
1 1  2
2 3  7
3 9 13


-pd

  
    
#
Dear Mike,

I remember so very well the time when I struggled with exactly the same
things, reading a file seeming like an almost insurmountable task.
However, given this actually is very simple I can also understand the
reactions you got. Imagine every newbie asking these questions over
and over again, in a time where there is so much information out there to
figure it out quite easy.

The documentation might be a little cryptic, I give you that. But there are
so many other resources, most of them free, that you can read to understand
how this works. I would warmly recommend some of the contributed
introductory materials from:
https://cran.r-project.org/other-docs.html

There are also plenty of websites to teach R interactively, and all of them
offer this kind of information, without exception, since this really is
part of the very basics in R.

What I learned over the years is that help on this list is invaluable. But
all of the contributors share their own time, and help must be required in
such a way that it (at least) makes it obvious you did first try to do your
homework. Most of the time, asking the right question(s) reveals the answer
and at some point you will only need to browse past similar questions to
find the answer you want.

Linked to that, one other thing I learned is my question is almost never
unique and most likely somebody else asked something at least similar in
the past. Doing your homework also means trying to dig in the archives,
which is pretty easy these days using Google.

Should you make this effort and make it evident in your question that you
did try to read on your own, I'm sure it would be easy for other people to
point you in the right direction. Because this is almost always what I
need: a pointer, and then I can figure it out on my own.

Rest assured this is a very friendly email list, and I consider myself
lucky to be part of this community. Despite knowing this for so many years,
I still make mistakes and consume too much of others' time. But at least I
am aware of that, and extremely grateful for the help I get.

I hope this helps,
Adrian
On Tue, Sep 8, 2020 at 1:08 AM Mike Feher <mfeher1971 at gmail.com> wrote: