Paul Adams wrote:
Hello everyone,=I have a question as to how to remove the column headers
in a data file and then replace those with titles from another file in this case
the file labeled ann (
in which the titles are all in one column).
Maybe this will help partially.
I am not sure on how to read your new column names from a file into a vector
but if you can get them into that format this should let you accomplish your
goal.
Esmail
load(Data/simpleTestData2.rda)
df
Y X1 X2 X3 X4 X5 X6
1 74.9 10 49.8 0.2 99 50 57
2 79.8 11 49.6 0.4 69 91 57
3 84.4 12 48.8 1.2 30 38 58
4 88.8 13 47.6 2.4 77 87 58
colnames(df)
[1] Y X1 X2 X3 X4 X5 X6
altnames=c(A, B1, B2, B3, B4, B5, B6)
colnames(df)=altnames
df
A B1 B2 B3 B4 B5 B6
1 74.9 10 49.8 0.2 99 50 57
2 79.8 11 49.6 0.4 69 91 57
3 84.4 12 48.8 1.2 30 38 58
4 88.8 13 47.6 2.4 77 87 58
save(df, file=example.rda)
# new file will contain the new column headers.
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.