GitHub Copilot for R - First impressions

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hey everyone today I'm gonna try something a little different than what I usually do for my videos usually I plan them out heavily in advance a lot of the times I will have a script for my intro and I've already written every single line of code that I'm going to use in the video so everything flows really nicely but today I have a couple of hours to work on a video and rather than using that couple of hours to make a script and plan everything out perfectly I want to try just recording a video as I'm learning something for the first time and see how that turns out and specifically today I want to teach myself about GitHub copilot I've actually never used it before I really don't know that much about it and I'm hoping that by the end of this video I'll be somewhat of an expert on how to use it and I'm hoping you'll enjoy coming along this journey with me I'm still going to edit this video and cut out all of the awkward sound balances or times where I'm just sitting there thinking and processing but I hope this format is helpful to see what that learning process can be like and I'm I'm hoping it's also interesting to see first impressions of GitHub co-pilot before I've had a chance to really dig into it so thanks for joining me today and let me know in the comments if you like this format or if you prefer my videos that are more scripted and planned out okay so I'm on the web page for GitHub co-pilot it says it's your AI pair programmer apparently it's going to use the open AI codex model to suggest code and write entire functions for you in real time right from your editor I know that it does cost money but there's a free trial so that's what I'm going to go with for today I do already have a GitHub account but I'm going to create a new one for the purpose of this video and I'm going to use the email address that is associated with this YouTube channel take a moment to generate a password and a username oh no it's captcha again this one is like the same one that was in my blastula video and I hope that this is not where captcha is going because these are the worst ones that one was not as bad though okay so I guess we can get a 60-day free trial of GitHub co-pilot which is awesome I'm just gonna sign up for the 10 a month one it looks like I do have to enter my billing info to sign up for the free trial but that's okay I'm sure we can cancel it fairly easily okay after I've entered my credit card information it's asking for preferences so I guess you can decide whether or not you want to prevent GitHub from suggesting code to you that is exactly identical to code that someone else has written personally like as an individual not representing an organization or an employer right now I'm going to allow suggestions matching public code but I think if I were doing this representing an organization I would be inclined to pick block I think and then we get to decide if we want to let our code Snippets improve GitHub co-pilot in the future basically do we want to improve their model based on what we write I'll leave that as allow for right now okay so there's only a few Ides that are compatible with GitHub co-pilot and unfortunately for probably most people watching this video it looks like our studio is not one of those Ides don't think I've ever made a YouTube video where I didn't use rstudio for the programming portion so this will be a little bit different but I'm gonna go with Visual Studio code I have used it quite a bit and I do really like it and the nice thing about Visual Studio code is that it does have really great extensions for R and Cordo as well so it's an environment that I'm already somewhat familiar with and maybe GitHub co-pilot can inspire me to use vs code a little bit more I actually don't have vs code installed on this machine so I'm gonna download that first I also think it's worthwhile mentioning that even pause it themselves are supportive of BS code I went to a workshop at the r Studio conference last year back when it was still called our studio instead of pause it and it was a workshop on an introduction to Cordo and we actually used vs code for a lot of it I'm someone who is a big big fan of posit and all of their products so I don't feel like I'm betraying them or something by using vs code for this video and I am an R programmer so I'm still going to make sure that this is very focused from the perspective of an R user and who knows maybe one day pause it will add support for a GitHub co-pilot extension in our studio or maybe someone in the open source world will go ahead and make something like that for us now that vs code is launched I'm going to go ahead and add those extensions that I was talking about before so the first one I'm going to add is R that's installed I'm going to add the Corrido extension as well and finally let's see if we can get GitHub co-pilot on here looks like it's as easy as that okay so then a little pop-up appears asking us to sign in to GitHub in order to use GitHub Copilot I click allow oh oh no okay it's popping up to my personal GitHub which is not the one that I want to use with vs code I want to actually use that account that I just created since that's the one where I have the GitHub co-pilot free trial right now let's see if I go into the documentation okay apparently I needed that pop-up so I'm going to click cancel and then oh it asked me if there's a different way I'd like to log in so let's say yes okay it's still popping up to my personal account so I'm gonna go to GitHub and I'm just gonna sign out and then hopefully if I launch that again okay so now it's giving me a like a one-time code that I can copy and paste and using that other account now I have to enter this code all right I'm gonna authorize vs code and it looks like that worked go back to vs code for a second okay so let's take a look at the documentation GitHub co-pilot can provide suggestions for numerous languages and a wide variety of Frameworks but it works especially well for python JavaScript typescript Ruby go C sharp and C plus plus the examples that they have are in JavaScript but other language should work similarly looks like our first step is to create a new file I'm gonna make an R script instead of JavaScript go to new file our document and then it's asking us if we'd like to install the r package language server which is required for code completion Etc so let's go ahead and install that okay okay we might need to reopen an R file create a new R document and I'm just going to put some text into it and save it the next suggestion is to create a skeleton of a function and then GitHub copilot will automatically suggest the function body in grade text let's follow along with this example but we'll turn it into our code instead so we're going to create a function called calculate days between dates and the first argument is begin and the second argument is end calculate days between dates is a function and it's a function of begin and end and now I've got the skeleton but nothing's really popping up let's see what we're missing here okay so it looks like I didn't actually activate copilot yet so let's go ahead and do that I'm going to enable this for R only for right now so I'm guessing that this will activate copilot anytime I create an R script but not if I'm using other languages in vs code I'm still not seeing anything popping up let's try one of the other examples I guess you can also generate code suggestions based on comments that you write so if we describe what we want to do using natural language then GitHub copilot can try to write that code for us I'm not going to follow along with the example that's here I'm going to come up with my own I'll add a comment saying create a function that and oh there we go it looks like copilot is now kicking in so the grade out text is the suggestion and we're supposed to hit tab to accept the suggestion so I'll hit tab see what happens okay so that filled out the rest of the comment for me and let's see I'm really hoping that if I just press enter it'll have suggestions for me okay path copilot dot R I'm not sure what that's getting at I hit Tab and enter that still doesn't seem like it's doing anything okay now what if I copy and paste this function skeleton below that okay okay so once I go into the skeleton I have to press tab in order for it to pop up any of those suggestions which isn't super clear in the documentation to be honest but it worked and this looks amazing so let's hit Tab and accept the suggestion wow that's super cool let's get rid of this empty skeleton at the top and let's try actually using this function and okay look at that copilot even gives us suggestions for the begin and end arguments that's awesome I'll accept that suggestion and let's run this code and now I'm pretty sure in vs code it's very similar to our studio so I think all I need to do is hit control enter yeah so just like in our studio I hit Ctrl enter and then it popped up in the terminal so let's see if this function Works which it should that's super cool okay I'm really impressed so far so I guess the real question is how can we best utilized co-pilot in order to get the most out of it and save us time on the stuff that's really tedious and give us more time to do the parts of our jobs that actually require more thinking and human input so for me the thing that's jumping out right away is the UI side of shiny and the reason that that's jumping out at me as something to try is because when I first tried out chat GPT that was the part that I was the most impressed by because I spent so so so so so much time on playing around with the UI side of a shiny App instead of doing the stuff on the server side that is actually like where my skills really come in I mean I'm sure there's people out there who enjoy just writing UI code but for me like that that part always feels like it's kind of like a necessary evil and the server-side logic is where the bulk of the work should be but off isn't so it would be amazing if something like chat GPT or GitHub co-pilot can save us time as data scientists on the UI side so that we can spend more time doing the more complex stuff being said I'm going to close this R script and I'm going to create a new one I'm going to create another R document and let's try to describe a simple shiny app and see how well copilot does with this I have no idea what the best prompts will be for this so this might be a little bit of trial and error but let's see if we say Define user interface side of shiny application let's hit tab oh my goodness I didn't even have to hit Tab and it already created something for us this is incredible so this is one of the examples that's on the posit website I believe I think this is sort of like the standard example of a shiny app so let's hit Tab and go along with that and I wow I hit enter I didn't even have to describe what I was going to do next it already knows that my next step in creating a shiny app is to define the server logic that's required for this app so I'm going to hit tab again enter and half a second later it's got the rest of that example that's on the the posit website so let's accept that suggestion by hitting Tab and I'm going to save this now I usually go with a two file shiny app like a UI dot R and A server.r but since this is all contained in one file I'm going to call this app.r I don't actually know if vs code can launch a shiny app but let's give it a try and see what happens I'm going to press the Run button I think that would run the whole app okay right that makes sense so we forgot to load the packages so I'm going to add a comment saying load required oh load required libraries let's see hit enter oh my goodness okay okay incredible it knows exactly what package we're gonna need and that's the shiny package let's save that and try running this again that did not work let's see it's not giving us an error it's just not working I'm not sure if vs code can run shiny apps okay looks like we're gonna need the r tools for visual studio I'm guessing that's a vs code extension so let's go to the extensions tab our tool for visual studio okay that's not coming up maybe just our tools let's see okay let's give that a go try running that again okay we're still getting the same problem all right let's just try running this line by line okay looks like I might have broken my vs code somehow so now when I'm hitting Ctrl enter it's telling me that the execute in terminal is not found so maybe let's try getting rid of that our tools extension let's see nope okay I might have might have broken vs code let's try restarting it okay so now a Kernel's been launched let's try Ctrl enter again all right and that fixed it so I I guess I broke vs code somehow with that extension I don't know why that didn't work but let's see if we Define the UI the server okay I just realized the problem is you have to use the run app function which I totally forgot about so that's on me let's hit Tab and accept this suggestion from GitHub co-pilot again amazing and let's hit Ctrl enter on that and it looks great I just launched right right in vs code and it works like we would expect I'm sure now if I just hit this run button it'll all work it's totally because I forgot to add that run app line now I wonder if okay let's see did that launch somewhere okay so now vs code seems to be kind of stuck it thinks that I'm still trying to view this app but I actually want to close it maybe if I go to the link and then end it that didn't do anything either cool well I'm not sure how to stop that execution so what I'm gonna do is just restart vs code again I'm I'm curious if GitHub co-pilot would have caught the fact that I didn't have that run app so I'm just going to erase that and see so if I hit enter after the definition of server if it's going to suggest oh my gosh okay apparently all I needed to do was hit enter and co-pilot would have had my back interesting it's using a different function than run app see if that works okay it doesn't like that so maybe I do need to control enter my way through this cool so if I just hit Ctrl enter a bunch of times it works but for some reason it seems like running the whole script it doesn't work so that's good to know I'm wondering if there's a way to stop the app from running so that my terminal doesn't just get stuck on this I can't figure out a way and if I just exit it it doesn't seem to actually stop the app from running which is odd well so far I'm very impressed with the functionality of GitHub co-pilot this is totally something that I could see myself using that the benefit of this over chat GPT is that it is right in your IDE whereas with chat GPT I find that I'm spending a lot of time going back and forth copying and pasting between the browser and my IDE so having everything be typed out for me directly in place is really cool I do like vs code but I'm a huge fan of rstudio so I'm wondering if there's a way to integrate it into the rstudio IDE I'm going to Google that quickly looks like there's a GitHub issue requesting this functionality it looks like it's not currently in the plans to support it and there's quite a discussion on this thread it looks like there's a lot of philosophical debate about whether or not the is something that should be integrated into our studio I can see the arguments here someone's suggesting GPT tools package I've definitely been meaning to learn gbt Studio maybe that's the the route forward let's see this video here convert a script into functions that kind of sound similar to copilot okay it doesn't seem exactly the same this example seems to be taking code that you've already written and then yeah converting it into a function which is cool still very cool it's slightly different than what we're looking for but hmm okay interesting so it sounds like this is definitely not available yet in our studio This Thread is active as of now really and someone here is suggesting that there's an alternative to co-pilot called codium which might be getting integrated with our studio yeah GPT Studio seems like the closest thing to an integration between our studio and open AI right now and although GitHub co-pilot does use an open AI model GPT Studio doesn't offer exactly the same thing so it looks like for right now like as of March 24th 2023 it seems like we're stuck to vs code for using GitHub copilot specifically but GPT studio is an option for adding chat GPT functionality to our studio it would probably allow us to do a lot of similar things I guess the the question comes down to cost comparison and what exactly it is that you're looking for I'm not sure how expensive it would be to use GPT Studio instead of copilot like the nice thing about GitHub copilot is that it's only 100 bucks a year which is fairly affordable especially if you're programming every day this is something that will save you hours and hours and hours it's definitely worth a hundred dollars a year but I don't know how much it would cost to go the open AI API key root let's see e-pricing it's a pay-as-you-go model which could be good or could be bad depending on how often you're looking to use it I guess the first step to understanding this pricing model is understanding tokens their prices are listed per 1000 tokens where you can think of tokens as pieces of words a thousand tokens is about 750 words this paragraph is 35 tokens okay it's really hard to know how much you'd be using so what I'm gonna do to figure that out is I'm going to log into my my actual openai account with like my personal account and I can take a look at the usage there just to get a sense of the pricing because before I was on the account that I had created for my my YouTube account now I'm just going to check on my personal account where I have like an actual API key that I've used a little bit let's see usage okay so I used it a bit in February I think February 28th was the the day that I created my YouTube video on using chat gbt from within R apparently that cost me two cents out of I have a free 18 credit which is expiring very soon now on that day I really didn't do very much I all I had asked was what is the meaning of life I think that was the only prompt that I asked and that cost two cents so it's two cents US dollars so it's very possible that it could get expensive if you're using it every day for for multiple hours a pay as you go is is a good model if you're you know not going to be using a lot and you can predict how much it's going to cost you but I I do like the idea of GitHub co-pilots model of just being around 10 a month or a slightly less than that if you get the annual subscription because then you can just use it as much as you want you don't have to think about how much it costs you I guess there are usage limits here so that's good you can at least predict that your your cost isn't going to be more than whatever amount you set for yourself but I'm not sure because the the integration into our studio is huge I think this is going to be one of those things where I just have to play around with both of them and see over time which one is is the better fit for me but I'd love to hear your thoughts in the comments if you've tried both which one do you recommend which one was cheaper for you and which one meets your everyday needs better I think for me personally only time will tell thanks for joining me today I hope you're as excited about GitHub co-pilot and chat gbt as I am and I'll see you all in the next video
Info
Channel: ggnot2
Views: 3,963
Rating: undefined out of 5
Keywords: copilot r, github copilot, copilot x, codepilot, co pilot, codeium, ChatGPT, GPT-3, GPT-4, gpt-3.5, Open AI, OpenAI, RStudio, posit, shiny, ggnot, ggnot2, github copilot r, gpttools, GPTStudio, gptstudio, ChatGBT, AI, MichelNivard, code completion, languageserver, data science, pair programmer, AI pair programmer, codex, codex model, gptchatter, VS Code, Visual Studio, Visual Studio Code, IDE, Python, Shiny for Python, posit conf, API key, tokens, codepen, quarto, copilot extension, VS Code extension
Id: NGM7Z1Dd9fE
Channel Id: undefined
Length: 24min 56sec (1496 seconds)
Published: Mon Mar 27 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.