concept observation in category R

appears as: observations, observations, observation, An observation, n observation, observation
R in Action, Third Edition

This is an excerpt from Manning's book R in Action, Third Edition.

A dataset is usually a rectangular array of data with rows representing observations and columns representing variables. Table 2.1 provides an example of a hypothetical patient dataset.

Table 2.1 A patient dataset

PatientID

AdmDate

Age

Diabetes

Status

1

10/15/2018

25

Type1

Poor

2

11/01/2018

34

Type2

Improved

3

10/21/2018

28

Type1

Excellent

4

10/28/2018

52

Type1

Poor

Different traditions have different names for the rows and columns of a dataset. Statisticians refer to them as observations and variables, database analysts call them records and fields, and those from the data-mining and machine-learning disciplines call them examples and attributes. We’ll use the terms observations and variables throughout this book.

Observations that have high leverage are outliers with regard to the other predictors. In other words, they have an unusual combination of predictor values. The response value isn’t involved in determining leverage.

Observations with high leverage are identified through the hat statistic. For a given dataset, the average hat value is p/n, where p is the number of parameters estimated in the model (including the intercept) and n is the sample size. Roughly speaking, an observation with a hat value greater than 2 or 3 times the average hat value should be examined. The code that follows plots the hat values:

Figure 8.9 Index plot of hat values for assessing observations with high leverage
> pwr.chisq.test(w=.1853, df=2, sig.level=.05, power=.9)
 
     Chi squared power calculation
 
              w = 0.1853
              N = 368.5317
             df = 2
      sig.level = 0.05
          power = 0.9
 
 NOTE: N is the number of observations
Exploring Data with R

This is an excerpt from Manning's book Exploring Data with R.

We supplied a key of hour and a value of temp and targeted the columns that start with temp (using the select helper function starts_with(), for convenience). What we get in the output table (stored as the variable winni_mod) is a longer table of (112 rows) compared to 28 rows in the original table. This is four times the row count of the original since the four separate observations per row in winniweather are now given separate rows (as we need one row per observation for tidiness).

Listing 4.5. Using arrange() to put the observations in the correct order.
```{r weather_arrange, paged.print=FALSE}
winni_tidy <-
  winni_tidy %>%
  arrange(year, month, day, hour)      #A
 
winni_tidy
```
# A The arrange() function from the dplyr package takes unquoted column names (or expressions with desc(), not shown here but demonstrated in Chapter 2). The order is important. We are sorting first by year, then month, then day, and finally by hour.
R in Action, Second Edition: Data analysis and graphics with R

This is an excerpt from Manning's book R in Action, Second Edition: Data analysis and graphics with R.

A dataset is usually a rectangular array of data with rows representing observations and columns representing variables. Table 2.1 provides an example of a hypothetical patient dataset.

Table 2.1. A patient dataset

PatientID

AdmDate

Age

Diabetes

Status

1 10/15/2014 25 Type1 Poor
2 11/01/2014 34 Type2 Improved
3 10/21/2014 28 Type1 Excellent
4 10/28/2014 52 Type1 Poor

Different traditions have different names for the rows and columns of a dataset. Statisticians refer to them as observations and variables, database analysts call them records and fields, and those from the data-mining and machine-learning disciplines call them examples and attributes. We’ll use the terms observations and variables throughout this book.

Although a dataset might have dozens of variables and thousands of observations, we’ve included only 10 columns and 5 rows to simplify the examples. Additionally, we’ve limited the number of items pertaining to the managers’ deferential behavior to five. In a real-world study, you’d probably use 10–20 such items to improve the reliability and validity of the results. You can create a data frame containing the data in table 4.1 using the following code.

4.10.3. Selecting observations

Selecting or excluding observations (rows) is typically a key aspect of successful data preparation and analysis. Several examples are given in the following listing.

Listing 4.6. Selecting observations
newdata <- leadership[1:3,] #1 newdata <- leadership[leadership$gender=="M" & #2 leadership$age > 30,] #2 attach(leadership) #3 newdata <- leadership[gender=='M' & age > 30,] #3 detach(leadership) #3 #1: Asks for rows 1 through 3 (the first three observations) #2: 1 Selects all men over 30 #3: Uses attach() so you don’t have to prepend variable names with data-frame names
Figure 8.13. Index plot of hat values for assessing observations with high leverage