you could use a loop but maybe easier would be
x<-c(NA,x)
y<-c(y,NA)
t<-x*y

use write.table() to write the table to your hard drive

e.g.

write.table(t, file="C:/Documents and Settings/simonp/My Documents/RELU/GIS data/Land Cover Map working/squares plus adjoining parcels/Scotland/scotland adj squares.csv", sep = ",",row.names = F)

HTH, Si.

----- Original Message ----- From: "Carletto Rossi" <nuovo...@gmail.com>
To: <r-help@r-project.org>
Sent: Tuesday, June 02, 2009 11:22 AM
Subject: [R] newbie help: simple operations in R


Hi, i' d like to use R for simple calculations. I show you an examples to
make clear my help request

I' ve a file .csv like this (my real file is composed by 10.000 lines and 8
columns)

x y
3 4
1 7

I' ve imported in R correctly. Now i want create a new variable named "t"
and t is defined throught this relation:

t = 4 (second element on x column) * 4 (first element on y column)

in what way can i calculate t and print its value on an external file or,
better, append t values as a column on my original csv???

Thanks

Emanuele

[[alternative HTML version deleted]]

______________________________________________
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.


______________________________________________
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.

Reply via email to