许多软件包包含数据框,其中plot(df)生成特定输出。例如。 nlme包含'Dialyzer'数据框,在情节(Dialyzer)上使用格子(格子包)生成一个图,其中代码实际上是:
<!DOCTYPE html>
<html>
<head>
<title>Rewind HD</title>
<link rel="stylesheet" type="text/css" href="CSS/rewind hd.css">
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
body {
font-family: Arial, Verdana, sans-serif;
background-color: #141414;
color: #fff;
font-size: 90%;
margin: 0px;
padding: 0px;
}
img#logo {
width: 250px;
position: relative;
bottom: 0px;
left: 10px;
border: none;
}
div#nav {
background-color: rgba(7, 7, 7, 0.7);
box-shadow: 0px 3px 10px #000;
height: 70px;
position: fixed;
top: 0px;
left: 0px;
padding: 10px;
margin: 0px;
width: 100%;
}
div#division {
margin-top: 120px;
}
.octo {
position: fixed;
right: 0px;
width: 100%;
height: 100%;
margin-bottom: 100px;
}
.wraper {
margin: 10px auto 10px auto;
width: 85%;
padding-left: 100px;
}
.poster {
display: inline-block;
width: 273px;
float:left;
}
figure {
background-color: rgba(106, 192, 69, 0.7);
border-radius: 5px;
padding-left: 3px;
}
img {
}
figcaption {
font-weight: bold;
padding-left: 5px;
}
figure:hover {
background-color: #1ba6e0;
border-radius: 5px;
}
</style>
</head>
<body>
<div id="nav">
<img id="logo" src="images/REWIND HD web.png">
</div>
<div id="division"></div>
<div class="wraper">
<div class="poster">
<figure>
<figcaption>James Bond<br /> Octopussy</figcaption>
<a href="james Bond.html"><img src="images/octopussy.jpg"></a>
</figure>
</div>
<div class="poster">
<figure>
<figcaption>James Bond<br /> A View To A Kill</figcaption>
<a href="james Bond A view to kill.html"><img src="images/JBAVTK.jpg"></a>
</figure>
</div>
<div class="poster">
<figure>
<figcaption>James Bond<br /> For Your Eyes Only</figcaption>
<a href="James Bond For your eyes only.html"><img src="images/James Bond For Your Eyes Only.jpg"></a>
</figure>
</div>
<div class="poster">
<figure>
<figcaption>James Bond<br /> Licence To Kill</figcaption>
<a href="James Bond For your eyes only.html"><img src="images/James Bond Licence To Kill.jpg"></a>
</figure>
</div>
<div class="poster">
<figure>
<figcaption>James Bond<br /> Moonraker</figcaption>
<a href="James Bond Moonraker.html"><img src="images/James Bond Moonraker.jpg"></a>
</figure>
</div>
<div class="poster">
<figure>
<figcaption>James Bond<br /> Never Say Never Again</figcaption>
<a href="James Bond Never Say Never Again.html"><img src="images/James Bond Never Say Never Again.jpg"></a>
</figure>
</div>
<div class="poster">
<figure>
<figcaption>James Bond<br /> Majestys Secret Service</figcaption>
<a href="James Bond On Her Majestys Secret Service.html"><img src="images/James Bond On Her Majestys Secret Service.jpg"></a>
</figure>
</div>
<div class="poster">
<figure>
<figcaption>James Bond<br /> The Living Daylights</figcaption>
<a href="James Bond The Living Daylights.html"><img src="images/James Bond The Living Daylights.jpg"></a>
</figure>
</div>
<div class="poster">
<figure>
<figcaption>James Bond<br /> The Spy Who Loved</figcaption>
<a href="James Bond The Spy Who Loved.html"><img src="images/James Bond The Spy Who Loved.jpg"></a>
</figure>
</div>
<div class="poster">
<figure>
<figcaption>ames Bond<br /> Licence To Kill</figcaption>
<a href="James Bond For your eyes only.html"><img src="images/James Bond Licence To Kill.jpg"></a>
</figure>
</div>
<div class="poster">
<figure>
<figcaption>James Bond<br /> Moonraker</figcaption>
<a href="James Bond Moonraker.html"><img src="images/James Bond Moonraker.jpg"></a>
</figure>
</div>
<div class="poster">
<figure>
<figcaption>James Bond<br /> Never Say Never Again</figcaption>
<a href="James Bond Never Say Never Again.html"><img src="images/James Bond Never Say Never Again.jpg" class="background_color"></a>
</figure>
</div>
<div class="poster">
<figure>
<figcaption>ames Bond<br /> Licence To Kill</figcaption>
<a href="James Bond For your eyes only.html"><img src="images/James Bond Licence To Kill.jpg"></a>
</figure>
</div>
<div class="poster">
<figure>
<figcaption>James Bond<br /> Moonraker</figcaption>
<a href="James Bond Moonraker.html"><img src="images/James Bond Moonraker.jpg"></a>
</figure>
</div>
<div class="poster">
<figure>
<figcaption>James Bond<br /> Never Say Never Again</figcaption>
<a href="James Bond Never Say Never Again.html"><img src="images/James Bond Never Say Never Again.jpg"
</figure>
</div>
</div>
</body>
</html>
这个代码似乎包含在dataframes属性中:是否有人可以向我指导或包含有关如何设置数据帧默认情节的指南?
答案 0 :(得分:1)
这由对象的类决定。请注意Dialyzer的等级&#34; data.frame&#34;。
> class(Dialyzer)
[1] "nfnGroupedData" "nfGroupedData" "groupedData" "data.frame"
当您调用plot时,它会遍历此类的条目并尝试查找plot.*
方法。它找到的第一个被使用。如果一切都失败了,那么总是data.frame
。
> methods("plot")
[1] plot.acf* plot.ACF* plot.augPred* plot.compareFits* plot.data.frame*
[6] plot.decomposed.ts* plot.default plot.dendrogram* plot.density* plot.ecdf
[11] plot.factor* plot.formula* plot.function plot.gls* plot.hclust*
[16] plot.histogram* plot.HoltWinters* plot.intervals.lmList* plot.isoreg* plot.lm*
[21] plot.lme plot.lmList* plot.medpolish* plot.mlm* plot.nffGroupedData*
[26] plot.nfnGroupedData* plot.nls* plot.nmGroupedData* plot.pdMat* plot.ppr*
[31] plot.prcomp* plot.princomp* plot.profile.nls* plot.ranef.lme* plot.ranef.lmList*
[36] plot.raster* plot.shingle* plot.simulate.lme* plot.spec* plot.stepfun
[41] plot.stl* plot.table* plot.trellis* plot.ts plot.tskernel*
[46] plot.TukeyHSD* plot.Variogram*
如果您想使用特定方法,可以使用plot.*
明确地调用它,例如plot.default
。
答案 1 :(得分:1)
R是多态。这意味着相同的函数可以导致不同类对象的不同操作。您可以将plot()
应用于许多不同类型的对象,您将为每个对象获得不同类型的图。例如,我们可以对print()
,summary()
和其他许多人说同样的话。
多态性使事情更容易记住。如果某个函数对您来说是新手,请尝试在函数输出上运行plot()
;它可能会奏效。如果您是程序员,多态性允许编写相当通用的代码,而不必担心被操纵的对象类型,因为底层类机制会处理这个问题。
适用于多态的函数,例如plot()
和print()
,
被称为泛型。当调用泛型函数时,R将调用传递给相对类方法:它会将调用重新路由到为特定对象类定义的函数。