[R] R: Appending the files
John Kane
jrkrideau at yahoo.ca
Sat Apr 21 01:42:18 CEST 2007
--- Vaibhav Gathibandhe
<gathibandhe.vaibhav at gmail.com> wrote:
> Hello R-Experts,
>
> I am a beginner to R. Can someone please look at my
> problem
>
> I am trying to append the files in R but couldn't
> get the answer properly.
>
> My code is
>
> mat1<-matrix(0,2,3)
> mat2<-matrix(1,2,3)
>
> write.table(mat1,"foo.csv",sep=",",col.names=NA)
> write.table(mat2,"foo.csv", sep=",", col.names=NA,
> append = TRUE)
>
> I am getting a warning message:
>
> Warning message:
> appending column names to file in: write.table(mat2,
> "foo.csv", sep = ",",
> col.names = NA, append = TRUE)
>
> Moreover the data of *mat2* is getting appended to
> "foo.csv" in the
> following way
>
> V1 V2 V3 1 0 0 0 2 0 0 0 V1 V2
> V3 1 1 1 1 2 1 1 1
>
> If data is getting appended then why I am getting
> the warning message?
I'm a newbie too, but I think it is just a "warning".
:) I suspect it is just to tell you that you are
appending to a file and not creating a new file. Iwas
a bit upset the first time I saw it until I realised
the write command was working just fine.
>
> Moreover is there any way by which i can get the
> data of *mat2* beside the
> data of *mat1* instead of below?
I suspect that you would have to join the two matrices
together in R.
cbind the two matrices xx <- cbind(mat1, mat2) and
then save the resulting larger matrix X . Will that
work?
More information about the R-help
mailing list