R - Names

Card Puncher Data Processing

About

Language - Name (Program Entity) in R.

A name permits to address a value.

An object may have several values and then several names.

For a data.frame or a list, it will be the column header.

You can set and/or get them.

Management

List

The available names of an object can be found with the names function:

names(x)

where:

The str function gives them also:

str(df)
'data.frame':	5 obs. of  3 variables:
 $ colA: int  1 2 3 4 5
 $ colB: int  2 3 4 5 6
 $ colC: int  3 4 5 6 7

Update

The previous names are not really beautiful, we will change them:

names(df)=c("cond","diff")
> names(df)
[1] "cond" "diff"

Set

example with a list

l = list(name = "Nico", age = 40)
l
$name
[1] "Nico"

$age
[1] 40

> names(l)
[1] "name" "age" 

Get the values by name

You may use the $ sign to retrieve a named value:

You can access the value by name

l$name
[1] "Nico"

Documentation / Reference

?names





Discover More
Card Puncher Data Processing
R - (Object|Variable|Symbol)

R provides a number of specialized objects. They are created (instantiated), used and referenced through variable (known as symbol). When you read the term object in the documentation, you can interchange...
R Studio Import Dataset
R - Data frame Object

A data frame is a logical implementation of a table in a relational database A data frame inherits all the property and function of an object. It has a list of variables of the same number of rows with...
Card Puncher Data Processing
R - Interaction Analysis

interaction with R . An interaction term between a numeric x and z is just the product of x and z. lm processes the “” operator between variables andautomatically: add the interaction...
Card Puncher Data Processing
R - List

The list in R may contain elements of the different class (just like a data frame) class a vector (1 dimension) or a matrix (2 dimensions) data.tables and data.frames are internally lists with all...
Card Puncher Data Processing
R - Multiple Linear Regression

Multiple linear regression with R functions such as lm Unstandardized Multiple Regression Regression analyses, standardized (in the z scale). The point is a short-cut to select all variables....
Card Puncher Data Processing
R - Names

in R. A name permits to address a value. An object may have several values and then several names. For a data.frame or a list, it will be the column header. You can set and/or get them. The...
Biplot Pca R
R - Principal Component Analysis

in R. Package stats where: scale=TRUE will standardize the variables in order to take into account the different unity. The data The variables associated (names) Unclass will show...
Card Puncher Data Processing
R - Simple Linear Regression

simple linear regression with R function such as lm Unstandardized Simple Regression Regression analyses, standardized (in the z scale). In simple regression, the standardized regression coefficient...
Card Puncher Data Processing
R - Subset Operators (Extract or Replace Parts of an Object)

In the Data Manipulation category, you have the subset operators: [ [[ $ This operators acts on: vectors, matrices, arrays lists data.frame to extract or replace parts. See also:...



Share this page:
Follow us:
Task Runner