![]() ![]() ![]() For instance, suppose I’ve typed round( into the console, and then I hit tab. The RStudio autocomplete tool works slightly differently if you’ve already got the name of the function typed and you’re now trying to type the arguments. RStudio brings up a little dialog box like this one that lets you select the one you want, and even prints out a little information about it. Start typing the name of a function or a variable, and hit the “tab” key. Figure 3.2: Start typing the name of a function or a variable, and hit the “tab” key. ![]() Anyway, if you’ve decided that round() is the function that you want to use, you can hit the right arrow or the enter key, and RStudio will finish typing the rest of the function name for you. Sometimes that additional information is very helpful, sometimes it’s not: RStudio pulls that text from the R help documentation, and my experience is that the helpfulness of that documentation varies wildly. But RStudio goes a bit further, and provides some additional information about the function underneath. In a lot of situations, that’s all the information you need. The second argument is digits, and it has a default value of 0. The first argument is called x, and it doesn’t have a default value. ![]() The very first thing it says is round(x, digits = 0): what this is telling you is that the round() function has two arguments. But when we select round, it displays information about the round() function, exactly as it is shown in Figure 3.2. Previously, it had been telling us something about the rock data set (i.e., “Measurements on 48 rock samples…”) that is distributed as part of R. When you do this, you’ll see that the panel on the right changes. In our case, the thing we want is the round option, so we’ll select that. Or, if none of the options look right to you, you can hit the escape key (“esc”) or the left arrow key to make the window go away. You can use the up and down arrow keys to select the one that you want. The one we want is round, but if you’re typing this yourself you’ll notice that when you hit the tab key the window pops up with the top entry (i.e., rock) highlighted. In Figure 3.2 you can see that there’s quite a few things that start with the letters ro: there’s something called rock, something called round, something called round.Date and so on. Ignore the grey text for now: it won’t make much sense to you until we’ve talked about packages in Section 4.2. On the left, there’s a list of variables and functions that start with the letters that I’ve typed shown in black text, and some grey text that tells you where that variable/function is stored. In this figure, I’ve typed the letters ro at the command line, and then hit tab. RStudio will then display a little window like the one shown in Figure 3.2. This time around, start typing the name of the function that you want, and then hit the “tab” key. Let’s stick to our example above and assume that what you want to do is to round a number. The first thing I want to call your attention to is the autocomplete ability in RStudio. ![]()
0 Comments
Leave a Reply. |