Get data in long format, change the variable and get it back in wide format :
library(tidyr)
df %>%
pivot_longer(cols = -Symbol) %>%
pivot_wider(names_from = Symbol, values_from = value)
# name STAT1 GAPDH ACTB PRPF8 CAPNS1
# <chr> <dbl> <dbl> <dbl> <dbl> <dbl>
#1 GSM1573135 0.296 -0.0616 -0.0319 0.292 0.284
#2 GSM1573160 -0.604 0.597 0.138 0.131 0.694
#3 GSM1573175 -0.101 0.183 0.0319 0.187 0.0110
#4 GSM1573186 0.231 -0.448 -0.740 -0.361 -0.959
#5 GSM1573132 -0.139 0.139 -0.0927 -0.0466 -0.137
data.table
:
library(data.table)
dcast(melt(setDT(df), id.vars = 'Symbol'), variable~Symbol, value.var = 'value')
data
df <- structure(list(Symbol = c("STAT1", "GAPDH", "ACTB", "PRPF8",
"CAPNS1"), GSM1573135 = c(0.29600048, -0.06155872, -0.03187084,
0.29218674, 0.28366375), GSM1573160 = c(-0.6039429, 0.59726906,
0.13835812, 0.13059807, 0.69432163), GSM1573175 = c(-0.10135269,
0.18338203, 0.03187466, 0.18707657, 0.01103115), GSM1573186 = c(0.2308369,
-0.4480076, -0.739625, -0.3613615, -0.9594564), GSM1573132 = c(-0.13862038,
0.13947392, -0.09272575, -0.0466404, -0.13679028)),
class = "data.frame", row.names = c(NA, -5L))