-
Notifications
You must be signed in to change notification settings - Fork 0
/
discussion.html
47 lines (47 loc) · 3.32 KB
/
discussion.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="generator" content="pandoc">
<title>Software Carpentry: Programming with R</title>
<link rel="shortcut icon" type="image/x-icon" href="/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="stylesheet" type="text/css" href="css/bootstrap/bootstrap.css" />
<link rel="stylesheet" type="text/css" href="css/bootstrap/bootstrap-theme.css" />
<link rel="stylesheet" type="text/css" href="css/swc.css" />
<link rel="alternate" type="application/rss+xml" title="Software Carpentry Blog" href="http://software-carpentry.org/feed.xml"/>
<meta charset="UTF-8" />
<!-- HTML5 shim, for IE6-8 support of HTML5 elements -->
<!--[if lt IE 9]>
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
</head>
<body class="lesson">
<div class="container card">
<div class="banner">
<a href="http://software-carpentry.org" title="Software Carpentry">
<img alt="Software Carpentry banner" src="img/software-carpentry-banner.png" />
</a>
</div>
<article>
<div class="row">
<div class="col-md-10 col-md-offset-1">
<a href="index.html"><h1 class="title">Programming with R</h1></a>
<h2 class="subtitle">Discussion</h2>
<h2 id="error-returned-when-attempting-to-calculate-mean-of-data.frame-rows">Error returned when attempting to calculate mean of data.frame rows</h2>
<p>As of R version 3.0.0 one cannot use functions such as <code>mean()</code>, <code>max()</code>, <code>min()</code>, etc., on <code>data.frame</code> rows. This can be a problem when going through material in the <a href="02-func-R.html">Creating functions</a> lesson, <strong>Testing and Documenting</strong> section, if one attempts to apply any of these functions to the example dataset rows (e.g., <code>center(dat[4, ], 0)</code>. The examples in the lesson are all written to work only with columns, but an error is returned if one tries using rows. This may also be a problem if one attempts to calculate row means or medians in the <a href="01-starting-with-data.html">Analyzing patient data</a> lesson, <strong>Manipulating Data</strong> section. The <strong>recommended solution</strong> to this issue is to not apply these functions to <code>data.frame</code> rows. However, one <em>could</em> get around this issue by using the functions <code>rowSums</code> or <code>rowMeans</code> in some cases, or explicitly converting the row to a vector of numeric values (e.g., <code>center(as.numeric(dat[4, ]), 0)</code>)</p>
</div>
</div>
</article>
<div class="footer">
<a class="label swc-blue-bg" href="http://software-carpentry.org">Software Carpentry</a>
<a class="label swc-blue-bg" href="https://github.com/swcarpentry/lesson-template">Source</a>
<a class="label swc-blue-bg" href="mailto:admin@software-carpentry.org">Contact</a>
<a class="label swc-blue-bg" href="LICENSE.html">License</a>
</div>
</div>
<!-- Javascript placed at the end of the document so the pages load faster -->
<script src="http://software-carpentry.org/v5/js/jquery-1.9.1.min.js"></script>
<script src="css/bootstrap/bootstrap-js/bootstrap.js"></script>
</body>
</html>