Dear Kayj
Try something like
setwd("c:\\temp")
require(MASS)
my.df<-read.table("my_inputfile.txt", sep="\t", head=T)
my.df$newcol<-my.df$col1+my.df$col2+my.df$col3
write.table(my.df, "my_outputfile.txt", append=F, row.names=F,
sep="\t")
On the above example, I suppose that your input file are on c:\temp
directory (pay attention on double slash); that you used TAB as field
separator (sep="\t"); that the first line of your input file have the
collumn names (head=T).
my.df$newcol will create a new collumn on your data.frame and that it will
receive the sum of other three collumns.
write.table will save your new table.
I hope this helps.
miltinho astronauta
Brazil
On 8/27/08, kayj <kjaja27@yahoo.com> wrote:>
>
> I do have some data of dim 100*3 (i.e 100 rows and 3 columns ) stored in a
> txt file. I want to read the data into R, Perform the same operation in
> each row and store the result in a forth column( that I should create).
> I do not know how I can create a forth column to store the result of the
> operation for each row?
>
>
>
>
>
> --
> View this message in context:
>
nabble.com/How-to-create-additional-columns--tp19191104p19191104.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help@r-project.org mailing list
> stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
[[alternative HTML version deleted]]