![]() Talking through your problem is called rubber ducking in computer science - talking through your thought process to a rubber duck may help you realise the solution.Don’t think of this as a real blog post. Sometimes the solution isn’t immediately obvious so it may require some trial and error - and that’s all part of the process too! It’s really hard to fix someone’s coding problem without context. The other person needs enough information and context to understand what you hope to achieve and what you’ve done so far to suggest a solution. If you can’t identify the problem, then you need to be able to describe your problem to another person. Make a habit of asking for help as your last option because for the assessment you will need to use R and troubleshoot independently. It is a skill you have to learn by doing, which means having a go yourself before seeking help from others. Learning to problem solve independently is not something you learn by reading or something you can be taught. The first thing is to retrace your steps and identify whether you’ve missed a step or misspelled something. If your code is not working then it’s likely that you’ve made an error somewhere - and that’s OK! It’s all part of learning how to program and there’s no shame in not getting it right the first time. The code to see the working directory in R is: getwd() # GET Working Directory. You can see which working directory is the default directory in RStudio on the “Files” tab. In contrast, the relative address for file B is even shorter, fileB, since folder 2 is already the working directory. /fileA which means that the computer is now looking in the documents folder. For example, if folder 2 was the working directory C:/documents/folder1/folder2 and we wanted to access file A, then we need to tell the computer to go up two directories. which tells the address to go up a directory. Navigating through directories using addresses can be confusing.Īnother useful command is. This way we don’t have to type C:/documents/folder1/ every time. If the default directory is C:/, then the address for file B is C:/documents/folder1/folder2/fileB.īut if we set folder 1 as the working directory C:/documents/folder1/, then we can use the relative address for the file: folder2/fileB. We can then use directory addresses that are relative to this default address to call files.įor example, following this directory structure: C: The working directory in R is the default directory R will look in first. There is a short cut if we use working directories. Remember directories? Typing out whole addresses starting from the hard drive is annoying. ![]() libPaths() in R to check that your personal library folder is now listed in RĬhanging default settings in the Control Panel is pretty advanced computing - we don’t expect you to know this. In the Variable value field enter the address of the package folder (where you made it in step 1) - make sure to use backslash \ not forward slash /.In the Variable name field type R_LIBS_USER - exactly like that in all caps.Under User variables (the top window) click New.Type in “environmental variables”, you should see “Edit environment variables for your account” in the search results - click that with the address C:\Users\XXXX\Documents\R Make sure it is not syncing with the cloud. Create an empty folder in your Documents folder called R.To change the address of your personal library in Windows 10 "C:/Users/XXXX/OneDrive/Documents/R/win-library/4.1" is problematic If the address has OneDrive in the address, then we need to fix that - follow the steps below."C:/Users/XXXX/Documents/R/win-library/4.1" is fine If the second address is on your local computer (e.g. Documents) and not in the cloud then you don’t have to do anything.When you install new packages from the Internet, they will be saved here. One somewhere else on your computer - this is your personal library."C:/Program Files/R/R-4.1.1/library" - this is where all the base R packages are installed (the default packages that come with R) One in your Program Files or wherever your computer installed R.libPaths() in your console - meaning Library Paths, the address of your package libraries. You can see where your packages are saved using. The constant syncing slows down communication and creates issues between the cloud and R and RStudio. Packages should ideally be downloaded to your local computer and not saved on the cloud (e.g. through OneDrive). This is not a problem for Mac users or Windows users that are not logged in to a Microsoft account (check it anyway, in case). We should check that your packages folder is set up properly - especially if you use Windows 10 and sync with OneDrive. ![]() Additional packages are saved to a folder on your computer.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |