The Row_To_Header function allows you to apply values from the selected table row as the names of the individual variables (columns).


Row Number Integer. The row number that will be used for column header names definition.
Remove Boolean. Property defines whether selected table row (Row Number) will be finally removed.


Row to Header, Row Values to Table Header, Row to Column Names, Excel Table

See Also

Header_To_Row, Flip_Horizontal, Flip_Vertical, Rename


How to Insert Values of Selected Row to Table Header

Sometimes it may happen that after importing the data you have (by mistake) variable names stored within the table - for example, in the first row. You can use the Row_To_Header function for this issue. An example is in the following illustration.

We will describe the nature of the function in the following example. In the table we have 4 variables with 12 records (rows). In the first row we have stored values that we would like to use as variable names.

In the ribbon toolbar tab Reshape, click on the Row_To_Header button.

In the list of applied functions is displayed the desired function. If you click on it, the adjustable properties of the function are listed at the bottom panel part. For Row_To_Header you can set two properties.

The first property is the Row Number. Using this integer argument, we define a row whose values we want to use as variable names. Subsequently, using the boolean property Remove, we can remove used row from the table.

The following figure shows an example with a default settings and result table. As the new variable names were used values from the first row of the table and the line was deleted (Remove = TRUE).

The next figure shows an example of when we set the property Remove to FALSE. In this case, the values from the first row were applied as variable names while remaining in the table.

The next figure shows an example of when we used values from the second row. Selected row was finally removed from the table.

After you apply the described function, you can continue to work with the data. For example, you can define the correct data types for each variable using the Format function.

The Row_To_Header function is very simple and we use it in very specific cases. The opposite character (copying the variable names as values into the table) has the Header_To_Row function.