Here is an example of reshaping data from a wide format to a long format and combining two columns. I made some assumptions about your data structure. I if you need more detailed help, please post the output of
dput(DF)
where DF is the name of your data frame.
DF <- data.frame(`1` = c(2,4,3), `2` = c(6,5,4),`3` = c(12,32,22), `4` = c(1,2,3),
check.names = FALSE, row.names = c("A","B","C"))
DF
#> 1 2 3 4
#> A 2 6 12 1
#> B 4 5 32 2
#> C 3 4 22 3
library(tidyr)
library(tibble)
DF <- DF |> rownames_to_column()
DF
#> rowname 1 2 3 4
#> 1 A 2 6 12 1
#> 2 B 4 5 32 2
#> 3 C 3 4 22 3
DF <- DF |> pivot_longer(cols = -rowname, names_to = "TMP")
DF
#> # A tibble: 12 × 3
#> rowname TMP value
#> <chr> <chr> <dbl>
#> 1 A 1 2
#> 2 A 2 6
#> 3 A 3 12
#> 4 A 4 1
#> 5 B 1 4
#> 6 B 2 5
#> 7 B 3 32
#> 8 B 4 2
#> 9 C 1 3
#> 10 C 2 4
#> 11 C 3 22
#> 12 C 4 3
DF <- DF |> unite(col = "Kuyu", c("rowname", "TMP"), sep = "")
DF
#> # A tibble: 12 × 2
#> Kuyu value
#> <chr> <dbl>
#> 1 A1 2
#> 2 A2 6
#> 3 A3 12
#> 4 A4 1
#> 5 B1 4
#> 6 B2 5
#> 7 B3 32
#> 8 B4 2
#> 9 C1 3
#> 10 C2 4
#> 11 C3 22
#> 12 C4 3
Created on 2023-03-27 with reprex v2.0.2