background preloader

More resources

Facebook Twitter

R read.table function manual written by. File the name of the file which the data are to be read from.

R read.table function manual written by

Each row of the table appears as one line of the file. If it does not contain an absolute path, the file name is relative to the current working directory, getwd(). Tilde-expansion is performed where supported. As from R 2.10.0 this can be a compressed file (see file). Alternatively, file can be a readable text-mode connection (which will be opened for reading if necessary, and if so closed (and hence destroyed) at the end of the function call). File can also be a complete URL. Header. A million ways to connect R and Excel « The R Trader. In quantitative finance both R and Excel are the basis tools for any type of analysis.

A million ways to connect R and Excel « The R Trader

Whenever one has to use Excel in conjunction with R, there are many ways to approach the problem and many solutions. It depends on what you really want to do and the size of the dataset you’re dealing with. I list some possible connections in the table below. 1 – Read Excel spreadsheet in R gdata: it requires you to install additional Perl libraries on Windows platforms but it’s very powerful. require(gdata) myDf <- read.xls ("myfile.xlsx"), sheet = 1, header = TRUE) RODBC: This is reported for completeness only. Require(XLConnect) wb <- loadWorkbook("myfile.xlsx") myDf <- readWorksheet(wb, sheet = "Sheet1", header = TRUE)

1. Input — R Tutorial. Here we explore how to define a data set in an R session.

1. Input — R Tutorial

Only two commands are explored. The first is for simple assignment of data, and the second is for reading in a data file. There are many ways to read data into an R session, but we focus on just two to keep it simple. 1.1. Assignment¶ The most straight forward way to store a list of numbers is through an assignment using the c command. The numbers within the c command are separated by commas.

When you enter this command you should not see any output except a new command line. If you wish to work with one of the numbers you can get access to it using the variable and then square brackets indicating which number: > bubba[2][1] 5> bubba[1][1] 3> bubba[0]numeric(0)> bubba[3][1] 7> bubba[4][1] 9. Swirl - Home. R by example. Basics Reading files Graphs Probability and statistics Regression Time-series analysis All these examples in one tarfile.

R by example

Outright non-working code is unlikely, though occasionally my fingers fumble or code-rot occurs. Other useful materials Suggestions for learning R The R project is at : In particular, see the `other docs' there. Over and above the strong set of functions that you get in `off the shelf' R, there is a concept like CPAN (of the perl world) or CTAN (of the tex world), where there is a large, well-organised collection of 3rd party software, written by people all over the world.

From spreadsheet thinking to R thinking. Towards the basic R mindset.

From spreadsheet thinking to R thinking

Previously The post “A first step towards R from spreadsheets” provides an introduction to switching from spreadsheets to R. It also includes a list of additional posts (like this one) on the transition. Add two columns Figure 1 shows some numbers in two columns and the start of adding those two columns to each other in a third column. Tutorial: Basic data processing with R. R Tutorials. Sharing my R notes.

Sharing my R notes I started working with R 2 1/2 years ago.

Sharing my R notes

I remember opening R closing it and thinking it was the dumbest thing ever (command line to a non programmer is not inviting). Now it’s my constant friend. From the beginning I took notes to remind myself all of the things I learned and relearned. They’ve been invaluable to me in learning. Note that : 1) they are poorly arranged 2) they may have mistakes 3) they don’t credit others work properly or at all They were for me but now I think maybe others will find them useful so here they are: *Note that the file is larger ~7000KB and 274 pages worth.

Like this: Like Loading... About tylerrinker. R for Public Health: Converting a dataset from wide to long. I recently had to convert a dataset that I was working with from a wide format to a long format for my analysis.

R for Public Health: Converting a dataset from wide to long

I struggled with this a bit, but finally found the right sources and the right package to do it, so I thought I'd share my practical example of reshaping data in R. This post is specifically helpful for those using Demographic and Health Survey (DHS) data. The DHS dataset includes one observation for each woman. For each observation, there are 20 columns for each birth she could have had for 16 different characteristics. If no birth happened then the cell is left missing. For clarity, I've shortened the data to just 7 observations and two characteristics of each birth (b2 and b4) for 3 possible births: Here v012 is the mother's age, all the b2 variables are year of births, and the b4 variables are the sex of the child.

So the first subject, aged 30, has had two births - one in 2000 and one in 2005, both boys. 60+ R resources to improve your data skills.