I would like to import a txt file only contains one line as table column name and append with the other csv file with only data. The simplified files are as below:
txt file
Precentral Frontal_Sup Frontal_Sup_Orb
and the csv file
0.9938 0.96507 1.0043
And final outcome I want is
Precentral Frontal_Sup Frontal_Sup_Orb
0.9938 0.96507 1.0043
I've tried this but it does work
AAL <- rbind(read.table('raw data/header.txt', header = TRUE), read.csv('raw data/data.csv', header = FALSE))
And the outcome is
V1 V2 V3
0.9938 0.96507 1.0043
How to solve this? Thanks very much!
nm1 <- scan('raw data/header.txt', what ="", sep = " ", quiet = TRUE)and then you name the data read withnames(df1) <- nm1read.csv("file.csv", col.names=scan(...))bind_rowsfrom dplyr you would have noticed that you get 6 columns instead of 3.