viewIf: List selected column with an optional condition

View source: R/viewIf.R

viewIfR Documentation

List selected column with an optional condition

Description

List head or tail of a data.frame allowing to select column to be viewed and an optional condition to select rows to be displayed.

viewIf allow to quickly display some column of a dataframe satisfiyng a condition. It can be used during data exploration or after a recoding to verify the result When a condition is given, viewIf return all rows for which the condition is TRUE plus all rows with NA

Usage

viewIf(data, ..., cond = NULL, nline = 10)

Arguments

data

The dataframe to explore

...

variable name(s) to include in view, as character

cond

A logical condition to select records which will be evaluated into data, given as character string. The condition should be passed between quote : cond="mycondition".

nline

Number of rows to show (default to 10) If nline is negative then viewIf display nline rows from the end (similar to tail function)

Value

the resulting selection of n rows for the given list of column

Examples

data <- data.frame(id = 1:10,
                   case = c(rep(1,3), rep(0,7)),
                   vacc = sample(c(0,1), replace = TRUE, size = 10),
                   ill = sample(c(0,1), replace = TRUE, size = 10))
data[8,2]<-NA                    
viewIf(data ,case,vacc)
viewIf(data, ,case,vacc, nline=3)
viewIf(data,case,ill, nline= -3)
viewIf(data,case,ill,cond="vacc==1" )
 

Epiconcept-Paris/STRAP-epiuf documentation built on Aug. 5, 2024, 3:41 a.m.