当前位置:文库下载 > 所有分类 > 工程科技 > 建筑/土木 > Useful R functions
免费下载此文档侵权投诉

Useful R functions

Useful R functions

Useful R functions

Program management

q()

help(…),?…,?help,find

help.start()

;

#

ls(), objects() # quit # help manual # help in html format # cmd separator # comment mark # see which R objects are in the R

workspace

# remove x,y from workspace

# runs file.R from working directory

# sends output to file.lis in working dir

# output reverts to console

# value from previous expression rm(x,y) source( file.R ) sink( file.lis ) sink() .Last.value

save(),dump(),write(),dput(),dget(),write()

Data management

read.table(“file.dat”,header=TRUE,http://www.wenkuxiazai.coms=1)

scan("ex.data", skip = 1) # reading fixed formatted input

names(islands) # print the names attribute of the

islands data set

table(rpois(100,5)) # build a contingency table of the counts

at each combination of factor levels

http://www.wenkuxiazai.coms(…)

matrix(data,nrow = 1,ncol = 1,byrow = FALSE,dimnames) #creates a matrix data() # list all available data sets

data(package = base) # list the data sets in the base package data(women) # load the data set women

file.show # view file

attach(women) # attaches database to search path

detach("women") # remove database from search path

library() # list all available packages

library(eda) # load package eda'

print(x) # prints its argument and returns it

invisibly (generic)

edit(…) # edit a data frame or matrix

summary(height) # a generic function used to produce

result summaries

Data manipulation

mode(object), length(object) # returns mode and length of object str() # displays structure of an arbitrary R

object

c(1:5, 10.5, "next") # generic fnc which combines args into a

vector

x[1:10] # indexes vector

paste(c(“a”,”b”),1:10) # combine one by one into char vector dim(x) or dim(x) <- c(3,4) # retrieve or set the dimension of an

object

array # creates or tests for arrays

as.matrix(x) # attempts to turn x into a matrix

is.matrix(x) # tests if x is a (strict) matrix

第1页

免费下载Word文档免费下载:Useful R functions

(下载1-4页,共4页)

猜你喜欢

返回顶部