У меня есть эта матрица.
mat<-c("A","NODATA","NODATA","NODATA","A","B","C","NODATA","A","B","C","NODATA","D","E","A","NODATA","D","B","A","NODATA")
mat2 <- matrix(mat<-c("A","NODATA","NODATA","NODATA","A","B","C","NODATA","A","B","C","NODATA","D","E","A","NODATA","D","B","A","NODATA"),nrow = 4,ncol = 5)
mat3<-t(mat2)
colnames(mat3)<-c("col1","col2","col3","col4")
mat3
col1 col2 col3 col4
[1,] "A" "NODATA" "NODATA" "NODATA"
[2,] "A" "B" "C" "NODATA"
[3,] "A" "B" "C" "NODATA"
[4,] "D" "E" "A" "NODATA"
[5,] "D" "B" "A" "NODATA"
Я хочу изменить фрейм данных, как показано ниже в R.
A B C D E NODATA
1 0 0 0 0 1
1 1 1 0 0 1
1 1 1 0 0 1
1 0 0 1 1 1
1 1 0 1 1 1
Знаете ли вы какие-либо идеи?
спасибо .