On Jun 10, 2009, at 11:27 AM, Dmitry Gospodaryov wrote:

I have the data arranged in table (in Excel, or Notepad):

        x       y

        0       100
        2       100
        4       80
        6       40
        8       0

I need to transfer these data in R file and then going to
operate with x and y as with variables. I should note, that I have
2.8.1 version. Thank you for advance.


Dmitry,

There is a complete R manual that describes how to get data into and out of R, called R Data Import/Export. It is available within your R distribution (if on Windows, via the R menus) or on the R web site at:

  http://cran.r-project.org/manuals.html

There is also a page on the R Wiki at:

  http://wiki.r-project.org/rwiki/doku.php?id=tips:data-io:ms_windows

which specifically covers R and Windows/Excel data exchange.

A quick example, if the above is in Notepad, but with NO BLANK LINE between the x and y labels and the data. You can highlight the text, press CTRL-C to copy it to the clipboard and then use the following in R (see ?read.table):

  DF <- read.table("clipboard", header = TRUE)

That will give you a 'data frame' in R that contains the two columns, which can then be addressed as DF$x and DF$y. Further information is available in the R manual An Introduction to R.

HTH,

Marc Schwartz

______________________________________________
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