mckenzie code error tracking
 Share
The version of the browser you are using is no longer supported. Please upgrade to a supported browser.Dismiss

 
View only
 
 
Still loading...
ABCDEFGHIJKLMNOPQRSTUVWXYZAAABAC
1
ErrorLanguage
Link (eg, to SO)
Date
Complexity/Risk (1-5)
Category
Time Lost (mins)
More info
2
Downloaded link rather than json filed3.js9/1/20141need to make sure that file types are correct when debugging
3
Used chrome rather than firefox for debuggingd3.js9/1/20141firefox gives much richer error reports, at least wrt json files and d3 in this run
4
invalid graphics state in R R
http://stackoverflow.com/questions/20155581/persistent-invalid-graphics-state-error-when-using-ggplot2
9/3/20141perform dev.off() to fix when the graphics device gets messed up
5
passing ggplot "short" data frame format, when it expects a "long" formatR
http://rpubs.com/daattali/heatmapsGgplotVsLattice
9/3/20144be careful with ggplot's inputs and expect to have to make a basic test case for each plot
6
didn't use a comma in base R order function R9/8/20142errors are often in copying when failing to include commas: watch for this
7
didn't "distribute" facet in facet_wrap by two variablesR9/9/20141need to be very careful of particular syntax and characters in ggplot aesthetics
8
plus sign at beginning of R lineR9/11/20141
don't put plus signs there; Error in inherits(x, "theme") : argument "e2" is missing, with no default
9
tried to melt() a data frame with non unique row combinations R
http://stackoverflow.com/questions/9979545/reshape2-cast-data-frame-with-some-duplicate-values
9/18/20143
reshape2 automatically aggregates by factor and thus I had one value for each factor instead of each column ... when using melt, needs to be at least one unique row or combination of rows
10
access a value in a list via [] rather than [[i]]R9/20/20141
11
taking length() of a vector that specifies lengthR9/20/20142this gives you length = 1, not the actual value!
12
tried to start newline to make code clean without operatorR
http://stackoverflow.com/questions/6329962/split-code-over-multiple-lines-in-an-r-script
9/20/20141
in order to do a newline in R, need to inform R that you will be continuing by using an operator like + or ,
13
tried to make a matrix with data = list() instead of c(x,...) R 9/20/20142for some reason R prefers c(numbers) rather than list, still dunno why
14
appending names to list in for loop without indexing by [[]], ie position R9/20/20141
15
$PATH was altering ability of X11 to operate (eg, in R) shell
http://apple.stackexchange.com/questions/127882/how-do-i-undo-export-path-usr-local-binpath-bash-profile
9/22/20144
had to remove lines from my customized $PATH via /usr/bin/open ~/.bash_profile, which re-enabled shell commands on restart
16
list of variable names called as strings, without coercing to object via mget()R
http://stackoverflow.com/questions/17831015/r-list-from-variables-using-variable-names
9/25/20143cuidado in function invocations
17
using mget() in local environment, where it can't read objectsR
http://stackoverflow.com/questions/5864854/pulling-all-objects-in-the-global-environment-that-have-specific-attributes
9/25/20143need to call certain functions from the global environment (think, related to namespace)
18
attempting to extract actual values from factor variable instead of indexR
http://www.cookbook-r.com/Manipulating_data/Converting_between_vector_types/
10/7/20142better solution is the hacky as.numeric(as.character(x))
19
merge creates extra rows from duplicate variables -- de-duplicate if necessaryR
https://stat.ethz.ch/pipermail/r-help/2012-February/302658.html
10/8/20143can de duplicate rows via !(duplicated[x])
20
to remove a entry use "which"; using the name just removes the indexR
http://r.789695.n4.nabble.com/Remove-a-number-from-a-vector-td851865.html
10/19/20142"In order to remove "bobo" from x you need to do the following: x=x[which(x=="bobo")]"
21
change order of a facet grid in ggplot requires altering factor prior to ggplotR
http://docs.ggplot2.org/0.9.3.1/facet_grid.html
10/19/20142
need to change the order of the levels of the factor manually via df$name = factor(df$name, levels = c("First One", "second one", ...))
22
output file without quotes in tableR10/19/20142just switch write.table( , quotes = FALSE, )
23
instantiate vector using vector()R10/20/20141as opposed to as.vector(), which doesn't work but rather coerces existing objects to vectors
24
converting text file to list using R R
http://stackoverflow.com/questions/6602881/text-file-to-list-in-r
10/22/20143
this is a tough problem, because R assumes that lists should instead by columns of char vectors
25
write to file without quoting the values, change option quote = FALSER10/22/20142in general there are lots of options eg in the write.table function for these sorts of things
26
object attributes are capitalized but printed out uncapspython
http://biopython.org/wiki/SeqIO
10/23/20142dunno if this is in the general case
27
calling a row dimname with an empty selection (or with "NA") yields a "subscript out of bounds" error
R10/23/20145
took a long time to debug this; was making a call in a long matrix based on the dimnames, but this particular row (#2000) had no gene names ... in general, if you get a problem late in a loop or other iterator sequence, assume that the problem may be variance in your data / exception case
28
create a data frame without changing strings to factors and thus removing order, via setting stringsAsFactors=FALSE
R10/26/20142R will often mess w your data types unless you tell it not to
29
if two library namespaces clash, use :: to indicate (e.g. dplyr and MASS) R
http://stackoverflow.com/questions/24202120/dplyrselect-function-clashes-with-massselect
11/3/20143
30
1-phyper() can't go past 2e-16; instead, using phyper(.., lower.tail = F) R11/5/20143
31
geom_text in facet_wrap won't facet unless you give it a value specifying how to do so R
http://stackoverflow.com/questions/20428902/geom-text-writing-all-data-on-all-facets
11/25/20143
you can use a separate df in your geom_text that you send to facet wrap them in your main df, but they both must be df's (so probably going to be using some rep functions for any repeated labels, eg)
32
if you have quotes in a file, read.table() won't read the full thing in (you'll have fewer rows than you'd prefer)
R
http://stackoverflow.com/questions/5854231/read-table-creates-too-few-rows-but-readlines-has-the-right-number
12/5/20143
switch quotes = "" as one of the arguments; another possibility is comments could be messing with the line
33
model.matrix() automatically removes rows w NA values; stop this by replacing NAs w rowMeans or changing the na.action
R
http://stackoverflow.com/questions/6447708/model-matrix-generates-fewer-rows-than-original-data-frame
12/5/20143
may not notice this until downstream steps where you are told "Error in design[obs, , drop = FALSE] : (subscript) logical subscript too long"
34
to read in a matrix while "flipped" (ie transpose it), turn header = FALSE, read it in, then replace (this appears to be best practice)
R
http://stackoverflow.com/questions/7039358/reading-a-flipped-table-in-to-a-data-frame-correctly
12/10/20141this is the obvious solution, but good to know there is nothing more "elegant"
35
named two objects the same thing and got a type error when calling the first one for not being iterable
python12/28/20142need to be careful on variable naming and check this if you get a confusing error
36
to print list of ints as space separated strings, convert each element to a string via map()python
http://stackoverflow.com/questions/6507431/join-float-list-into-space-separated-string-in-python
12/28/20141
37
paste() defaults to separation of " " (ie one space) R1/2/20151
38
didn't put a whitespace after open bracket in shellshell
http://stackoverflow.com/questions/20235217/syntax-error-near-unexpected-token-then
1/10/20152sh scripts seem pretty ticky tacky about whitespace
39
x11 R plots are blurry (especially the text) in yosemite R
http://stackoverflow.com/questions/26439410/plot-text-is-blurry-on-x11-device
1/13/20152
fix by instantiating a quartz device via quartz() before calling the plotting function; http://stat.ethz.ch/R-manual/R-devel/library/grDevices/html/quartz.html
40
error: line X did not have Y elementsR
http://stackoverflow.com/questions/18161009/error-in-reading-in-data-set-in-r
1/14/20153
data missing in a particular row; R assumes that each row has the same number of data points; usually something wrong with the data or one row of the data, so often best to debug via fill = TRUE and then looking at the data in R
41
error: " line 1 appears to contain embedded nulls", due to attempting to read xlsx as read.table
R
http://stackoverflow.com/questions/25872946/read-csv-throws-error
1/16/20152data_io
use library(xlsx) to read it in, though caution that this in insalely slow, instead (though it was due to encoding, and that may be true too, but this solved it better than switching the encoding type)
42
error: "EOF within quoted string" causes deletion of rows when reading in large fileR
http://stackoverflow.com/questions/17414776/read-csv-warning-eof-within-quoted-string-prevents-complete-reading-of-file
1/16/20152data_ioneed to disable quoting via quote = ""
43
error: object of type 'closure' is not subsettable when operating on an object R
http://stackoverflow.com/questions/11308367/error-in-my-code-object-of-type-closure-is-not-subsettable
1/18/20153naming
two problems: named an object after a base R fxn (test), and hadn't instanstaited that argument before I tried to index on one of its variables
44
"'col.names = NA' makes no sense when 'row.names = FALSE'"; use col.names = FALSE instead
R
http://stackoverflow.com/questions/6750546/export-csv-without-col-names
1/19/20151data_iocol.names in R write.table is really annoying
45
read in a table where you just need the 3rd column using read.table(pipe("cut -f3 (or -f4) path/to/file"))
R
http://stackoverflow.com/questions/19743271/quicker-way-to-read-single-column-of-csv-file
1/26/20151data_io
careful of trying to use scan() here ... it's a low level fxn, and eg, will only accept real numbers
46
trying to call $ on a non-list or df gives "$ operator is invalid for atomic vectorsR
http://stackoverflow.com/questions/20124801/operator-is-invalid-for-atomic-vectors
1/27/20151syntax
47
replace all specified values of a df with df[df = X] = Y; (eg, df[df == "NaN"] = NA to replace NaNs with NAs)
R
http://stackoverflow.com/questions/19503266/r-replace-all-particular-values-in-a-data-frame
1/28/20151syntax
48
how to get the object names from a list, like list(a, b, c), where a, b, c are character vectors
R2/4/20153unresolved
49
df's have a base column named row.names, so if you have an additional column named row.names, you'll get errors like "'by' must specify a uniquely valid column"
R2/8/20153naming
50
R has a row.names() function for df's/matrices, but colnames() instead of col.namesR2/9/20151naming this is a really silly aspect of R
51
gsub doesn't work on vectors in apply format (dunno why); can use qdap package insteadR
http://stackoverflow.com/questions/19424709/r-gsub-pattern-vector-and-replacement-vector
2/12/20152functions
52
"line 1 appears to contain embedded nulls", this may be due to a file encoding issueR
http://stackoverflow.com/questions/25872946/read-csv-throws-error
2/19/20152data_iocan use library(xlsx) instead and read.xls(filename, sheetname, etc)
53
use skip = n to skip the first n lines from an input file R
http://stackoverflow.com/questions/17485426/how-to-skip-comments-line-in-data-file-i-want-to-import-with-r
2/27/20151data_io
54
to combine lists of character vectors, use Reduce(union, list) (instead of doing them one-by-one)
R
http://stackoverflow.com/questions/5775534/how-to-take-the-union-of-element-in-a-nested-list-in-r
2/27/20151streamlining
55
"incomplete final line found by readTableHeader" indicates that you need to add a blank line to the end of the file
R
http://stackoverflow.com/questions/22171858/in-read-table-incomplete-final-line-found-by-readtableheader
2/27/20152data_io
56
if you want to order a column's rows by a different vector, use match() instead of order()R
http://stackoverflow.com/questions/11977102/order-a-data-frames-rows-according-to-a-target-vector-that-specifies-the-desire
3/4/20155syntaxorder() can be a trap (literally tried to write this same exact thing on 4/17/15...)
57
if you get "EOF within quoted string" error, disable quoting in read.table()R
https://docs.google.com/spreadsheets/d/1mDGkh8EhNR7CSkyeOcdelKgnfTgAJgpVYwity8WkNSI/edit#gid=0
3/15/20151data_io
58
columns can't be named with something that starts with a number, or you'll get "Error: unexpected numeric constant"; use backticks to call it
R4/1/20154naming
59
using merge(), if your rows are eliminated, switch all = TRUE to make them be NAs instead
R
http://stackoverflow.com/questions/5965698/r-merge-unequal-dataframes-and-replace-missing-rows-with-0
4/12/20152merging
60
tried to use gsub on a df; gsub works on df's so you need to use an apply fxn insteadR
http://stackoverflow.com/questions/14871249/can-i-use-gsub-on-each-element-of-a-data-frame
4/15/20152syntax
61
before write table, should be relatively standard to create directory for it; otherwise R crashes
R
http://stackoverflow.com/questions/4216753/check-existence-of-directory-and-create-if-doesnt-exist
4/22/20152data_iocan use dir.create(file.path(outdir, subdir))
62
to create a directory if it doesn't exist, use dir.create(file.path(mainDir, subDir), showWarnings = FALSE)
R
http://stackoverflow.com/questions/4216753/check-existence-of-directory-and-create-if-doesnt-exist
5/5/20151data_io
63
to count the number of true values in a logical vector, use sum(z, na.rm=TRUE)R
http://stackoverflow.com/questions/2190756/in-r-how-to-count-true-values-in-a-logical-vector
5/5/20151syntax
64
"invalid 'na.print' specification" means that you need to specify how print() should deal with NA's via the na.print argument
R5/8/20151syntax
65
use grep(paste(patterns, collapse='|'), x) to search for multiple patterns using grep, ie concatenating them into a regexp
R
http://stackoverflow.com/questions/5542542/using-cbind-on-an-arbitrarily-long-list-of-objects
5/11/20153syntaxow get warning argument 'pattern' has length > 1 and only the first element will be used
66
Reduce( ... , merge, list_of_dfs) fails to preserve unique colnames: assign these with a Map fxn first
R
http://stackoverflow.com/questions/8091303/merge-multiple-data-frames-in-a-list-simultaneously
5/11/20154syntax
67
if writing a table and get an opaque "cannot open the connection" following dir.create(), lots of possibilites, but note that dir.create() can only create one directory, not multiple nested ones
R5/14/20155data_iohardest bug i've had in awhile (not objectively, but hard for me... data i/o stuff is so rough)
68
to list the objects in the global environment outside of fxn, use ls(envir=.GlobalEnv)R
http://stackoverflow.com/questions/8142941/how-to-search-an-environment-using-ls-inside-a-function
5/14/20152scope
69
to determine whether *any* items are duplicated in a vector, use any(duplicated(vector)) R
http://stackoverflow.com/questions/5263498/how-to-test-whether-a-vector-contains-repetitive-elements
6/4/20151syntax
70
named an object as a function and then when tried to call fxn got "could not find function" error
R6/8/20153syntaxdon't name objects the same as functions!!
71
tried calling Rcpp function as source() instead of sourceCpp, get error around line 3, e.g. unexpected '/'
R/Rcpp6/8/20153syntaxcareful when calling R extensions
72
in df's "columns" can be accessed via "names", but in matrices, must specify colnames() or rownames()
R6/8/20152syntax
73
if you want to convert a vector to a matrix, use matrix(), *not* as.matrix() R
http://stackoverflow.com/questions/14614946/how-to-turn-a-vector-into-a-matrix-in-r
6/10/20152syntax
74
have to start directories with a "/" for root, ow will get " cannot open the connection" errorR6/15/20152data_io
75
don't have a "/" at the beginning of non-root directoriesR6/18/20152data_io
76
in strsplit, if you want to match an actual character like "|", use fixed = T, ow might assume that it is a regexp
R6/23/20151syntax
77
"Error in dev.off() : QuartzBitmap_Output - unable to open file" -- good chance you're in the wrong directory
R6/25/20152data_io
78
after subsetting or ordering a row name, can "reset" the numeric rownames via rownames(foo) = NULL
R7/1/20151syntax
79
do *not* assume that the names() function for a matrix will access columns a la a df -- specify colnames()
R7/2/20154syntax
80
prefer message() to cat(), the latter of which may print out in non-standard ways e.g. during testing
R7/2/20153syntax
81
don't use cbind() when creating a data.frame(), otherwise it will coerce all of the columns to the same type (e.g., character)
R7/3/20153syntax
82
write.table does *not* accept lists; if you want to create a df with missing data points, use cbind.fill
R
http://stackoverflow.com/questions/7962267/cbind-a-df-with-an-empty-df-cbind-fill
7/5/20154data_io25
83
if read.table isn't reading as many rows as you have (via bash wc -l), there may be quotes in the file that are silently ruining everything
R
http://stackoverflow.com/questions/3016333/r-why-does-read-table-stop-reading-a-file
7/8/20155data_io20
84
"formal argument "col.names" matched by multiple actual arguments" might mean that you literally passed in the same parameter twice
R7/9/20151syntax1
85
can't get VennDiagram package to work... getting an "Impossible" error, and other attempts didn't work either; annoying package in this sense
R
http://stackoverflow.com/questions/20526348/error-in-r-venndiagram-impossible-produces-negative-area
7/9/20152viz20
86
if you wanna select multiple elements of a list using sapply, use "[", c(1, 3); since this is how you select multiple elements of a list, vs "[[" for one element
R7/12/20151syntax1
87
don't use which() when reordering rowsR
http://stackoverflow.com/questions/5620885/how-does-one-reorder-columns-in-r
7/14/20151syntax2
88
to reorder columns of a df by a character vector foo, simply use df = df[foo]R
http://stackoverflow.com/questions/23141795/r-sort-columns-of-a-data-frame-by-a-vector-of-column-names
7/20/20151syntax5
89
tried to do assignment within function using "="; must use "<-" in this case (!) R7/24/20154syntax 15
this is apparently the one time where <- matters vs =; and i have a flashcard on it and i still missed this for awhile
90
in reshape2's dcast, value.var option must be quoted, e.g. value.var = "foo", which is crazy and i almost don't even believe but pretty sure it's true
R7/28/20154syntax 20
91
when porting code to a different platform, forgot to add options(stringsAsFactors == FALSE), which is in my ~/.Rprofile on my main machine
R7/29/20155data_io30
92
if reading in a boolean from command line, may want to use == "True" since it may be read in as string
python7/29/20153data_io15somewhat hacky and non-pythonic but works
93
for subsetting a table, which == or which %in% can choke on integer() if no matches; instead, use == or %in% as boolean
R7/29/20154syntax 15
94
when you get "more columns than column names error", make sure to look for things such as # in the colnames, and if there are some turn comment.char = ""
R8/9/20153data_io20read.table() commands so HY
95
to get the *original ordering* of levels of a factor variable foo (as opposed to lexographic), use factor(foo, levels = unique(foo))
R
https://stat.ethz.ch/pipermail/r-help/2008-June/165145.html
8/13/20154syntax20
96
must add "do" before you call foo in a bash for loop, ow you'll get "syntax error near unexpected token foo"
bash8/14/20151syntax1
97
when extracting from a list using strsplit, if your result is a vector, use "[", not "[["R8/18/20153syntax30
98
if you get a "no lines available in input", be careful of your lines starting with a comment char
R8/26/20153syntax5
99
default sep in R is not "one whitespace", but any amt of whitespace; set this with sep = "", not sep = " "
R
http://stackoverflow.com/questions/16979858/reading-text-file-with-multiple-space-as-delimiter-in-r
8/28/20152data_io2
100
matrices don't have "names" -- must explicitly specify colnames or rownamesR9/3/20151syntax5stupid mistake...
Loading...
 
 
 
Sheet1