Home | The University of Sheffield
Recap/Intro – Functions, objects and working in the consoleA function in R is…An object in R is…When we import a dataset it will be stored as…Importing dataThe working directory is …getwd() …Using read.csv…Note: there are lots of ways of getting data into R, the above is probably the simplest. You also need to make sure that the CSV is “R-Friendly” before you try to import the dataset to RStudio. For more options see the “First Steps in R” materialsExercise 1Find your working directory.Save a dataset to your working directory as a csv file.Import the dataset in to R.PackagesA package is…To install a package…To remove a package…To access a package you…Exercise 2Some useful packages are MASSggplot2swirlInstall one of these packages. ggplot2 is a package which is widely used for plotting graphs. It contains some functions for plotting graphs and charts which many people consider to be superior to the default functions.swirl is a package designed to help you learn R. Type the following commands to get started:library(swirl)swirl()(You might want to wait until after the session before you investigate swirl)Investigating a datasetDatasets to play and learn with:“First Steps in R” materials will help you recap some helpful functions for getting to know a dataset.Exercise (for later)Experiment with these commands:?name_of_data_framestr(name_of_data_frame) (stands for structure)summary(name_of_data_frame)head(name_of_data_frame)View(name_of_data_frame) (note capital V!)Saving a datasetwrite.csv() …How to use R practicallyYou will want to be able to do the following:Get Data into RGet to know the datasetManipulate the dataExport the data3, manipulate the data is the tricky bit! The general approach is as follows:- What do you want to do?- Is there a function in R what will help?- How do we use the function (what arguments does it take, in what order, how do we enter them)Manipulating Data Frames – Beginning Subsetting[ ] when used with a vector[ ] to select a row and columnWe can select a column from a dataframe by…We can select a row by…Exercise 4Look at the iris dataframe (by typing iris in the console or by using some of the commands above)Type a command to get R to show you the third element of the second columnType a command to get R to show you the 7th entry in the Sepal.Length columnStore the first two columns of the dataset in an object called first_twoStore the first 5 rows of the dataset in an object called first_fiveThe “First Steps in R” materials don’t currently cover subsetting. For more information see ................
................
In order to avoid copyright disputes, this page is only a partial summary.
To fulfill the demand for quickly locating and searching documents.
It is intelligent file search solution for home and business.
Related searches
- the university of scranton address
- the university of hong kong
- wharton school of the university of pennsylvania
- the university of scranton tuition
- the university of scranton
- the university of hk
- the university of scranton jobs
- the university of north texas
- the university of philosophical research
- the university of scranton players
- the university of scranton calendar
- the university of chicago jobs