Use this tag for any *on-topic* question that (a) must have an `R`-based solution yet (b) is not *just* about how to program in `R`.

learn more… | top users | synonyms

175
votes
20answers
52k views

Python as a statistics workbench

Lots of people use a main tool like Excel or another spreadsheet, SPSS, Stata, or R for their statistics needs. They might turn to some specific package for very special needs, but a lot of things can ...
75
votes
5answers
39k views

Difference between logit and probit models

What is the difference between the logit and the probit model? I'm more interested here in knowing when to use logistic regression, and when to use probit. If there's any literature which define it ...
65
votes
21answers
12k views

Resources for learning R [duplicate]

I'm interested in learning R on the cheap. What's the best free resource/book/tutorial for learning R?
61
votes
21answers
25k views

R vs SAS, why is SAS preferred by private companies?

I learned R but it seems that companies are much more interested in SAS experience. What are the advantages of SAS over R?
58
votes
1answer
24k views

Interpretation of R's lm() output

the help pages in R assume I know what those numbers mean. I don't :) I'm trying to really intuitively understand every number here. I will just post the output and comment on what I found out. There ...
55
votes
7answers
63k views

How to summarize data by group in R?

I have R data frame like this: ...
51
votes
14answers
3k views

Complete substantive examples of reproducible research using R

The Question: Are there any good examples of reproducible research using R that are freely available online? Ideal Example: Specifically, ideal examples would provide: The raw data (and ideally ...
47
votes
14answers
35k views

Good GUI for R suitable for a beginner wanting to learn programming in R?

Is there any GUI for R that makes it easier for a beginner to start learning and programming in that language?
47
votes
6answers
4k views

Is the R language reliable for the field of economics?

I am a graduate student in economics who recently converted to R from other very well-known statistical packages (I was using SPSS mainly). My little problem at the moment is that I am the only R user ...
43
votes
1answer
5k views

R's lmer cheat-sheet

There's a lot of discussion going on on this forum about the proper way to specify various hierarchical models using lmer. I thought it would be great to have all ...
41
votes
2answers
5k views

Data APIs/feeds available as packages in R

EDIT: The Web Technologies and Services CRAN task view contains a much more comprehensive list of data sources and APIs available in R. You can submit a pull request on github if you wish to add a ...
38
votes
3answers
14k views

How to choose nlme or lme4 R library for mixed effects models?

I have fit a few mixed effects models (particularly longitudinal models) using lme4 in R but would like to really master the ...
36
votes
5answers
2k views

First R packages source code to study in preparation for writing own package

I'm planning to start writing R packages. I thought it would be good to study the source code of existing packages in order to learn the conventions of package construction. My criteria for good ...
31
votes
7answers
3k views

Graphical data overview (summary) function in R

I'm sure I've come across a function like this in an R package before, but after extensive Googling I can't seem to find it anywhere. The function I'm thinking of produced a graphical summary for a ...
31
votes
2answers
67k views

How do I get the number of rows of a data.frame in R? [closed]

After reading a dataset: dataset <- read.csv("forR.csv") How can I get R to give me the number of cases it contains? Also, will the returned value include of ...
30
votes
5answers
4k views

Alternatives to logistic regression in R

I would like as many algorithms that perform the same task as logistic regression. That is algorithms/models that can give a prediction to a binary response (Y) with some explanatory variable (X). ...
30
votes
2answers
5k views

Conditional inference trees vs traditional decision trees

Can anyone explain the primary differences between conditional inference trees (ctree from party package in R) compared to the ...
29
votes
1answer
5k views

Removal of statistically significant intercept term boosts $R^2$ in linear model

In a simple linear model with a single explanatory variable, $\alpha_i = \beta_0 + \beta_1 \delta_i + \epsilon_i$ I find that removing the intercept term improves the fit greatly (value of $R^2$ ...
28
votes
5answers
9k views

Which permutation test implementation in R to use instead of t-tests (paired and non-paired)?

I have data from an experiment that I analyzed using t-tests. The dependent variable is interval scaled and the data are either unpaired (i.e., 2 groups) or paired (i.e., within-subjects). E.g. ...
28
votes
3answers
10k views

Best way to present a random forest in a publication?

I am using the random forest algorithm as a robust classifier of two groups in a microarray study with 1000s of features. What is the best way to present the random forest so that there is enough ...
28
votes
3answers
6k views

Clojure versus R: advantages and disadvantages for data analysis

I had a plan of learning R in the near future. Reading another question I found out about Clojure. Now I don't know what to do. I think a big advantage of R for me is that some people in Economics ...
27
votes
6answers
9k views

When is it ok to remove the intercept in lm()?

I am running linear regression models and wondering what the conditions are for removing the intercept term of lm()? In comparing results from two different lm ...
27
votes
4answers
5k views

How to deal with perfect separation in logistic regression?

If you have a variable which perfectly separates zeroes and ones in target variable, R will yield the following "perfect or quasi perfect separation" warning message: ...
27
votes
3answers
28k views

How can I change the title of a legend in ggplot2? [closed]

I have a plot I'm making in ggplot2 to summarize data that are from a 2 x 4 x 3 celled dataset. I have been able to make panels for the 2-leveled variable using ...
27
votes
4answers
963 views

What is a good use of the 'comment' function in R?

I just discovered the comment function in R. Example: ...
26
votes
5answers
13k views

What do the residuals in a logistic regression mean?

In answering this question John Christie suggested that the fit of logistic regression models should be assessed by evaluating the residuals. I'm familiar with how to interpret residuals in OLS, they ...
26
votes
3answers
1k views

Cloud computing platforms for machine learning

I've got a small list of companies that provide a platform for running R, python, or octave scripts on clusters built on top of amazon EC2. Are there other names I should add? Cloudnumbers Opani ...
25
votes
5answers
1k views

Line graph has too many lines, is there a better solution?

I'm trying to graph the number of actions by users (in this case, "likes") over time. So I have "Number of actions" as my y-axis, my x-axis is time (weeks), and each line represents one user. My ...
25
votes
7answers
641 views

How to increase longer term reproducibility of research (particularly using R and Sweave)

Context: In response to an earlier question about reproducible research Jake wrote One problem we discovered when creating our JASA archive was that versions and defaults of CRAN packages ...
25
votes
4answers
1k views

OpenBugs vs. JAGS

I am about to try out a BUGS style environment for estimating Bayesian models. Are there any important advantages to consider in choosing between OpenBugs or JAGS? Is one likely to replace the other ...
24
votes
3answers
2k views

What is the meaning of the “.” (dot) in R?

I'm just reading the book "R in a Nutshell". And it seems as if I skipped the part where the "." as in "sample.formula" was explained. ...
24
votes
5answers
7k views

Time series 'clustering' in R

I have a set of time series data. Each series covers the same period, although the actual dates in each time series may not all 'line up' exactly. That is to say, if the Time series were to be read ...
24
votes
1answer
10k views

How to interpret coefficients in a Poisson regression?

How can I interpret the main effects (coefficients for dummy-coded factor) in a Poisson regression? Assume the following example: ...
24
votes
1answer
1k views

How to determine significant principal components using bootstrapping or Monte Carlo approach?

I am interested in determining the number of significant patterns coming out of a Principal Component Analysis (PCA) or Empirical Orthogonal Function (EOF) Analysis. I am particularly interested in ...
23
votes
6answers
4k views

Is there a good browser/viewer to see an R dataset (.rda file)

I want to browse a .rda file (R dataset). I know about the View(datasetname) command. The default R.app that comes for Mac does not have a very good browser for ...
23
votes
6answers
289 views

Standard errors for lasso prediction using R

I'm trying to use a LASSO model for prediction, and I need to estimate standard errors. Surely someone has already written a package to do this. But as far as I can see, none of the packages on CRAN ...
23
votes
7answers
3k views

How can I efficiently model the sum of Bernoulli random variables?

I am modeling a random variable ($Y$) which is the sum of some ~15-40k independent Bernoulli random variables ($X_i$), each with a different success probability ($p_i$). Formally, $Y=\sum X_i$ where ...
23
votes
3answers
2k views

Why does including latitude and longitude in a GAM account for spatial autocorrelation?

I have produced generalized additive models for deforestation. To account for spatial-autocorrelation, I have included latitude and longitude as a smoothed, interaction term (i.e. s(x,y)). I've based ...
23
votes
3answers
2k views

Box-Cox like transformation for independent variables?

Is there a Box-Cox like transformation for independent variables? That is, a transformation that optimizes the $x$ variable so that the y~f(x) will make a more ...
23
votes
3answers
3k views

Is it possible to do time-series clustering based on curve shape?

I have sales data for a series of outlets, and want to categorise them based on the shape of their curves over time. The data looks roughly like this (but obviously isn't random, and has some missing ...
23
votes
5answers
6k views

What book is recommendable to start learning statistics using R at the same time?

Books to Learn Statistics using R What exactly is the book I'm looking for. What I am looking for is a book that teaches you statistics while using R to give you hands-on experience and thus end up ...
22
votes
23answers
5k views

What R packages do you find most useful in your daily work?

Duplicate thread: I just installed the latest version of R. What packages should I obtain? What are the R packages you couldn't imagine your daily work with data? Please list both general and ...
21
votes
5answers
4k views

Timing functions in R

I would like to measure the time that it takes to repeat the running of a function. Are replicate() and using for-loops equivalent? For example: ...
21
votes
3answers
1k views

Visualizing a million, PCA edition

Is it possible to visualize the output of Principal Component Analysis in ways that give more insight than just summary tables? Is it possible to do it when the number of observations is large, say ...
21
votes
1answer
2k views

For which distributions are the parameterizations in BUGS and R different?

I have found some distributions for which BUGS and R have different parameterizations: Normal, log-Normal, and Weibull. For each of these, I gather that the second parameter used by R needs to be ...
21
votes
4answers
2k views

How to do dimensionality reduction in R

I have a matrix where a(i,j) tells me how many times individual i viewed page j. There are 27K individuals and 95K pages. I would like to have a handful of "dimensions" or "aspects" in the space of ...
21
votes
1answer
640 views

Why is Mantel's test preferred over Moran's I?

Mantel's test is widely used in biological studies to examine the correlation between the spatial distribution of animals (position in space) with, for example, their genetic relatedness, rate of ...
21
votes
2answers
633 views

Detecting patterns of cheating on a multi-question exam

QUESTION: I have binary data on exam questions (correct/incorrect). Some individuals might have had prior access to a subset of questions and their correct answers. I don’t know who, how many, or ...
21
votes
1answer
862 views

Quantile regression: Which standard errors?

The summary.rq function from the quantreg vignette provides a multitude of choices for standard error estimates of quantile regression coefficients. What are the ...
20
votes
6answers
1k views

Why and when create a R package?

I understand this question is quite a broad one, but I wonder what should be the decisive points in deciding to create (or not) a new package for R. To be more specific, I would add that the question ...