I have a tibble named X of multiple columns (over 500) which are named in format of "X"+integer. The tibble looks like this.
# A tibble: 7,352 x 561
X1 X2 X3 X4 X5 X6
<dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
1 0.289 -0.0203 -0.133 -0.995 -0.983 -0.914
2 0.278 -0.0164 -0.124 -0.998 -0.975 -0.960
The txt file didn't contain column names, but they are in another txt file which I have read into another tibble. This tibble is size of 561x1.
What I wanted to do is to rename all of the column names of tibble x by using row values (=converting the tibble to character vector named y).
I have tried dplyr function rename_all without a result.
Here's an example which I believe is quite close to actually working, but I don't quite understand how to work with function list
> rename_all(x,list(paste0(y)))
The above command in RStudio command line produces following error message:
Error in get(.x, .env, mode = "function") :
object 'tBodyAcc-mean()-X' of mode 'function' was not found
The tBodyAcc-mean()-X
is the value in the first row of character vector y.
I have tried to googling the error message, but so far I have no idea what is causing that and how should I modify the rename_all command to get it working.
Any help is much appreciated!
names(df) <- y
? – Sotos