2012年6月8日

摘要: http://wiki.stdout.org/rcookbook/Data%20input%20and%20output/Loading data from a fileTable of contentsLoading data from a fileProblemSolutionDelimited text filesLoading a file with a file chooserTreating strings as factors or charactersLoading a file from the InternetFixed-width text filesExcel file 阅读全文
posted @ 2012-06-08 10:41 Buttonwood 阅读(1388) 评论(0) 推荐(0) 编辑
 
摘要: Creating a formula from a stringProblemYou want to create a formula from a string.SolutionIt can be useful to create a formula from a string. This often occurs in functions where the formula arguments are passed in as strings.In the most basic case, useas.formula():# This returns a string:"y ~ 阅读全文
posted @ 2012-06-08 10:19 Buttonwood 阅读(370) 评论(0) 推荐(0) 编辑
 
摘要: StringsSearching and replacing - grep, sub, gsubCreating strings from variables - sprintf, pasteCreating strings from variablesTable of contentso Creating strings from variableso Problemo Solutiono Using paste()o Using sprintf()o NotesProblemYou want to do create a string from variables.SolutionThe 阅读全文
posted @ 2012-06-08 10:12 Buttonwood 阅读(394) 评论(0) 推荐(0) 编辑
 
摘要: Generating random numbersProblemYou want to generate random numbers.SolutionFor uniformly distributed (flat) random numbers, userunif(). By default, its range is from 0 to 1.runif(1)# 0.5581546# Get a vector of 4 numbersrunif(4)# 0.383330465 0.005814167 0.879704937 0.873534007# Get a vector of 3 num 阅读全文
posted @ 2012-06-08 10:05 Buttonwood 阅读(250) 评论(0) 推荐(0) 编辑
 
摘要: 笔记来源:http://wiki.stdout.org/rcookbook/Indexing into a data structureProblemYou want to get part of a data structure.SolutionElements from a vector, matrix, or data frame can be extracted using numeric indexing, or by using a boolean vector of the appropriate length.In many of the examples, below, th 阅读全文
posted @ 2012-06-08 09:45 Buttonwood 阅读(298) 评论(0) 推荐(0) 编辑