Friday, March 31, 2017

Blurry Text in Windows 10 on Lenovo P50 laptop

Problem

The Lenovo P50 has a great HD display but some programs have blurry text in Windows 10. Most are fine and even two different subwindows within the same program can have different behavior, ex. the top bar of an NI Diadem script dialog box editor is fine but the text in the editor workspace is blurry.

Temporary Fix

https://www.groovypost.com/howto/fix-fuzzy-windows-10-fonts-high-resolution-displays/

Short overview: go to shortcut's Properties\Compatibility
\check Disable display scaling on high DPI setting


Sunday, February 19, 2017

RStudio and git Part 1: Get Started

Introduction

I've used git and github before but not in a while and I'm even less familiar with R. After digging into some other articles, blogs, videos it became apparent that the real goal should have been to first look into writing an R package then how to use git/github to collaborate on the R package (rather than just a simple R script or other singular file). This realization made some of the references below make more sense since some of the steps in making an R package were left out. I suppose the blog writer assumed that's what you were doing in the first place.

Background Reading/Watching

I came across a webinar with Hadley Wickham at RStudio. He has a book out on developing your own R Packages and the webinar went through how git can help you and your team build R packages with git and GitHub. It's about an hour but pretty conversational, not bad to put in the background while you fix dinner.

https://www.rstudio.com/resources/webinars/collaboration-and-time-travel-version-control-with-git-github-and-rstudio/
video references:
- http://r-pkgs.had.co.nz/git.html

RStudio support page for Git (was updated on Jan 3, 2017 last I saw it)
https://support.rstudio.com/hc/en-us/articles/200532077?version=1.0.136&mode=desktop

Blog post from Hilary Parker
https://hilaryparker.com/2014/04/29/writing-an-r-package-from-scratch/

Interesting find with lots of relevant PhD comics referenced
http://r-bio.github.io/intro-git-rstudio/

Getting Software Installed

I'm working with someone else that uses R and I didn't presently have any of the software tools: R, git, RStudio installed yet so I needed some help. Note: running Win10 64bit although you should be able to get through this on OS X and Linux too, just choose the correct installer as you go along.

1) Install R
https://cran.rstudio.com/

2) Install RStudio
https://www.rstudio.com/products/rstudio/download/

3) Install git
https://git-scm.com/downloads
I left all the installation defaults as is except for changes to .cmd
In the past I never used Windows cmd as a shell for git and the computer I was working with, I wasn't sure if I was ready to make any changes to cmd. No biggy to leave ALL the git installations on default.

Get RStudio setup to work with git

When I installed git, RStudio magically knew that I'd installed it and placed the .exe for git in the path. 

Load up RStudio.
At the top click on Tools then Global Options
Check to see that the two check boxes are checked and the Git executable path is right.
For good measure, go ahead and uncheck and recheck the box for Use Git Bash as shell
   for some reason I had to do that or it tried to use cmd instead



Hadley recommends setting up the SSH keys now, not a bad idea to get this setup for GitHub now. It's much easier to deal with the commit process if this is setup.
http://r-pkgs.had.co.nz/git.html
Under "Initial set up", create a key then put it into GitHub using his instructions.

Create an RStudio Project

Get to a working directory that you want.
Make a new project


Couple routes you can go from here. This is where my present familiarity with R packages ends. 
The New Directory appears to be a wizard to help build R Packges and Shiny Web Applications.
(For more background reading on RStudio Projects:

https://www.stat.ubc.ca/~jenny/STAT545A/block01_basicsWorkspaceWorkingDirProject.html#rstudio-project

https://support.rstudio.com/hc/en-us/articles/200526207-Using-Projects ) 

For now I'm going to do a New Directory --> Empty Project

 
  
Later we'll do a New Project from Version Control by cloning (a git vocabulary term) a remote repository (another git vocabulary term) from github. That'll actually be the check that we did everything right in case you're not working with a buddy or a second computer.

 

I went ahead and checked the Create a git repository check box. You can create this later using git bash too. Once you hit Create Project it'll change your working directory to the project location. The project name will also show up in the corner.


New things:
Git tab next to Environment and History (only shows up if R detects a git repo in the wd)
New files: .gitignore and HelloGitWorld.Rproj

.gitignore sidebar
The .gitignore file in the directory. That can be configured so git will ignore certain file types from version control so you don't chew up hard drive space with lots of copies of large .pdf's. Sidebar on that: git is very good a minimizing space needed to track text based file since it really only records changes between commits rather than copy after copy of the same files. It doesn't do so well with binary files like .pdf or .docx so it might help to ignore those files from version control. There are lots of writeups on this topic elsewhere.

Go ahead and make another file just to see how that changes things.
I made a new script called helloworld.r



Click on the Git tab.
Notice there are three items with yellow ? boxes.
Also the checkboxes under Staged is unchecked.
If you hover your mouse over the box it'll show up as "Untracked".

Make your first commit

The first thing to do before you make a commit is to stage your changes. Go ahead and check the checkboxes next to all three files in the Git tab.




They now show up as A for "added".
Now it's time to Commit


Here's the window to let you see what you're committing.
First off, give it a descriptive Commit message. Some best practices have that you keep the first line short which helps if you do any work in git bash which shows the first line of a commit message.

If you check the History tab, it's empty since this is the first commit.
If you click on each of the files individually you can see new text highlighted in green and if there were any deletions they would be highlighted in red.

Once you're ready go ahead and click Commit.
 

RStudio gives you the text readout from git similar to if you had done the commit manually using git bash or another shell interface.

View your repo history

Now that you've made your commit, there shouldn't be any unstaged changes (git vocabulary) so the Git tab will be empty. Go ahead and check the History button in the Git tab.




You then get a nice view of the edits associated with the first commit.





Setup Remote Repo with GitHub, Push to Remote

If you haven't made a github account already it's time to make one. As other tutorials have mentioned, the free account is fine for most projects.

Working from this GitHub article
https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/

For all the commands on that page that start with "$ git ......" you're going to enter those into the git shell. You can navigate to Git Bash from the Windows Start button or in RStudio:







This is nice since it automatically sets up the Git Bash session in the repo directory of your project.
You really only need to do
Once you've setup a blank repository on GitHub you can 
$ git remote add origin  https://github.com/yourGitHubUsername/yourGitHubRemoteRepoName
then push to the remote from the shell



I had to use this to get the Push and Pull buttons to work in RStudio
https://www.r-bloggers.com/things-i-forget-pushpull-greyed-out-in-rstudio/
$ git push -u origin master

Go ahead and make another change to your local repo, make another commit, and push again using the -u push. You should be able to use the RStudio buttons now.

You should now see both pointers, one for the local repo, and one for the origin (git vocab for remote). Notice they're in the same place.




Still working on branching and merging which as far as I know aren't supported with RStudio buttons/GUI so that may be some more shell commands. Also need to add a second contributor to work through Pull requests in GitHub. I also didn't cover R packages, still not sure how those work yet and the workflow to develop the package i.e. do you install your own package? or just link to it locally? More work to be done.