Hi Jinsong,
You can try
> d <- read.table(textConnection("5700 12.8 2500 270 25000
+ 1000 10.9 600 10 10000
+ 3400 8.8 1000 10 9000
+ 3800 13.6 1700 140 25000
+ 4000 12.8 1600 140 25000
+ 8200 8.3 2600 60 12000
+ 1200 11.4 400 10 16000
+ 9100 11.5 3300 60 14000
+ 9900 12.5 3400 180 18000
+ 9600 13.7 3600 390 25000
+ 9600 9.6 3300 80 12000
+ 9400 11.4 4000 100 13000"), header = FALSE)> closeAllConnections()
> colnames(d) <- paste('X', 1:ncol(d), sep = "")
> head(d)
X1 X2 X3 X4 X5
1 5700 12.8 2500 270 25000
2 1000 10.9 600 10 10000
3 3400 8.8 1000 10 9000
4 3800 13.6 1700 140 25000
5 4000 12.8 1600 140 25000
6 8200 8.3 2600 60 12000
# option 2 -- assuming you copy your data in the clipboard (on Windows)
d <- read.table('clipboard', header = FALSE)
colnames(d) <- paste('X', 1:ncol(d), sep = "")
d
See ?read.table, ?textConnection and ?colnames for more information.
HTH,
Jorge
On Sat, Oct 22, 2011 at 4:30 AM, Jinsong Zhao <> wrote:
> Hi there,
>
> In SPSS, small piece of data can be input as following:
>
> DATA LIST LIST /x1 x2 x3 x4 x5 .
> BEGIN DATA
> 5700 12.8 2500 270 25000
> 1000 10.9 600 10 10000
> 3400 8.8 1000 10 9000
> 3800 13.6 1700 140 25000
> 4000 12.8 1600 140 25000
> 8200 8.3 2600 60 12000
> 1200 11.4 400 10 16000
> 9100 11.5 3300 60 14000
> 9900 12.5 3400 180 18000
> 9600 13.7 3600 390 25000
> 9600 9.6 3300 80 12000
> 9400 11.4 4000 100 13000
> END DATA .
>
> Is there a similar way in R?
>
> Any suggestion will be really appreciated. Thanks in advance.
>
> Regards,
> Jinsong
>
> ______________________________**________________
> R-help@r-project.org mailing list
>
https://stat.ethz.ch/mailman/**listinfo/r-help<https://stat.ethz.ch/mailman/listinfo/r-help>
> PLEASE do read the posting guide http://www.R-project.org/**
> posting-guide.html <http://www.R-project.org/posting-guide.html>
> and provide commented, minimal, self-contained, reproducible code.
>
[[alternative HTML version deleted]]