我有一组约750个测量值,分为10列,每行代表十年。我已经更改了行名称(' times')以适应日期,但我需要第二组行名称作为样本ID。是否可以定义两个行名称?
即使数据框已经分组为10?
组,也可以将其添加为列向量data <- read.csv (file='Transpose.csv', header = TRUE, sep = ',');
require(reshape2)
melt(data)
times <- c(1940,1950,1960,1970,1980,1990,2000,2010,2020,2030,2040,2050,2060,2070,2080,2090,2100,2110,2120,2130,2140,2150,2160,2170,2180,2190,2200,2210,2220,2230,2240,2250,2260,2270,2280,2290,2300,2310,2320,2330,2340,2350,2360,2370,2380,2390,2400,2410,2420,2430,2440,2450,2460,2470,2480,2490,2500,2510,2520,2530,2540,2550,2560,2570,2580,2590,2600,2610,2620,2630,2640,2650,2660,2670,2680,2690,2700);
matrix1<- data.frame(X=data$Measurement, ind=rep(1:10, nrow(data)/10));
capture.output(print(unstack(matrix1, X~ind), print.gap=3, row.names=times), file="Transposed.txt")