Problem installing access to Github repository

Hi,
I have been trying in all different ways to be able to start a project in Rstudio that can be saved in my repository on Github but nothing is working.
I tried to install git.exe on my laptop, but keep getting git.cmd.exe which is not accepted by Rstudio instead of git.exe, no matter which options I select during the installation.

Then I tried this command:

devtools::create("GitHub - nancywahl/DataSci_CrimeStats")
(from something I saw on this support site, but I'm probably missing some step.)

Error: DataSci_CrimeStats.git is not a valid package name: it should contain only
ASCII letters, numbers and dot, have at least two characters
and start with a letter and not end in a dot.

Any specific suggestions? I really need a step by step guide to this process. Thanks!

Nancy J

Hi Nancy,

I'm not 100% clear on what you're trying to do, but if it involves Git and R(Studio), there's not much better place to start than Happy Git With R written by RStudio's own Prof. Jenny Bryan.

I'm also happy to answer any specific questions you might have if you need - just let me know!

J

3 Likes

Thank you. I was starting to get on the right track with simply downloading Git for Windows, but I had gummed up Rstudio by selecting git.cmd.exe. So I
deleted Git, and reinstalled it according to Jenny's instructions, then was careful to choose git.exe in the bin file in my global options under Tools. Then

I was able to create a new project with the git repository option finally available! That in itself is major progress for me. Thanks again.

Nancy

1 Like

That's great news :slight_smile:

Feel free to ask again here if you need any further advice, but it sounds like you're well on your way.

1 Like

Thank you Jim. I now have other questions as I'm further along and wondering what to do with this html file I created, but I will search the RStudio site for that topic.

Nancy

When you say "what to do", do you mean whether or not to add it to git?

Hi Jim,

Yes. You see part of this assignment is to come up with a project, produce 2 graphics on the data, and post it on a public site like Github. They suggested using either Heroku apps or displaying a notebook. If I knew Python, I think it would have been much easier. I've done a little with Rnotebook, but I couldn't find much on how to connect that with GitHub, so I thought I would just try doing Rmd files. But now it looks like things are more complicated than I had thought. For this project, I only have a few hours left, before it's due as it's a competition. But I want to become knowledgeable about Github anyway as I am seeking to build skills in data science. So I will take some time to experiment. Again thanks for your helpful suggestions, and I will try them out.

Nancy

An option you have in Rstudio when you create an Rmd document is to always save the markdown output of the notebook (a notebook is typically processed from Rmd -> markdown -> HTML). Markdown documents can be displayed nicely on Github.

To make sure the (usually intermediate) markdown file gets saved; when you have your Rmd file open, click on the small cog symbol (next to the Knit button) and select Outupt options..., from there, click Advanced and then make sure the Keep markdown source file box is selected/ticked.

You should then re-knit your Rmd notebook and should see the .md markdown document in your project folder. If you commit and add that to git/push to github, you should be able to see the results of your analysis online on github.

This workflow is covered in Happy Git with R in section 19 here.

I tried obtaining the md and other files, and was successful. But when I tried to commit and push them, I got the message "Your branch is ahead of 'origin/master' by 1 commit'. Someone on StackOverflow suggested entering 'git reset --hard HEAD' from the shell in RStudio. I did that but it didn't change anything, except now when I rerun the code with knitr (this is on the Cars code) I don't see my files on the stage to push like I used to. So I don't know if git reset caused that or not, but it seems I'm worse off than before.

That message makes sense.

From your description, you added some files to your local (i.e. on your computer) git repository and made 1 commit containing those files/changes. Your branch is now "ahead" of GitHub (what the message refers to as origin/master) by 1 commit in the sense that you haven't shared your changes to GitHub yet.

The git reset --hard HEAD will have only removed your changes that you hadn't commited, so you should in theory still have the files if you have made a commit of them.

Did you actually push your changes to GitHub?

I just tried pushing, then rerunning knitr, and finally got rid of that warning. But my newly recreated md file and associated folder are listed
in my file list pane, but are still not listed on the stage, which is what needs to happen before committing and pushing, right?

Before you commit, you should usually need to stage them, yes.

Are you able to provide a screenshot of what your git commit/stage pane in RStudio looks like? And also a link to the repository on Github.

Hi Jim,

I went to RStudio and was very surprised to see the files RStudio claimed could not be pushed were indeed there! And the output

was there to see too! So maybe that's why the files no longer went to the stage. Well that's a happy finding! Feel free to check out

my link.

https://github.com/nancywahl/CrimeAnalysis

Nancy

From the look of your Git pane, you haven't actually staged those files to be committed.

The yellow ? boxes and un-ticked boxes indicate that git is aware of those files, but isn't currently tracking them.

To push them to GitHub, you'll need to stage the files you want to push (e.g. select each checkbox), then commit, then push.

Hi

As I said, the files I needed in Github, I actually found there yesterday, including my md file with the display that includes all the html file puts out, and a png file containing just

my graph. But I did commit and push the 4 stages files anyway, and they were successfully sent. Github is in the process of listing them all on the first page, but I see that it

takes time for it to do that. I learned that there is a delay in the displaying of the files you send on the first page of Github, but they are all there under Commits.

And now I just discovered if I modify my code (I deleted one chunk and changed the code of another to a histogram) and knit that, my new run will cause my output to be staged,

and I successfully committed those, and saw my histogram in github.

So I thank you so much for all your patience and help. Also learned some interesting things about html from another user, so it looks like I'm hooked :blush:

Nancy

1 Like

I checked the box for solution, so I hope that does it. Thanks.

1 Like

Hello. Could you help me please,

I am trying to run a clone git. Basically i done the folowing:

1-Run Git Bach for Window
2.Clone repository from url on internet
3. On R wrote: library library(devtools) and them, install('AquaCropR')
but i have obtained the following message as well as error:

install('AquaCropR')
√ checking for file 'C:\Users\Ingrid\Documents\R\win-library\EX\AquaCropR/DESCRIPTION' ...

  • preparing 'AquaCropR':
    √ checking DESCRIPTION meta-information ...
  • checking for LF line-endings in source and make files and shell scripts
  • checking for empty or unneeded directories
  • building 'AquaCropR_0.0.0.9000.tar.gz'

Running "C:/PROGRA~1/R/R-36~1.1/bin/x64/Rcmd.exe" INSTALL "C:\Users\INGRID~1\AppData\Local\Temp\Rtmp8YyDlu/AquaCropR_0.0.0.9000.tar.gz"
--install-tests

  • installing to library 'C:/Users/Ingrid/Documents/R/win-library/3.6'
  • installing source package 'AquaCropR' ...
    ** using staged installation
    |arning in file(file, if (append) "a" else "w") :
    cannot open file 'C:/Users/Ingrid/Documents/R/win-library/3.6/00LOCK-AquaCropR/00new/AquaCropR/DESCRIPTION': No such file or directory
    Error in file(file, if (append) "a" else "w") :
    cannot open the connection
    ERROR: installing package DESCRIPTION failed for package 'AquaCropR'
  • removing 'C:/Users/Ingrid/Documents/R/win-library/3.6/AquaCropR'
    Error in (function (command = NULL, args = character(), error_on_status = TRUE, :
    System command error