ВУЗ: Не указан

Категория: Не указан

Дисциплина: Не указана

Добавлен: 06.04.2021

Просмотров: 864

Скачиваний: 1

ВНИМАНИЕ! Если данный файл нарушает Ваши авторские права, то обязательно сообщите нам.
background image

9.8. EXAMPLE

CIRCLE 9. UNHELPFULLY SEEKING HELP

The question lacks both specificity and background (though it is mercifully

brief). The answer to how to do the operation could depend on whether you
want it delivered, and what size it should be. And do you want anchovies? If
you provide background, you may get an answer that proposes a better—but
entirely different—way of getting nutrients into your bloodstream.

Do not confuse a warning with an error. There are two differences:

1. warnings say “warning” and errors say “error”.

2. the computation continues when there is a warning but is interrupted

when there is an error.

If there really is an error, then give the results of:

traceback()

The word “crash” is very ambiguous. It would be better if you didn’t use the
word at all. If you do use it, you need to explain

exactly

what you mean. In

addition to avoiding the use of vague words like “crash”, you can be informative
by displaying the results of

sessionInfo()

.

If error or warning messages are not in English and you are writing to an

English mailing list, then translating pertinent messages would be in your best
interest. But do show the real message as well.

If you are asking if method XYZ is implemented in R, then say that XYZ

stands for Xeric Yare Zeugma (and hence not X-raY Zoometry). Give a brief
explanation and a reference (preferably available online). The same technique,
or something suitably similar, may well go by a different name.

Did I say you should give the results of

sessionInfo()

? The more infor-

mation about the version of R you are using and your machine, the better. If
the information is accurate, that’s a plus.

9.8

Give a minimal, self-contained example

Note this does not say, “Give an example.” It says to give a minimal, self-
contained example. A minimal, self-contained example allows readers to repro-
duce the problem easily. The easier you make it for your readers, the more likely
you receive help.

The word “minimal” implies an optimization. Elements of that optimization

include:

Minimize the number of packages involved. Ideal is if a vanilla session
suffices.

Minimize the number of functions involved.

Minimize the size of any functions that are yours.

120


background image

9.9. WAIT

CIRCLE 9. UNHELPFULLY SEEKING HELP

Minimize the number and size of datasets involved. If peculiar data are
required and your data are complicated, large and/or proprietary, then
make up some data that exhibits the problem.

Often the process of making a

minimal

example reveals the problem. If the

problem does not reveal itself, then keep these hints in mind:

Make your example easy to cut and paste. The

dput

function is sometimes

useful for this.

If the example involves random numbers, then use

set.seed

to make the

numbers non-random.

Using data that comes with R is often the easiest for your readers.

Format the code to be easy to understand—the space bar is an excellent
resource.

Your minimal, self-contained example should

never ever

include a line of code

like:

rm(list=ls())

There’s a special special place for those who try to lull their would-be helpers
into destroying their data.

It can not be emphasized enough that a message is putting yourself at the

mercy of strangers. If someone has the wit and knowledge to answer your
question, they probably have other things they would like to do. Making your
message clear, concise and user-friendly gives you the best hope of at least one
of those strangers diverting their attention away from their life towards your
problem.

9.9

Wait

Don’t send the message immediately. Wait some amount of time—at least 1
hour, at most 1.7348 days. Leave the room you’re in.

Now reread the message from a typical list member’s point of view. The

answer may become apparent. More likely you may see how the question could
be made more clear. Add information that only you know but which the message
assumes the reader knows. Imagine yourself going through all of the steps of
your problem from the beginning.

Send the message in plain text, not html.
Only send the message once. Just because you don’t immediately see your

message on the list does not mean it didn’t go through. Seeing the same message
multiple times annoys people and reduces the chances they will answer you.
There seems to be positive correlation between a person’s level of annoyance at
this and ability to answer questions.

121


background image

Postscript

irgil

and I came upon the road leading to the bright world. We climbed

through an opening to see once again the stars.

Most of this was stolen from the archives of R-help (thieves are consigned to
Circle 9 [page

115

], as you’ll recall). Thanks go to Tim Triche, Jr. and especially

Mark Difford for help with the table of contents and the index, and for well-
placed prods. Mark’s version of the source document went through an inferno
of its own.

What spark of life there may be in these scribblings is due largely to the con-
tributors of R-help, and to Beatrice.

122


background image

Index

1-D arrays,

110

tapply

,

110

Assignment operators,

94

Attributes,

see

Objects, S3 methods,

S4 methods

Backslashed characters,

see

Table

8.1

Braces, curly,

28

Breathe,

115

Calculating products,

see

Vectorization

safe, efficient calculation,

18

Capitalization,

46

,

78

Circle I,

9

11

virtuous pagans, floating point and

all that,

9

Circle III,

17

23

cold, dead weight of the past,

17

foreign tongues,

17

pain and pleasure of perfection,

17

Complex numbers,

94

Computing on the language,

32

Corrupted .RData,

113

Curly braces,

28

Data frame,

98

101

Double brackets versus single brackets,

72

Empty cells

aggregate, by, sapply, tapply

(behaviour),

69

70

split

and

sapply

,

70

Factors,

80

87

File extension conventions,

64

Floating Point Trap,

9

11

floating point,

9

,

11

,

111

numerical error and wrong calcu-

lation,

11

rank of a matrix,

11

Functions (R + other)

all.equal

,

93

as.numeric

,

91

cbind

,

100

c

,

84

data.table

,

25

ifelse

,

90

if

,

90

integrate

,

105

is.integer

,

91

is.matrix

,

92

max

,

92

pmax

,

92

return

,

112

,

113

Vectorize

,

18

,

106

aggregate

,

70

as alternative to

tapply

,

25

all.equal

,

11

apply

,

24

as.complex

,

10

,

48

as.integer

,

91

attach

,

95

by

,

70

,

110

as alternative to

tapply

,

25

data frames,

110

111

cbind

,

10

,

18

circle.area

,

28

do.call

,

95

for

,

12

15

,

17

,

18

,

21

,

22

,

26

,

50

,

123


background image

INDEX

INDEX

66

,

73

76

,

95

,

107

getAnywhere

,

95

help.request

,

117

help

,

95

identical

,

93

ifelse

,

21

22

,

84

if

,

21

22

is.complex

,

10

is.integer

,

92

is.matrix

,

90

is.na

,

26

,

36

,

52

,

77

,

87

,

89

equality of missing values,

48

is.numeric

,

91

,

94

isTRUE

,

93

library

,

95

max

,

19

mean

,

19

memory.size

,

15

min

,

19

na.rm

,

28

,

39

,

57

outer

,

106

prod

,

18

,

19

quadratic.formula

,

10

,

18

range

,

19

rbind

,

13

,

14

read.table

,

101

replicate

,

95

require

,

95

return

,

28

rm

,

95

runif

,

13

,

14

,

22

,

111

sample

,

96

sapply

,

70

,

108

,

110

inside functions,

110

save

,

95

seq

,

9

,

21

,

75

,

76

,

107

,

114

sessionInfo

,

120

sqrt

,

10

str

,

114

,

119

subset

,

95

96

sum

,

17

19

system.time

,

94

tapply

,

25

,

69

,

70

,

110

alternatives,

see

by, aggregate

traceback

,

120

unique

,

9

update.packages

,

116

vapply

,

110

write.table

,

105

formatting,

32

34

passing information,

37

writing functions

consistency,

33

34

indenting,

33

simplicity,

32

33

spaces between (logical) opera-

tors,

33

Global Assignments,

35

37

memoization,

36

,

37

Green book,

see

S4 methods

Help (asking for),

115

121

rtfm

,

115

dput

,

121

help.request

,

117

sessionInfo

,

120

set.seed

,

121

traceback

,

120

update.packages

,

116

check the

faq

,

116

descriptive subject line,

118

filing bug reports,

117

118

hijack thread,

118

minimal example (value of),

120

121

read the posting guide,

117

repeating a message,

121

select best list,

118

special interest groups,

117

types of list,

117

vanilla session,

120

wait before posting,

121

Integers,

91

92

Namespaces,

42

43

::

(accessing public [exported] ob-

jects),

43

:::

(accessing private [non-exported]

objects),

43

accessing functions/objects with the

same name,

42

124