use first row data as column names in r
This should be such an easy problem but I have trouble with. I have a dirty dataset that I could not read it with header=T . After I read and clean it, I would like to use the now first row data as the column name. I tried multiple methods on stackoverflow without success. What could be the problem? The dataset t1 should look like this after clean up: V1 V2 V3 V4 V5 1 col1 col2 col3 col4 2 row1 2 4 5 56 3 row2 74 74 3 534 4 row3 865 768 8 7 5 row4 68 86 65 87 I tried: colnames(t1)=t1[1,] . Nothing happens. I tried: names(t1)=ti[1,] , Nothing happens. I tried: lapply(t1, function(x) {names(x)<