Вы находитесь на странице: 1из 4

R version 3.0.

1 (2013-05-16) -- "Good Sport" Copyright (C) 2013 The R Foundation for Statistical Computing Platform: x86_64-w64-mingw32/x64 (64-bit) R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. > data =c (10,2,01,119) > sum(data) [1] 132 > sum =sum(data) > n = length(data) > sum/n [1] 33 > min(data) [1] 1 > max(data) [1] 119 > mean(data) [1] 33 > median(data) [1] 6 > mode(data) [1] "numeric" > help() starting httpd help server ... done > sort(data) [1] 1 2 10 119 > summary(data) Min. 1st Qu. Median Mean 3rd Qu. Max. 1.00 1.75 6.00 33.00 37.25 119.00 > boxplot(data) > IQR(data) [1] 35.5 > setwd('C:\R-Tut') Error: '\R' is an unrecognized escape in character string starting "'C:\R" > setwd('C:/R-Tut') > data=read.table('data.txt',header=TRUE) Warning message: In read.table("data.txt", header = TRUE) : incomplete final line found by readTableHeader on 'data.txt' > data=read.table('data.txt',header=TRUE) Warning message: In read.table("data.txt", header = TRUE) : incomplete final line found by readTableHeader on 'data.txt' > data=read.table('data.txt') Warning message: In read.table("data.txt") : incomplete final line found by readTableHeader on 'data.txt' > data=read.table('data.txt')

> data V1 V2 V3 V4 1 120 62 100 0 2 113 64 135 0 3 128 64 115 1 4 123 69 190 0 5 108 67 125 1 6 136 62 93 0 7 138 62 178 0 8 NA 60 172 1 > data=read.table('data.txt') Error in scan(file, what, nmax, sep, dec, quote, skip, nlines, na.strings, : line 2 did not have 5 elements > data=read.table('data.txt') > hist(data) Error in hist.default(data) : 'x' must be numeric > Exp = data[,2] > hist(Exp) > Exp [1] 62 64 64 69 67 62 62 60 > colnames(data)=('dautien','lan2','lan3','lan4') Error: unexpected ',' in "colnames(data)=('dautien'," > colnames(data)=('dautien','lanhai','lanba','lanbon') Error: unexpected ',' in "colnames(data)=('dautien'," > colnames(data)=c('dautien','lanhai','lanba','lanbon') > data\ Error: unexpected input in "data\" > data dautien lanhai lanba lanbon 1 120 62 100 0 2 113 64 135 0 3 128 64 115 1 4 123 69 190 0 5 108 67 125 1 6 136 62 93 0 7 138 62 178 0 8 NA 60 172 1 > attach(data) > boxplot(dautien) > boxplot(lanhai) > boxplot(lanba) > boxplot(lanbon) > boxplot(lanba) > table(lanhai) lanhai 60 62 64 67 69 1 3 2 1 1 > dautien62=data[lanhai=='62',] > dautien62 dautien lanhai lanba lanbon 1 120 62 100 0 6 136 62 93 0 7 138 62 178 0 > dautien64=data[lanhai=='64',] > boxplot(dautien62[,2],dautien64[,2],border=rainbow(2),names=c(62,64),main='tes t choi') > boxplot(dautien62[,2],dautien64[,2],border=rainbow(2),names=c(62,64),main='tes t choi',ylim=(61,65)) Error: unexpected ',' in "boxplot(dautien62[,2],dautien64[,2],border=rainbow(2), names=c(62,64),main='test choi',ylim=(61,"

> boxplot(dautien62[,2],dautien64[,2],border=rainbow(2),names=c(62,64),main='tes t choi',ylim=c(61,65)) > dautien62 dautien lanhai lanba lanbon 1 120 62 100 0 6 136 62 93 0 7 138 62 178 0 > dautien 64 Error: unexpected numeric constant in "dautien 64" > dautien64 dautien lanhai lanba lanbon 2 113 64 135 0 3 128 64 115 1 > boxplot(dautien62[,2],dautien64[,2],border=rainbow(7),names=c(62,64),main='tes t choi',ylim=(61,65)) Error: unexpected ',' in "boxplot(dautien62[,2],dautien64[,2],border=rainbow(7), names=c(62,64),main='test choi',ylim=(61," > boxplot(dautien62[,2],dautien64[,2],border=rainbow(6),names=c(62,64),main='tes t choi',ylim=(61,65)) Error: unexpected ',' in "boxplot(dautien62[,2],dautien64[,2],border=rainbow(6), names=c(62,64),main='test choi',ylim=(61," > boxplot(dautien62[,2],dautien64[,2],border=rainbow(2),names=c(62,64),main='tes t choi',ylim=(61,65)) Error: unexpected ',' in "boxplot(dautien62[,2],dautien64[,2],border=rainbow(2), names=c(62,64),main='test choi',ylim=(61," > boxplot(dautien62[,2],dautien64[,2],border=rainbow(2),names=c(62,64),main='tes t choi',ylim=c(61,65)) > boxplot(dautien62[,2],dautien64[,2],border=rainbow(2),names=c(62,64),main='tes t choi',ylim=c(61,65)) > dautien62=data[lanbon==0] Error in `[.data.frame`(data, lanbon == 0) : undefined columns selected > dautien62=data[lanbon==0,] > dautien64=data[lanbon==1,] > boxplot(dautien62[,2],dautien64[,2],border=rainbow(2),names=c(62,64),main='tes t choi',ylim=c(61,65)) > boxplot(dautien62[,2],dautien64[,2],border=rainbow(2),names=c(62,64),main='tes t choi') > boxplot(dautien~lanhai,border=rainbow(2),names=c(62,64),main='test choi') Error in axis(side = 1, at = 1:4, labels = c(62, 64)) : 'at' and 'labels' lengths differ, 4 != 2 > boxplot(dautien~lanbon,border=rainbow(2),names=c(62,64),main='test choi') > boxplot(dautien~lanba,border=rainbow(2),names=c(62,64),main='test choi') Error in axis(side = 1, at = 1:7, labels = c(62, 64)) : 'at' and 'labels' lengths differ, 7 != 2 > boxplot(dautien~lanbon,border=rainbow(2),names=c(62,64),main='test choi') > boxplot(dautien~lanhai,border=rainbow(2),names=c(62,64),main='test choi') Error in axis(side = 1, at = 1:4, labels = c(62, 64)) : 'at' and 'labels' lengths differ, 4 != 2 > boxplot(dautien~lanbon,border=rainbow(2),names=c(62,64),main='test choi') > utils:::menuInstallPkgs() --- Please select a CRAN mirror for use in this session --Warning: unable to access index for repository http://cran.cnr.Berkeley.edu/bin/ windows/contrib/3.0 Warning: unable to access index for repository http://www.stats.ox.ac.uk/pub/RWi n/bin/windows/contrib/3.0 Error in install.packages(NULL, .libPaths()[1L], dependencies = NA, type = type) : no packages were specified In addition: Warning message: In open.connection(con, "r") : unable to resolve 'cran.r-project.org'

> utils:::menuInstallPkgs() Warning: unable to access index for repository http://cran.cnr.Berkeley.edu/bin/ windows/contrib/3.0 Warning: unable to access index for repository http://www.stats.ox.ac.uk/pub/RWi n/bin/windows/contrib/3.0 Error in install.packages(NULL, .libPaths()[1L], dependencies = NA, type = type) : no packages were specified > local({pkg <- select.list(sort(.packages(all.available = TRUE)),graphics=TRUE) + if(nchar(pkg)) library(pkg, character.only=TRUE)}) > update.packages(ask='graphics',checkBuilt=TRUE) Warning: unable to access index for repository http://cran.cnr.Berkeley.edu/bin/ windows/contrib/3.0 Warning: unable to access index for repository http://www.stats.ox.ac.uk/pub/RWi n/bin/windows/contrib/3.0 > utils:::menuInstallPkgs() Warning: unable to access index for repository http://cran.cnr.Berkeley.edu/bin/ windows/contrib/3.0 Warning: unable to access index for repository http://www.stats.ox.ac.uk/pub/RWi n/bin/windows/contrib/3.0 Error in install.packages(NULL, .libPaths()[1L], dependencies = NA, type = type) : no packages were specified > chooseCRANmirror() Warning message: In open.connection(con, "r") : unable to resolve 'cran.r-project.org' > chooseCRANmirror() Warning message: In open.connection(con, "r") : unable to resolve 'cran.r-project.org' > boxplot(dautien~lanhai,border=rainbow(2),names=c(62,64),main='test choi') Error in axis(side = 1, at = 1:4, labels = c(62, 64)) : 'at' and 'labels' lengths differ, 4 != 2 > boxplot(dautien~lanba,border=rainbow(2),names=c(62,64),main='test choi') Error in axis(side = 1, at = 1:7, labels = c(62, 64)) : 'at' and 'labels' lengths differ, 7 != 2 > boxplot(dautien~lanba,border=rainbow(7),names=c(62,64),main='test choi') Error in axis(side = 1, at = 1:7, labels = c(62, 64)) : 'at' and 'labels' lengths differ, 7 != 2 > boxplot(dautien~,border=rainbow(7),names=c(62,64),main='test choi') >

Вам также может понравиться