有谁知道如何绘制example chapter of Steyerberg's book的图23.1的图表?
R函数被称为" na.plot2"并显示例如数据框中缺失值的分数。我无法在本书的网页上找到该代码。
答案 0 :(得分:1)
手动编写它相当容易。我没有源数据,但这应该是你的开始
na <- is.na(dat)
fracna <- colMeans(na)
fracnaper <- lapply(na, function(i) colMeans(na[na[, i], -i]))
par(mfrow=c(2,2))
barplot(fracna, sideways=TRUE)
barplot(table(rowSums(na), sideways=TRUE)
barplot(fracnaper[, 1], sideways=TRUE)
plot(colMeans(na), sapply(fracnaper, sum))
答案 1 :(得分:0)
我发现软件包var x = document.getElementById("myAudio");
function playAudio() {
x.play();
}
function pauseAudio() {
x.pause();
}
</script>
<div class="equalizer" onclick="JavaScript: play();" value="Play" id="button">
<span class="column" id="purple"></span>
<span class="column" id="blue"></span>
<span class="column" id="cyan"></span>
<span class="column" id="green"></span>
<span class="column" id="yellow"></span>
<span class="column" id="orange"></span>
<span class="column" id="red"></span>
<span id="black"></span>
<br />
<script>
var x = document.getElementById("myAudio");
function playAudio() {
x.play();
}
function pauseAudio() {
x.pause();
}
//A function to return a random number between a min and a max value
function randomNumber(min, max) {
number = Math.floor((Math.random()*(max-min))+ min);
return number;
}
//Initialise starting values
var purple, blue, cyan, green, yellow, orange, red;
purple = 40;
blue = 35;
cyan = 45;
green = 35;
yellow = 45;
orange = 20;
red = 50;
//To start with the equalizer is paused
var playing=false; //WAS true
// A Function to change the height of a column more or less randomly
function changeHeight(column, height) {
height-=randomNumber(-20,20);
if (height>100) height=100;
if (height<2) height=2;
column.style.height=height + "px";
return height;
}
//A Function that will be run every 50ms to animate the equalizer
function animate() {
if (playing) {
purple = changeHeight(document.getElementById("purple"),purple); blue = changeHeight(document.getElementById("blue"),blue);
cyan = changeHeight(document.getElementById("cyan"),cyan);
green = changeHeight(document.getElementById("green"),green);
yellow = changeHeight(document.getElementById("yellow"),yellow);
orange = changeHeight(document.getElementById("orange"),orange);
red = changeHeight(document.getElementById("red"),red);
//Repeat this function every 50 ms
setTimeout(animate, 60);
}
}
//A Function to play or pause the animation
function play() {
if (playing) {
playing=false;
document.getElementById("button").value="Play";
x.pause();
} else {
playing=true;
document.getElementById("button").value="Pause";
x.play();
animate();
}
}
window.onload = play;//ADDED
中的功能.equalizer {
text-align: center;
margin: 10px auto;
width: 380px;
}
.column {
display: inline-block;
width: 10px;
margin: 2px;
}
#purple {
height: 40px;
background-color: #000000;
}
#blue {
height: 35px;
background-color: #000000;
}
#cyan {
height:45px;
background-color: #000000;
}
#green {
height: 35px;
background-color: #000000;
}
#yellow {
height: 45px;
background-color: #000000;
}
#orange {
height: 20px;
background-color: #000000;
}
#red {
height: 50px;
background-color: #000000;
}
#black {
display: inline-block;
height: 120px;
width: 1px;
background-color: #ffffff;
}
和<audio id="myAudio">
<source src="https://neue.run-time.co.za/wp-content/uploads/2020/11/Connected-Original-Mix-Melosense.mp3" type="audio/mpeg">
Your browser does not support the audio element.
</audio>
很有用。它直接概述了数据框中每个变量的NA数量,并包括变量类型。在https://visdat.njtierney.com/