12.07.2015 Views

R dummies

R dummies

R dummies

SHOW MORE
SHOW LESS
  • No tags were found...

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Between the square brackets, you can use a logical vector to select thecases you want. Here you select all cases where the variable activ equals 1for the first sample, and all cases where that variable equals 0 for the secondsample.Using a QQ plot to check for normalityIn most cases, you don’t want to compare two samples with each other, butcompare a sample with a theoretical sample that comes from a certain distribution(for example, the normal distribution).To make a QQ plot this way, R has the special qqnorm() function. As the nameimplies, this function plots your sample against a normal distribution. You simplygive the sample you want to plot as a first argument and add any of the graphicalparameters from Chapter 16 you like. R then creates a sample with values comingfrom the standard normal distribution, or a normal distribution with a mean of zeroand a standard deviation of one. With this second sample, R creates the QQ plot asexplained before.R also has a qqline() function, which adds a line to your normal QQ plot.This line makes it a lot easier to evaluate whether you see a clear deviationfrom normality. The closer all points lie to the line, the closer the distributionof your sample comes to the normal distribution. The qqline() function alsotakes the sample as an argument.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!