简体   繁体   中英

if first column of first row contains “Region” word then make that entire row as header.how can i code this in R?

I have multiple columns like

Region  | Canal |   Fabricantes|    Marcas  |Aromas Tamanos |   Año

like above so if 1st column of 1st row contains Region then make that row header of Dataframe otherwise dont do anythin...how can i code this in R?

Usually you can achieve this while importing the data already. For example, if you are using the openxl package, you can make it read the first row as the column names like this:

library(openxl)

open_xlsx(path='your_filename.xlsx', col_names=TRUE)

If you do not want the first to be the column name, use col_names=FALSE .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM