非常抱歉之前的回答中存在错误。根据您的要求,以下是将数据格式变为所需格式的修正代码:

library(dplyr)
library(tidyr)

data <- read.table(text = 'Name    A1    A2    A3    A4    A5    A6
SC-2    80.5    70.9    77.5    72.1    73.2    62.2
SC-3    63.2    57.5    67.5    73.5    65.7    64.2
SC-4    69.9    65.0    70.7    76.1    67.5    75.5
SC-6    69.5    64.2    56.2    62.5    71.2    64.5
SC-7    69.7    67.5    68.6    69.5    71.2    72.5
SC-8    65.9    62.5    73.2    57.4    67.1    53.5
SC-9    69.8    73.1    63.5    70.6    72.1    65.5
SC-10    80.5    65.5    70.1    62.5    68.4    77.6
SC-11    69.4    68.3    64.3    70.5    67.1    59.6
SC-12    62.6    60.8    68.1    68.5    67.5    60.8
SC-16    68.1    68.5    66.1    53.4    61.5    54.5
SC-17    56.2    51.5    59.5    54.0    63.2    58.5
SC-18    68.2    68.2    61.5    61.6    74.5    62.1', header = TRUE)

result <- data %>%
  pivot_longer(cols = -Name, names_to = 'Column', values_to = 'Value') %>%
  arrange(Name, Column) %>%
  pivot_wider(names_from = Column, values_from = Value)

write.table(result, 'output_file_path.csv', sep = ',', quote = FALSE, row.names = FALSE)  # 将'output_file_path.csv'替换为你的输出CSV文件路径

请将'output_file_path.csv'替换为你想要保存整理结果的文件路径和名称。

执行以上代码后,将会生成一个CSV文件,其中数据格式已变为所需的格式,每个A列对应一列数据。

希望这次能满足您的需求。如果还有其他问题,请随时向我提问。

数据格式转换:将表格数据变为特定格式

原文地址: https://www.cveoy.top/t/topic/Ol6 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录