# data[].attributes.attachment_link.readable_text
Para trabajar con este material es recomendable obtener una copia local del repositorio. Puedes hacerlo descargando el repositorio en formato ZIP. Es recomendable descomprimirlo en una ruta sencilla (por ejemplo, en Windows C:\cursoR\ y en Linux/Mac/home/miusuario/cursoR/). Si tienes en tu ordenador, puedes hacer una copia de forma aún más sencilla:

  git clone git://github.com/oscarperpinan/R.git

Una vez realizado el paso anterior, existirá una carpeta en tu ordenador con el contenido del curso. Todo el código asume que la ruta de trabajo coincide con esa carpeta. Por tanto, el primer paso a dar en R es definir la ruta de trabajo con setwd:

setwd('/ruta/de/copia/local/del/repositorio/')

Puedes comprobar que todo ha ido bien con dir. El resultado de la siguiente instrucción debe ser la estructura de carpetas y ficheros del repositorio:

A continuación, debes instalar los paquetes que se emplean a lo largo del curso. Algunos ya vendrán instalados con tu distribución de R por ser paquetes recomendados. En R debes usar install.packages. En la siguiente instrucción usamos el CRAN mirror de la Oficina de Software Libre (CIXUG). Consulta esta lista para elegir un CRAN mirror diferente.

install.packages(c('lattice', 'latticeExtra', 'RColorBrewer',
                   'zoo', 'reshape2', 'ggplot2'),
                 repos = 'http://ftp.cixug.es/CRAN')

Ya está todo listo para empezar a trabajar con el material.

# data[].attributes.attachment_link.description
Para trabajar con este material es recomendable obtener una copia local del repositorio. Puedes hacerlo descargando el repositorio en formato ZIP. Es recomendable descomprimirlo en una ruta sencilla (por ejemplo, en Windows C:\cursoR\ y en Linux/Mac/home/miusuario/cursoR/).

# data[].attributes.attachment_link.title
Bioestadística: base para el análisis de las ciencias de la salud

# data[].attributes.attachment_link.description
Bioestadística: base para el análisis de las ciencias de la salud | Wayne W. Daniel | digital library Bookfi | BookFi - BookFinder. Download books for free. Find books

# data[].attributes.body
example: repeated measures

# data[].attributes.body
example: survival analysis

# data[].attributes.body
(temporary edition)

# data[].attributes.body
(temporary edition)

# data[].attributes.body
(temporary edition)

# data[].attributes.body
Please, read carefully this paper ..

# data[].attributes.attachment_link.readable_text
Abstract

Background

Hospital mortality rates are one of the most frequently selected indicators for measuring the performance of NHS Trusts. A recent article in a national newspaper named the hospital with the highest or lowest mortality in the 2005/6 financial year; a report by the organization Dr Foster Intelligence provided information with regard to the performance of all NHS Trusts in England.

Methods

Basic statistical theory and computer simulations were used to explore the relationship between the variations in the performance of NHS Trusts and the sizes of the Trusts. Data of hospital standardised mortality ratio (HSMR) of 152 English NHS Trusts for 2005/6 were re-analysed.

Results

A close examination of the information reveals a pattern which is consistent with a statistical phenomenon, discovered by the French mathematician de Moivre nearly 300 years ago, described in every introductory statistics textbook: namely that variation in performance indicators is expected to be greater in small Trusts and smaller in large Trusts. From a statistical viewpoint, the number of deaths in a hospital is not in proportion to the size of the hospital, but is proportional to the square root of its size. Therefore, it is not surprising to note that small hospitals are more likely to occur at the top and the bottom of league tables, whilst mortality rates are independent of hospital sizes.

Conclusion

This statistical phenomenon needs to be taken into account in the comparison of hospital Trusts performance, especially with regard to policy decisions.

Mortality in NHS hospitals

According to an article in the Daily Telegraph [] (accessed online on 25/04/2007), the George Elliot Hospital (the only hospital run by the George Elliot Hospital NHS Trust) may have been the most dangerous hospital in England during the 2005/6 financial year. This is because its Hospital Standardised Mortality Ratio (HSMR) was 1.43, i.e. the number of patient deaths in this hospital was 43% higher than expected. In contrast, the hospital run by the Royal Free Hampstead Trust may have been the safest, since its HSMR was only 0.74, i.e. the number of patient deaths in this Trust was 26% lower than expected. The source of information in the Daily Telegraph was provided by an organization called Dr Foster Intelligence, which recently published a report entitled "How healthy is your hospital" [], in which the performance of NHS Trusts was assessed against several indicators, such as post-operative mortality and emergency readmission.

According to the Daily Telegraph, the George Elliot Hospital had problems in the areas of both finance and hospital infection, though the Royal Free Hospital seems to have its own problems too. Whilst we do not have any explanations for the higher than average mortality rate in the George Elliot Hospital NHS Trust, we know that it is a relatively small hospital with only 352 beds, and admissions totalled 42,577 during 2005/6, according to Hospital Episode Statistics []. Even the Royal Free Hampstead Trust is not very large, with around 900 beds in current use for patient care, with total admissions of 62,062 during 2005/6 []. In contrast, the Leeds Teaching Hospitals NHS Trust has three hospitals and 2,370 beds (according to the Daily Telegraph website) with a total of 190,604 admissions during 2005/6 []. There is clearly huge variation in the sizes of Trusts and hence the number of patients they treat, and the question we consider is does size matter? We shall explain in this article why, from a statistical viewpoint, the size of a hospital may be a crucial factor as to whether or not that hospital appears at the top or the bottom of any league table.

Why size matters

First let us use a simple example to illustrate why the size of a hospital can matter. Suppose hospitals in England have only five different sizes - 200, 400, 600, 800 and 1000 beds - and they undertake 100, 200, 300, 400, and 500 coronary artery bypass graft operations each year, respectively. Also suppose that the post-operative mortality rate is nominally 10%, irrespective of hospital size. The expected number of deaths for the different sized hospitals should then be 10, 20, 30, 40, and 50, respectively. Nevertheless, it is inevitable that across the years there will be some variation; for instance, in some hospitals with 200 beds only 8 patients may die, whilst in other hospitals of the same size 12 patients may die. The overall average mortality rate nevertheless remains 10%. Suppose the extent of variation (standard deviation) between hospitals of the same size is similar across all hospitals, e.g. the observed number of deaths plus or minus its standard deviation is 10 ± 3, 20 ± 3, 30 ± 3, 40 ± 3, and 50 ± 3, respectively. So what of the observed mortality rates? From the smallest to largest hospital, the observed mortality rates have 95% confidence intervals of 4.0%-16.0%, 7.0%-13.0%, 8.0%-12.0%, 8.5%-11.5%, and 8.8%-11.2%, respectively. If we were to make a league table for these hospitals, the smaller hospitals are more likely to be found at the bottom and the top the league table. Nevertheless, if factors related to the success of coronary artery bypass surgery act in a similar way across different sized hospitals, then variations in the number of deaths for larger hospitals would be expected to be greater than for smaller hospitals.

Many factors affect the performance indicators of hospitals, such as the post-operative mortality rate. There has been a continuing debate regarding whether or not these indicators can really measure the quality of healthcare provided by a hospital Trust [-]. Any hospital that treats more patients with higher risks or greater complexity may show higher mortality rates. However, notwithstanding the controversy regarding the validity of performance indicators, it is important to note that the extent of variation in the number of deaths in hospitals of the same size is not in proportion to the size of the hospital, but is in proportion to the square root of its size [, ]. Therefore, for our simple example, if all the factors related to post-operative mortality (e.g. case-mix, staff experiences, and support from post-operative care units, etc.) were comparable for all hospitals and operated in similar ways across hospitals of different sizes, the variation of the observed number of deaths would be 10 ± 3.0, 20 ± 4.2, 30 ± 5.2, 40 ± 6.0, and 50 ± 6.7, rather than 10 ± 3.0, 20 ± 6.0, 30 ± 9.0, 40 ± 12.0, and 50 ± 15.0. The observed mortality rates would then have 95% confidence intervals of 4.0%-16.0%, 5.8%-14.2%, 6.5%-13.5%, 7.0%-13.0%, and 7.3%-12.7%, respectively. Hence, the smaller hospitals are still more likely to be found at the bottom and the top the league table.

From a statistical viewpoint, this is because the standard deviation of the sampling distribution of the mean, i.e. the standard error of the mean, is inversely related to the square root of the sample size: MathType@MTEF@5@5@+=feaafiart1ev1aaatCvAUfKttLearuWrP9MDH5MBPbIqV92AaeXatLxBI9gBaebbnrfifHhDYfgasaacPC6xNi=xH8viVGI8Gi=hEeeu0xXdbba9frFj0xb9qqpG0dXdb9aspeI8k8fiI+fsY=rqGqVepae9pg0db9vqaiVgFr0xfr=xfr=xc9adbaqaaeGacaGaaiaabeqaaeqabiWaaaGcbaacciGae83Wdm3aaSbaaSqaaiqbdIha4zaaraaabeaakiabg2da9maalyaabaGae83WdmhabaWaaOaaaeaacqWGUbGBaSqabaaaaaaa@33BE@ . This equation appears in every introductory statistics textbook and was first stated by the French mathematician de Moivre in 1730. This equation shows that the greater the sample size, the less likely is the sample mean to fluctuate, i.e. the variation is much greater for small hospitals and much less for large hospitals.

It has been noted in the literature that there is "over-dispersion" of performance indicators for smaller hospitals or Primary Care Trusts [], and therefore the use of league tables for the ranking of hospital performance may be misleading [, , , ]. Quality control charts [, ] and funnel plots [, , , ] have been proposed as alternative strategies to compare hospital performance, and to identify those for whom performance is below the national standard. To understand why quality control charts and funnel plots are more appropriate methods for comparing the performance of hospitals, it is crucial for health services researchers, doctors, and patients to appreciate fully the significance of de Moivre's equation.

Throwing the die of death

Suppose there is an imaginary fair die with 20 surfaces. One surface of the die is black and the other 19 are white. When the die is thrown, the probability of the black surface showing is 0.05, i.e. when the die is thrown 20 times, we expect on average to see the black surface only once. However, due to the nature of all random processes, in each round of 20 throws the black surface may or may not show, or might show more than once. Similarly, although the black surface is expected to show 50 times when the die is thrown 1,000 times, the black surface may actually show more or less than 50 times. From a statistical viewpoint, an experiment like this is known as a Bernoulli trial [, ]. The results collected from performing multiple independent Bernoulli trials, such as throwing our twenty-sided die 1,000 times, follow a binomial distribution [, ], which can be used to calculate the variation in the number of times the black surface is expected to show. By denoting the number of throws (trials) as n = 1,000 and the probability of obtaining black as π = 0.05, statistical theory tells us that the population mean, n π, is 50 and the standard error of this mean, MathType@MTEF@5@5@+=feaafiart1ev1aaatCvAUfKttLearuWrP9MDH5MBPbIqV92AaeXatLxBI9gBaebbnrfifHhDYfgasaacPC6xNi=xH8viVGI8Gi=hEeeu0xXdbba9frFj0xb9qqpG0dXdb9aspeI8k8fiI+fsY=rqGqVepae9pg0db9vqaiVgFr0xfr=xfr=xc9adbaqaaeGacaGaaiaabeqaaeqabiWaaaGcbaWaaOaaaeaacqWGUbGBiiGacqWFapaCdaqadaqaaiabigdaXiabgkHiTiab=b8aWbGaayjkaiaawMcaaaWcbeaaaaa@3435@ , is 6.9 []. Consequently, the number of times the black shows has a 95% confidence interval of 36 to 64.

In 2002-2003, the average mortality following selected surgical procedures in English NHS hospital Trusts was around 5% []. Now suppose the die represents the probability of death following these selected surgical procedures and n is number of surgeries undertaken by the hospital. The 95% confidence interval for the number of deaths is between 36 and 64, i.e. the mortality rate has a 95% confidence interval between 3.6% and 6.4%. For NHS hospital Trusts undertaking 4,000 surgeries, the expected number of deaths is 200 and the standard error of the mean is 13.8, which is twice as large as that for hospital Trusts undertaking only 1,000 surgeries. However, the 95% confidence interval for the mortality rate of this larger hospital Trust is 4.3% to 5.7%, which is narrower than that for the hospital Trust undertaking only 1,000 surgeries.

A funnel plot in Figure shows a simulated dataset of 1,000 hospitals in which the number of surgical procedures (Y) in each year has a mean of 2,500 and a standard deviation (SD) of 700. The mortality rate is assumed to be 5% across all sizes of hospital, so the number of expected deaths (X) has a mean of 125 and SD of 35. A random variable with zero mean and SD proportional to the square root of X is simulated to represent the variation/fluctuation in the observed mean number of deaths, and this is added to X. The vertical axis in Figure is the ratio of observed number of deaths (Z) over the expected number of deaths (X), and the horizontal axis is X. If we fit a linear regression model to the data, the regression slope will be close to zero, indicating that the observed to expected ratio is independent of the expected number of deaths (i.e. hospital size), yet variation in the 95% confidence interval of these ratios (represented by the blue lines both top and the bottom of the figure) is inversely related to hospital size. Although this simulation assumes no relationship between mortality and the number of surgeries undertaken, a few hospitals are below the lower confidence limit or above the upper confidence limit, as would be expected due to chance alone 5% of the time, indicating that their performance is either alarmingly poor or extremely good. We would therefore still need to be cautious in identifying the poor or good performers using funnel plots or quality control charts, given that chance is involved. In the report published in the "How healthy is your hospital?" readers can find that the report's graphs follow a very similar pattern [].

The most dangerous equation

In a recently published article [], Howard Wainer nominated de Moivre's equation as "the most dangerous equation", since being ignorant of its consequences may cost us dearly, especially with regard to policy decisions. One example given by Wainer was the project to convert large schools to many small schools simply because, amongst the high-performance schools, there seemed to be an unrepresentatively large proportion of small schools. The Bill and Melinda Gates foundation had given approximately $1.7 billion for this project, which achieved disappointing results []. Maybe it should be called the most expensive equation? If someone in the foundation had noted that small schools were also over-presented in the poor-performance schools, this $1.7 billion could have been saved for other purposes.

Returning to hospital performance league tables, Table shows the best and poorest performing NHS hospital Trusts, amongst the 152 English NHS Trusts, with respect to the hospital standardised mortality ratio (HSMR) for 2005/6, provided by "How healthy is your hospital" []. The number of hospital admissions within each hospital Trust during 2005/6 is used as a proxy variable for the volume of patients treated within each hospital Trust []. The range of admissions was between 24,269 and 232,033. Sixty-nine of the 152 (45.4%) Trusts had fewer than 65,000 admissions and 13 of them appear in Table ; none of the 27 Trusts with admissions greater than or equal to 110,000 appears in Table . We may conclude that there is an unrepresentatively large proportion of small Trusts in both the best and poorest performing groups. Figure shows the relationship between HSMR [] and the number of hospital admissions [] for the 152 English NHS hospital Trusts listed in "How healthy is your hospital" []. It is noted that there is less variation amongst mortality rates the greater the number of admissions, as predicted by de Moivre's equation, and this explains, in part, why many hospital Trusts in the league table (Table ) are small ones. Figure also shows that the HSMR of many NHS hospital Trusts is outside the 95% or even 99% confidence interval. Although the HSMRs of several large-sized NHS Trusts are relatively lower than those of many small Trusts, the HSMRs of these large-sized NHS Trusts are still above the upper 99% CI. However, although this may indicate the performance of these large NHS hospital Trusts is also below the bar, these Trusts would not be identified by the league table.

Why the George Elliot Hospital Trust had the highest mortality rate in the England in 2005/6 merits further explanation, but it might be too early to call it the most dangerous hospital based simply on its HSMR. As long as it remains small, it is more likely than larger hospital Trusts to be at the bottom or the top of any league table, even if the quality of care provided by the George Elliot Hospital Trust is no worse than other Trusts []. This is not to imply that only the size of a Trust plays a role in the random processes of variation; some studies have suggested that there exists an inverse association between hospital (surgeon) volume and surgical mortality [, ]. In addition, there may be other important managerial and financial factors contributing to the poorest (or best) performance of some (small) hospitals. Nevertheless, using league tables to rank the performance of hospital Trusts could be potentially misleading, and there are alternative, more appropriate methods available [-, , ]. Therefore, the next time we hear about the 'most dangerous/safest' city, the 'most dangerous/safest' postcode, the 'best/poorest' school etc., it is better to think again about de Moivre's equation.

Declarations

Acknowledgements

We would like to thank the three reviewers for their very helpful comments and suggestions which help improve this article greatly. Both authors are funded by the United Kingdom government's Higher Education Funding Council for England (HEFCE). YKT is also supported by the UK Research Council fellowship.

Authors' original submitted files for images

Competing interests

Authors' contributions

YKT conceived the ideas of this study, obtained and analysed the data, and wrote the first draft. MSG contributed to the discussion of the statistical analyses and revisions of the draft. Both authors read and approved the final manuscript.

The author(s) declare that they have no competing interests.

Below are the links to the authors' original submitted files for images.

References

1. The Daily Telegraph website. Accessed on 26 April 2007, [http://telegraph.co.uk/news/main.jhtml?xml=/news/2007/04/24/nhs24.xml ]

2. Dr Foster Intelligence. How healthy is your hospital?. Accessed on 25/04/06, [http://www.drfosterintelligence.co.uk/hospitalguide/index.asp ]

3. Department of Health, Hospital Episode Statistics website. Accessed on 21 July 2007, [http://www.hesonline.nhs.uk/Ease/servlet/ContentServer?siteID=1937&categoryID=212 ]

4. Spiegelhalter DJ: Mortality and volume of cases in paediatric cardiac surgery: retrospective study based on routinely collected data. BMJ. 2001, 323: 1-5. 10.1136/bmj.323.7303.1.

5. Spiegelhalter DJ: Handling over-dispersion of performance indicators. Quality and Safety in Health Care. 2005, 14: 347-351. 10.1136/qshc.2005.013755.

6. Marshall T, Mohammed MA: Case-mix and the use of control charts in monitoring mortality rates after coronary artery bypass. BMC Health Services Research. 2007, 7: 63-10.1186/1472-6963-7-63.

7. Pitches DW, Mohammed MA, Lilford RJ: What is the empirical evidence that hospitals with higher-risk adjusted mortality rates provide poorer quality care? A systematic review of the literature. BMC Health Services Research. 2007, 7: 91-10.1186/1472-6963-7-91.

8. Wainer H: The most dangerous equation. American Scientist. 2007, 65: 249-256.

9. Kirkwood B, Sterne JAC: Essential medical statistics. 2003, Oxford: Blackwell Science Ltd, 2

10. Spiegelhalter DJ: Problems in assessing rates of infection with methicillin resistant Staphylococcus aureus. BMJ. 2005, 331: 1013-1015. 10.1136/bmj.331.7523.1013.

11. Rice JA: Mathematical statistics and data analysis. 1995, Belmont: Duxbury Press, 2

12. Gill J: Essential mathematics for political and social research. 2006, New York: Cambridge University Press

13. Commission for Health Improvement: Deaths within 30 days of selected surgical procedures. 2003, (accessed July 2007), [http://www.chi.nhs.uk/Ratings/ ]

# data[].attributes.attachment_link.title
The most dangerous hospital or the most dangerous equation?

# data[].attributes.attachment_link.description
Hospital mortality rates are one of the most frequently selected indicators for measuring the performance of NHS Trusts. A recent article in a national newspaper named the hospital with the highest or lowest mortality in the 2005/6 financial year; a report by the organization Dr Foster Intelligence provided information with regard to the performance of all NHS Trusts in England.

# data[].attributes.body
(temporary edtion)

# data[].attributes.body
(temporary edition)

# data[].attributes.attachment_link.description
Accessibile dalla rete di Ateneo (o da casa attraverso EZ Proxy ) la banca dati Access Medicine, costituita principalmente da e-book costantemente aggiornati e che trattano tutte le principali aree informative in campo medico. Vai alla banca dati...

# data[].attributes.attachment_link.readable_text
Python is a programming language that lets you work quickly and integrate systems more effectively. Learn More

Fundraiser deal on now: Get a discount on PyCharm + all proceeds go to the Python Software Foundation. Ending soon! GET THE DEAL

# data[].attributes.attachment_link.keywords[]
python programming language object oriented web free open source software license documentation download community

# data[].attributes.attachment_link.description
The official home of the Python Programming Language

# data[].attributes.body
your local data

# data[].attributes.attachment_link.description
Learn how to import data in R from Excel, SAS, SPSS, and Text.

# data[].attributes.body
public data

# data[].attributes.attachment_link.readable_text
As I'm sure many statisticians do, I keep a folder of "stock code", or template scripts that do different things. This folder is always growing and the scripts are always improving, but there are a few in there that I think are worth sharing. Some of these are templates for common analyses, while others are just reminders of how to use a couple of commands to accomplish a practical task.

This post is of the latter type. I'm going to discuss fetching data from a URL.

Why might one need to fetch data from a URL?

Whatever your reason may be, it's a neat trick, but it's not one I use so often that I can just rattle off the code for it from memory. So here's my template. I hope it can help someone else.

Caveat!!!

This is only for data that is in tabular form already. This is not for web scraping (i.e. extracting a table of data from a Wikipedia page.) There are entire packages devoted to that. This is for the simplest of all cases where there is a .csv file or a .txt file (or similar) at a URL and you want to read it into R directly from that URL without the intermediate step of saving it somewhere on your computer.

Using data.table's fread()

I love the data.table package. I use it every day, for almost every project I do. It's an extension of the data.frame object class in R that makes many improvements. One of those improvements is in the function fread(). It's data.table's answer to base R's read.csv(). It does many things better, but here I'm only going to address its ability to read data right from the web. As a primer, its typical use on a data file residing on your computer would look something like this:

Reading data from a source on the web is no different. The example the package authors give in the help file (?fread) is this:

 V1 V2 V3 V4 V5
1: 1 307 930 36.58 0
2: 2 307 940 36.73 0
3: 3 307 950 36.93 0
4: 4 307 1000 37.15 0
5: 5 307 1010 37.23 0
6: 6 307 1020 37.24 0

Now if you actually navigate to that link in your browser, you won't see anything, but a download dialog should pop up. If you navigate to the parent directory of that address, http://www.stats.ox.ac.uk/pub/datasets/csb you will see some text further down the page you will see several links to data files. Each of these links launches a download dialog when clicked. To grab the URL of the data file to pass to fread(), right click the link and select "Copy link address". Other data files online might appear in the browser instead of launching download dialog, like this one a professor of mine had us use for an assignment. fread() handles these URLs just the same.

fread() makes smart decisions about how to read the data in (it detects column names and classes and so on), but the command has several arguments for specifying such things as well that you can use at your own discrimination. I find fread('filename') almost always just works, but sometimes there are reasons to be more explicit when reading data in.

Using RStudio

If you're not familiar with RStudio, you are a true R novice. If you know what it is, but don't use it, skip ahead.

In RStudio, you can click "Tools" -> "Import Dataset" -> "From Web URL" and a dialog will pop up asking you for a URL. Paste a URL into the dialog box (let's just use the same one as before: http://www.stats.ox.ac.uk/pub/datasets/csb/ch11b.dat) and click "OK". A nice little window pops up and allows you to specify how the data should be read and what name the object should be given in R. When you click "Import", the data is read in and some code appears in the console. What this interface does is download the data to a temporary file in a temporary folder and then read it in. The downloaded data file persists on your hard drive as long as your R session lasts, but disappears as soon as your R session ends.

This is handy, but if you wanted to repeat the process, you would have to click through the menu again and supply the data URL again. This isn't exactly "repeatable" in the Stack Overflow sense of the word.

Using RCurl's getURL()

The RCurl package provides bindings to the cURL library. This is a C library for web connections. The cURL library does way more than we need for this task and frankly, I don't understand a lot of it. I saved RCurl for last because iI usually try fread() first, and then if I get some sort of error, I resort to RCurl. Take for example the data set at this link: https://sakai.unc.edu/access/content/group/3d1eb92e-7848-4f55-90c3-7c72a54e7e43/public/data/bycatch.csv (also posted by a professor for an assignment of mine). If you try to fread() it, no dice. I have no idea what that error message means, but here's how to get that data set in anyway.

What are the arguments ssl.verifyhost=F and ssl.verifypeer=F doing? To be quite honest, I don't really know. But if I'm having trouble reading from a URL I try specifying these arguments and changing one or both to FALSE almost always circumvents whatever error I'm getting.

This grabs the content residing at the specified URL, but doesn't return a data.frame object. It has simply put the URL's content into a string.

[1] "character"

So how to get this into a data.frame object? We'll use textConnection() to open a "connection" with the string, much like you would open a connection with a file on your hard drive in order to read it. Then we'll have read.csv() (or you could use read.table() or fread() or similar) to read the string object like a text file and create a data.frame object.

 Season Area Gear.Type Time Tows Bycatch
1 1989-90 North Bottom Day 48 0
2 1989-90 North Bottom Night 6 0
3 1989-90 North Mid-Water Night 1 0
4 1989-90 South Bottom Day 139 0
5 1989-90 South Mid-Water Day 6 0
6 1989-90 South Bottom Night 6 0

And there you have it. The data from the URL is now in a data.frame and ready to go.

Aside: read.csv() is just a vesion of read.table() with argument defaults such as sep = "," that make sense for reading .csv files.

A Use Case

Let's pretend I want to automate something having to do with weather in Chicago. Maybe it's a knitr document that I have scheduled to re-knit every night on my server. Every time the script re-runs, it should somehow take into account recent weather in Chicago. Weather Undergroundoffers historic (and an hour ago counts as "historic") hourly weather data for many different locations. Many of these locations are airports, which for obvious reasons, have several meteorological sensors on site. On the Weather Underground page you can select a location and a date and see hourly weather for that calendar day. At the bottom of the page, you can click "Comma Delimited File" to see the data in comma delimited format - perfect for reading into R.

I see that the four letter airport code for Chicago is "KMDW" and after clicking through a few of these URLs, I see the stuff after "DailyHistory.html" doesn't change. So if I know the date, I can construct the URL where the hourly Chicago airport wether for that date can be found in .csv format.

First, I define the beginning and end of the URL, which never change.

baseURL 'http://www.wunderground.com/history/airport/KMDW'
suffixURL 'DailyHistory.html?HideSpecis=1&format=1'

There is opportunity here to generalize this for many locations if one simply maps the four letter codes to other locations of interest using switch() or similar.

Then I ask the system for todays date and from it produce a string having format year/month/day.

Then I piece all of these strings together to get a URL which will lead to a .csv file of today's weather in Chicago.

Finally I grab the content of the webpage at that URL using the RCurl method described above. I choose getURL() instead of fread() for good reason; I'll need to do some find-and-replace to clean up some html artifacts in the data and that is more efficient to do on one big string rather than on a bunch of individual values in a data.frame.

Now I have the content of the page in a string and I want to read that string into a data.frame object, but every line of the data ends with an html newline ("
") and a text newline ("n"). read.csv() will recognize the "n" as a signal to start a new row of the data.frame, but the "
" isn't recognized and will be appended to the value in the last column of every row. So let's take care of this before read.csv() ever gets involved. I'll do a simple find-and-replace where I find "
" and replace it with an empty string (""), aka nothing. This is the regex way of find-and-delete.

Finally I can "read" the data into a data.frame object with the help of read.csv() and textConnection().

 TimeCST TemperatureF Dew.PointF Humidity Sea.Level.PressureIn
1 12:22 AM 21.9 17.1 82 30.02
2 12:53 AM 21.9 16.0 78 30.07
3 1:53 AM 21.9 15.1 75 30.09
4 2:24 AM 21.0 14.0 74 30.04
5 2:39 AM 21.0 14.0 74 30.04
6 2:53 AM 21.0 15.1 78 30.09
 VisibilityMPH Wind.Direction Wind.SpeedMPH Gust.SpeedMPH PrecipitationIn
1 1.0 NNE 13.8 - 0.01
2 1.0 NNE 15.0 - 0.01
3 4.0 NNE 11.5 - 0.00
4 2.5 NNE 16.1 - 0.00
5 1.5 NNE 12.7 - 0.00
6 1.8 NNE 12.7 - 0.00
 Events Conditions WindDirDegrees DateUTC
1 Snow Snow 30 2015-02-26 06:22:00
2 Snow Light Snow 30 2015-02-26 06:53:00
3 Snow Light Snow 30 2015-02-26 07:53:00
4 Snow Light Snow 30 2015-02-26 08:24:00
5 Snow Light Snow 30 2015-02-26 08:39:00
6 Snow Light Snow 30 2015-02-26 08:53:00

Glorious.

To leave a comment for the author, please follow the link and comment on their blog: bRogramming.

R-bloggers.com offers daily e-mail updates about R news and tutorials on topics such as: Data science, Big Data, R jobs, visualization ( ggplot2, Boxplots, maps, animation), programming ( RStudio, Sweave, LaTeX, SQL, Eclipse, git, hadoop, Web Scraping) statistics ( regression, PCA, time series, trading) and more...

If you got this far, why not subscribe for updates from the site? Choose your flavor: e-mail, twitter, RSS, or facebook...

# data[].attributes.attachment_link.description
Getting Data From One Online SourceRobert NorbergHello world. It's been a long time since I posted anything here on my blog. I've been busy getting my Masters degree in statistical computing and I haven't had much free time to blog. But I've writing R code as much as ever.

# data[].attributes.body
didactical examples

# data[].attributes.attachment_link.description
Passenger Miles on Commercial US Airlines, 1937-1960

# data[].attributes.body
how to import data in R

# data[].attributes.attachment_link.readable_text
Welcome to the R Graph Gallery. Looking for inspiration or help concerning data visualisation? Here, you will find hundreds of distinctive graphics made with the R programming language, always with the reproducible code snippet

available. Charts are displayed in several sections represented by the icons below. The gallery dedicates a special section to tricks you can use with the ggplot2 library. If you are looking to browse for inspiration, the all graph

page displays all the charts of the gallery in a row. Feel free to propose a chart or report a bug; any feedback is highly welcome. Stay in touch with the gallery by following it on Twitter or Facebook, or by subscribing to the blog.

Sponsors
Search

# data[].attributes.attachment_link.description
Welcome to the R Graph Gallery. Looking for inspiration or help concerning data visualisation? Here, you will find hundreds of distinctive graphics made with the R programming language, always with the reproducible code snippet available. Charts are displayed in several sections represented by the icons below.

# data[].attributes.attachment_link.description
Rcommander Rcmdr a simple GUI interface for R

# data[].attributes.attachment_link.description
This website is for both current R users and experienced users of other statistical packages (e.g., SAS, SPSS, Stata) who would like to transition to R.

# data[].attributes.attachment_link.description
Statistical tools for data analysis and visualization

# data[].attributes.attachment_link.readable_text
Author: Carlos Alberto Gómez Grajales

Date: 19 Nov 2015

Copyright: Image appears courtesy of ClipArt.com

Any particular day seems to be fit to change history. For instance, on May 5, 1976, Argentine former football player Juan Pablo Sorín was born. He played for many teams, such as River Plate, Cruzeiro, Paris Saint-Germain and Barcelona [1]. On that very same Wednesday in 1976, David Bowie held a concert at the Empire Pool in London, just a few years before it changed its name to Wembley Arena [2]. And as a matter of fact, another event took place on that same day: May 5, 1976. It was an event that would trigger one of the most notorious revolutions in statistics, one that we are still witnessing up to this day.

It was an informal meeting of just five people, who gathered at Murray Hill, New Jersey [3]. They all worked at Bell Labs and gathered to discuss ideas for designing a system for statistical computing, or perhaps adopting an existing system for their research work. Ideally the system would be used by around 20 statisticians who worked at Bell Labs, or so the team thought. Back in the 1970s, computers were, of course, far different from what we have now and statistical systems were also still in a rudimentary phase. At that time, the statistical analysis group of Bell Labs used mostly a library of Fortran-based software, designed to produce simulations, data analysis and graphs, though these tools were too restricted for their research purposes. They needed something new, but it wasn't until after a month of meetings that the team decided to go ahead and create a new system.

The ideas that flowed in those first meetings would become foundations for what statistical software would be. Many, many years before the open software movement (the open source initiative would not exist until the 90's), the team at Bell Labs considered that the extensibility of the software needed to be incorporated at a fundamental level, something quite unusual for statistical software at the time. It was the collaborative research environment the team embraced what allowed them to identify the many advantages of extensible, adaptable software.

Two of the original five people in the room became the leaders of the project: Rick Becker and John Chambers, who worked in developing the system for many months, with occasional inputs from other colleagues. By the end of that year "The system", as it was initially called, was ready in a preliminary state. Everyone noticed that "The system" wasn't a particularly inspiring name; so many other suggestions were made including Interactive SCS (ISCS), Statistical Computing System, and Statistical Analysis System, though that last one was already taken by the software team at SAS. Due to the fact that none of the names was widely accepted, and noticing that most of the names had an S in them, the new software was simply called "S". Besides, that would also make the system consistent with the name of another language that was developed in Bell Labs around that time: the "C" programming language.

At first, S was developed in a local computer system, to be used only by the initial research team, but interest in the system grew quickly, so S was later developed under a portable version of UNIX, that could be used on other computers. That development would become S version 2, which was the first version ever to be commercially licensed. This would also mark the first time the system would leave Bell Labs, reaching a number of researchers in another companies, as well as some universities. This was important because the system was now being tested by more professionals, providing feedback and ideas for the core team. It was also notable because the list of new users included two remarkable statisticians at the University of Auckland in New Zealand.

Ross Ihaka and Robert Gentleman were among the first avid users of S outside of Bell Labs, during their time at the University of Auckland, where they gave lectures on statistics. They noticed, and often discussed, the fact that the then current implementations of the S language and many other systems at the time were still hard for their college students to grasp [5]. Just like S, other analysis software available 25 years ago had been designed by researchers, so they were indeed hard to use at the time. It was during a hallway conversation that the pair decided they wanted a technology better suited for their statistics students. At first, developing the language was a mere hobby for the professors, considering that none of them had any deep computer science training. But starting in 1991, both Ihaka and Gentleman started working full time in developing their new software.

R owes a huge debt to its grandfather, the S computer language. There's no better example than the name itself. As you can imagine, the name is partly a play on the name of the Bell Labs language, but it is also based on the names of the two R authors: Robert Gentleman and Ross Ihaka. Besides that, R can actually be considered a different version of S [6]. In fact, the official R system webpage is not shy to discuss its rooted origins in the S- language [7]. The web itself describes R as simply another implementation of the S engine:

"We can regard S as a language with three current implementations or "engines", the "old S engine" (S version 3; S-PLUS 3.x and 4.x), the "new S engine" (S version 4; S-PLUS 5.x and above), and R. Given this understanding, asking for "the differences between R and S" really amounts to asking for the specifics of the R implementation of the S language, i.e., the difference between the R and S engines."[7]

The R system was originally designed using a language largely compatible with S. There were some important differences though, such as the use of a different evaluation model (one in which nested function definitions are lexically scoped) and some additional features borrowed from the Lisp/Scheme family of languages. Still, many commands written for S ran unaltered under R: drawing histograms, defining data.frame objects and many other basic operations were exactly the same.

The open-source nature of R was a key component of its success. As it is, any user can contribute "packages" that extend R's capabilities. Right now you can find community created tools for R that allow you to perform many modern statistical tools, some of which are not available in other commercial software. The extensibility of R has grown even beyond that. There are packages that allow you to create interactive visualizations, maps, or web-based applications, all within R. Ihaka himself attributed the accomplishments of R to its collaborative nature...

R was first introduced to the world in a 1996 paper, where Ihaka and Gentleman presented it as the combination of two existing computer languages: S and Scheme [8]. By combining the strong points in each of these programming syntaxes, they created a language that looks like S on the surface, but that has a Scheme implementation beneath. The first version of R was described as "rough" by some statisticians who saw the system back there but, despite its flaws, R grabbed the attention of academics and students alike due to the fact that it followed a popular trend that developed along with it during the 1990s: the open-source movement.

Open-source software is a term used to describe computer software which makes the source code used to create it openly available to the users. The copyright provides rights to study, change and distribute the software for any purpose. This allows a collaborative environment where many people around the globe can tweak, modify and improve the software in question. As a result, open-software is upgraded at a faster pace than many other commercial choices. Open software is not limited at all to statistical systems; there are many other fields that have also witnessed the rise of open-source programs: You can, quite easily, find graphics editors, e-mail clients, instant-messaging clients, speech recognition systems or tools for quantum chemistry amongst open-source software lists [9].

The open-source nature of R was a key component of its success. As it is, any user can contribute "packages" that extend R's capabilities. Right now you can find community created tools for R that allow you to perform many modern statistical tools, some of which are not available in other commercial software. The extensibility of R has grown even beyond that. There are packages that allow you to create interactive visualizations, maps, or web-based applications, all within R. Ihaka himself attributed the accomplishments of R to its collaborative nature:

"R is a real demonstration of the power of collaboration, and I don't think you could construct something like this any other way. We could have chosen to be commercial, and we would have sold five copies of the software." [5]

After its initial development, Ihaka and Gentleman were joined by many other professionals, all volunteers, who contributed to the development of the system. The "R Development Core Team" is the group responsible for the development of the language, those who can modify the official R source code archive [7]. The core team is the group responsible for the latest updates and developments of the software, although they have the aid of thousands of users who report bugs or glitches. The group includes personalities such as Doug Bates, Thomas Lumley, Brian Ripley and John Chambers, one of the original creators of S, among other statisticians and data analysts. The team founded the R foundation in 2003, a non-profit organization based in Austria, as a means to provide support for the R project and other developments in statistical computing [7].

The fact that Chambers changed "teams" by joining the R core development group does not mean that S is gone. Actually, the S language is still used to this day, with its last major redesign published in 1998. S was purchased in 2004 by the Insightful Corporation, which commercializes it in the S-Plus system. But S has long since been eclipsed by the rising popularity of its younger brother. Chambers himself declared that "R has grown and spread beyond anything the original authors of S are likely to have imagined" [3]. It is hard to estimate the number of R users in the world, but Revolution Analytics, creators of an enhanced distribution of R claim the number surpasses 2 million [10].

And despite the fact the software is free and open-source it has gathered some prominent advocates. As avid users of R, we can count companies like Google, who use the software to analyse trends in ad pricing, or Pfizer, where customized packages have been developed to aid in the study of non-clinical trials [5]. Microsoft has recently embraced R as well, using the software to fit forecasting models, tune fraud detection algorithms and improve Azure's server reliability [11]. Even the Xbox brand is using R to improve matchmaking in online gaming. But Microsoft is not only viewing R as a business tool, but also as an investment. Microsoft acquired Revolution Analytics at the beginning of 2015, thus opening a window for a future distribution of Revolution R that uses both the Cloud infrastructure of Microsoft along with its database management suits. And why not? Maybe in some years, Microsoft can tackle some of the most notorious disadvantages of R.

As you well know, even after almost 20 years since R was introduced to the world, it is still far from perfect. R is notoriously hard to learn and rather complicated to use for some tasks, due to its intricate syntax. It really is hard to believe the system was initially devised as "easy-to-use" software. Although R can produce complex analysis few other software can match, sometimes producing simple procedures, like tabulations, can become a cumbersome task. And even after you finally get an output, obtaining print quality results or formatting them requires additional work. As such, some challengers of R have appeared, many of them aiming to fill the gap that R still has: simplicity. One of such challengers is Python, a more sophisticated programming language with a more "natural" syntax [12]. Recently, some Python libraries have extended the analytic capabilities of the system, turning the language into a powerful statistical toolbox. But even for those who aren't too thrilled with programming, there are some available, open-source, point-and-click options [13]. Open-source software has become more prominent and reliable and, at least in our field, R is partially responsible for that. A few years back, "free" software would usually be associated with "bad" software, but R has dramatically changed that notion. Many of the free alternatives just discussed have a fighting chance to be noticed thanks to R.

R has, in some way, changed how we do statistics, by igniting a movement that has resulted in dozens of easily available analytical tools for researchers, everywhere. More interesting perhaps, R and its history is a parallel of the collaborative effort of a statistician's work. Collaborating was always a part of the statistician's mindset and both S and R drew from that practice to become one of the most important statistical tools worldwide. Created by statisticians for statisticians, the software can be regarded as an ambassador of the statistician's working collaborative environment.

[1] Juan Pablo Sorin. Wikipedia - The Free Encyclopedia.
https://en.wikipedia.org/wiki/Juan_Pablo_Sorín

[2] Isolar - 1976 Tour. Wikipedia - The Free Encyclopedia.
https://en.wikipedia.org/wiki/Isolar_-_1976_Tour

[3] Chambers, John. Software for Data analysis - Programming with R. Springer, Jun 14, 2008

[4] S - Programming Language. Wikipedia - The Free Encyclopedia
https://en.wikipedia.org/wiki/S_(programming_language)

[5] Data Analysts Captivated by R's Power. The New York Times (January, 2009)
http://www.nytimes.com/2009/01/07/technology/business-computing/07program.html

[6] What is R? - The R project official website.
https://www.r-project.org/about.html

[7] R FAQ- The R project official website.
https://cran.r-project.org/doc/FAQ/R-FAQ.html

[8] Ihaka, Ross & Gentleman, Robert. R: A Language for Data analysis and Graphics. Journal of Computational and Graphical Statistics, Volume 5. Number 3, Pages 299-314.

[9] List of free and open-source software packages. Wikipedia - The Free Encyclopedia.
https://en.wikipedia.org/wiki/List_of_free_and_open-source_software_packages

[10] Community - Revolution Analytics Website
http://www.revolutionanalytics.com/community

[11] R at Microsoft - Revolution Analytics Blog
http://blog.revolutionanalytics.com/2015/06/r-at-microsoft.html

[12] The Python programming language. Python Official Website
https://www.python.org

[13] PSPP. GNU PSPP Official Website
https://www.gnu.org/software/pspp/

# data[].attributes.attachment_link.title
Created by statisticians for statisticians: How R took the world of statistics by storm

# data[].attributes.attachment_link.description
Author: Carlos Alberto Gómez Grajales Date: 19 Nov 2015 Copyright: Image appears courtesy of ClipArt.com Any particular day seems to be fit to change history. For instance, on May 5, 1976, Argentine former football player Juan Pablo Sorín was born. He played for many teams, such as River Plate, Cruzeiro, Paris Saint-Germain and Barcelona [1].

# data[].attributes.body
youtube tutorial

# data[].attributes.attachment_link.description
Enjoy the videos and music you love, upload original content, and share it all with friends, family, and the world on YouTube.

# data[].attributes.body
online book

# data[].attributes.body
online book

# data[].attributes.attachment_link.readable_text
This is the website for the first edition of "R for Data Science", published January 2017.

This book is now out-of-date and instead we recommend the 2nd edition at http://r4ds.hadley.nz/ which was published in June 2023.

R4DS teaches you how to do data science with R: You'll learn how to get your data into R, get it into the most useful structure, transform it, visualise it and model it. In this book, you will find a practicum of skills for data science. Just as a chemist learns how to clean test tubes and stock a lab, you'll learn how to clean data and draw plots-and many other things besides. These are the skills that allow data science to happen, and here you will find the best practices for doing each of these things with R. You'll learn how to use the grammar of graphics, literate programming, and reproducible research to save time. You'll also learn how to manage cognitive resources to facilitate discoveries when wrangling, visualising, and exploring data.

This website is (and will always be) free to use, and is licensed under the Creative Commons Attribution-NonCommercial-NoDerivs 3.0 License. If you'd like a physical copy of the book, you can order it from amazon. If you'd like to give back please make a donation to Kākāpō Recovery: the kākāpō (which appears on the cover of R4DS) is a critically endangered native NZ parrot; there are only 213 left.

Please note that R4DS uses a Contributor Code of Conduct. By contributing to this book, you agree to abide by its terms.

Acknowledgements

R4DS is a collaborative effort and many people have contributed fixes and improvements via pull request: adi pradhan (@adidoit), Andrea Gilardi (@agila5), Ajay Deonarine (@ajay-d), @AlanFeder, pete (@alonzi), Alex (@ALShum), Andrew Landgraf (@andland), @andrewmacfarland, Michael Henry (@aviast), Mara Averick (@batpigandme), Brent Brewington (@bbrewington), Bill Behrman (@behrman), Ben Herbertson (@benherbertson), Ben Marwick (@benmarwick), Ben Steinberg (@bensteinberg), Brandon Greenwell (@bgreenwell), Brett Klamer (@bklamer), Christian Mongeau (@chrMongeau), Cooper Morris (@coopermor), Colin Gillespie (@csgillespie), Rademeyer Vermaak (@csrvermaak), Abhinav Singh (@curious-abhinav), Curtis Alexander (@curtisalexander), Christian G. Warden (@cwarden), Kenny Darrell (@darrkj), David Rubinger (@davidrubinger), David Clark (@DDClark), Derwin McGeary (@derwinmcgeary), Daniel Gromer (@dgromer), @djbirke, Devin Pastoor (@dpastoor), Julian During (@duju211), Dylan Cashman (@dylancashman), Dirk Eddelbuettel (@eddelbuettel), Edwin Thoen (@EdwinTh), Ahmed El-Gabbas (@elgabbas), Eric Watt (@ericwatt), Erik Erhardt (@erikerhardt), Etienne B. Racine (@etiennebr), Everett Robinson (@evjrob), Flemming Villalona (@flemingspace), Floris Vanderhaeghe (@florisvdh), Garrick Aden-Buie (@gadenbuie), Garrett Grolemund (@garrettgman), Josh Goldberg (@GoldbergData), bahadir cankardes (@gridgrad), Gustav W Delius (@gustavdelius), Hadley Wickham (@hadley), Hao Chen (@hao-trivago), Harris McGehee (@harrismcgehee), Hengni Cai (@hengnicai), Ian Sealy (@iansealy), Ian Lyttle (@ijlyttle), Ivan Krukov (@ivan-krukov), Jacob Kaplan (@jacobkap), Jazz Weisman (@jazzlw), John D. Storey (@jdstorey), Jeff Boichuk (@jeffboichuk), Gregory Jefferis (@jefferis), 蒋雨蒙 (@JeldorPKU), Jennifer (Jenny) Bryan (@jennybc), Jen Ren (@jenren), Jeroen Janssens (@jeroenjanssens), Jim Hester (@jimhester), JJ Chen (@jjchern), Joanne Jang (@joannejang), John Sears (@johnsears), @jonathanflint, Jon Calder (@jonmcalder), Jonathan Page (@jonpage), Justinas Petuchovas (@jpetuchovas), Jose Roberto Ayala Solares (@jroberayalas), Julia Stewart Lowndes (@jules32), Sonja (@kaetschap), Kara Woo (@karawoo), Katrin Leinweber (@katrinleinweber), Karandeep Singh (@kdpsingh), Kyle Humphrey (@khumph), Kirill Sevastyanenko (@kirillseva), @koalabearski, Kirill Müller (@krlmlr), Noah Landesberg (@landesbergn), @lindbrook, Mauro Lepore (@maurolepore), Mark Beveridge (@mbeveridge), Matt Herman (@mfherman), Mine Cetinkaya-Rundel (@mine-cetinkaya-rundel), Matthew Hendrickson (@mjhendrickson), @MJMarshall, Mustafa Ascha (@mustafaascha), Nelson Areal (@nareal), Nate Olson (@nate-d-olson), Nathanael (@nateaff), Nick Clark (@nickclark1000), @nickelas, Nirmal Patel (@nirmalpatel), Nina Munkholt Jakobsen (@nmjakobsen), Jakub Nowosad (@Nowosad), Peter Hurford (@peterhurford), Patrick Kennedy (@pkq), Radu Grosu (@radugrosu), Ranae Dietzel (@Ranae), Robin Gertenbach (@rgertenbach), Richard Zijdeman (@rlzijdeman), Robin (@Robinlovelace), Emily Robinson (@robinsones), Rohan Alexander (@RohanAlexander), Romero Morais (@RomeroBarata), Albert Y. Kim (@rudeboybert), Saghir (@saghirb), Jonas (@sauercrowd), Robert Schuessler (@schuess), Seamus McKinsey (@seamus-mckinsey), @seanpwilliams, Luke Smith (@seasmith), Matthew Sedaghatfar (@sedaghatfar), Sebastian Kraus (@sekR4), Sam Firke (@sfirke), Shannon Ellis (@ShanEllis), @shoili, S'busiso Mkhondwane (@sibusiso16), @spirgel, Steven M. Mortimer (@StevenMMortimer), Stéphane Guillou (@stragu), Sergiusz Bleja (@svenski), Tal Galili (@talgalili), Tim Waterhouse (@timwaterhouse), TJ Mahr (@tjmahr), Thomas Klebel (@tklebel), Tom Prior (@tomjamesprior), Terence Teo (@tteo), Will Beasley (@wibeasley), @yahwes, Yihui Xie (@yihui), Yiming (Paul) Li (@yimingli), Hiroaki Yutani (@yutannihilation), @zeal626, Azza Ahmed (@zo0z)

R4DS is hosted by https://www.netlify.com as part of their support of open source software and communities.

# data[].attributes.attachment_link.description
This book will teach you how to do data science with R: You'll learn how to get your data into R, get it into the most useful structure, transform it, visualise it and model it. In this book, you will find a practicum of skills for data science.

# data[].attributes.body
online resources

# data[].attributes.attachment_link.readable_text
There are hundreds of websites that can help you learn R. Here's how you can use some of the best to become a productive R programmer.

Start by downloading R and RStudio.

Learn the basics

Take DataCamp's free R Tutorial to learn how to write basic R code or visit Try R by Code School. Both sites provide interactive lessons that will get you writing real code in minutes. They are a great place to make mistakes and test out new skills. You are told immediately when you go wrong and given a chance to fix your code.

Or try Leada. Leada gets you programming in your own environment with videos and exercises. The first few courses are free and cover how to install R and RStudio.

Broaden your skills

Work through The Beginner's Guide to R by Computerworld Magazine. This 30 page guide will show you how to install R, load data, run analyses, make graphs, and more.

Or try swirl, an R package designed to teach you R straight from the command line. Swirl provides exercises and feedback from within your R session to help you learn in a structured, interactive way.

Or attend an RStudio webinar. These free events teach you how do do useful things in R, and we're always making more. Our previous webinars are archived into several tracks for your viewing convenience:

Tip: Look at our two-part series on " Working with the RStudio IDE " at DataCamp to master all features of the IDE.

For a more complete education, read R for Data Science by Hadley Wickham and Garrett Grolemund. This book will teach you how to use the most modern parts of R to import, tidy, transform, visualize, and model data, as well as how to communicate findings with R Markdown. R for Data Science is available free online and is full of practical advice.

Practice good habits

Read the R Style Guide for advice on how to write readable, maintainable code. This is how other R users will expect your code to look when you share it.

Look up help

When you need to learn more about an R function or package, visit Rdocumentation.org, a searchable database of R documentation. You can search for R packages and functions, look at package download statistics, and leave and read comments about R functions.

If you need a quick reminder about how to wrangle data, make a graph, or do some other common task in R download one of our free R cheat sheets. These make handy reference guides to keep next to your work station.

Ask questions

Seek help at StackOverflow, a searchable forum of questions and answers about computer programming. StackOverflow has answered (and archived) over 40,000 questions related to R programming.

If you a have question that is more about statistical methodology, there are also plenty of R users active on the the CrossValidated Q&A community.

Attend a course

If you prefer a structured learning environment, attend one of theses MOOC's for an excellent introduction to the R language.

You can arrange a private or onsite course by contacting one of our training partners.

Keep tabs on the R community

Follow the RStudio blog to hear about our latest features, packages, and workshops. Our blog is a good place to find short tutorials about the packages we make. Follow the RStudio RViews blog for general interest articles about R and the R Community.

Read R bloggers, a blog aggregator that reposts R related articles from across the web. R bloggers is a good place to find R tutorials, announcements, and other random happenings.

Deepen your expertise

To attain the ultimate R expertise, read Hadley Wickham's Advanced R Programming book, which is available for free online at the link. Hadley explains in clear prose how R works from a computer science perspective.

Then, when you are ready, read Hadley's R Packages book to learn how to share your R tools with others. R Packages is also available free online at the link.

Or, take Hadley's online course " Writing Functions in R " where he teaches you the fundamentals of writing functions in R so you can make your code more readable, avoid coding errors, and automate repetitive tasks.

Got R down? Then give Shiny a try.

Shiny lets you share your results as interactive, eye-catching web apps that are friendly to non-programmers.

# data[].attributes.attachment_link.description
There are hundreds of websites that can help you learn R. Here's how you can use some of the best to become a productive R programmer. Take DataCamp's free R Tutorial to learn how to write basic R code or visit Try R by Code School.

# data[].attributes.body
Introductory Medical Statistics

# data[].attributes.attachment_link.description
Contents: Data presentation. -- Describing cuves and distributions. -- The normal distribution curve. -- Introduction to sampling, errors and accuracy. -- Introduction to probability. -- Binomial probabilities. -- Poisson probabilities. -- Introduction to statistical significance. -- The chi-squared test. -- The Fisher exact probability test. -- The t-test.

# data[].attributes.body
Syllabus