# Adding obs. -------------------------------------- d1 <- data.frame(name=c('Kim','Choi','Park','Lee'),age=c(22,27,24,32)) d2 <- data.frame(age=c(23,22),name=c('Yoo','Kang')) rbind(d1,d2)
时间: 2023-08-15 15:53:09 浏览: 38
这段代码介绍了 R 语言中如何向数据框中添加新的观测。
假设 d1 是一个名为 d1 的数据框,其中包含了两列数据:name 和 age。假设 d2 是一个名为 d2 的数据框,其中包含了两个人的名字和年龄。
使用 rbind(d1, d2) 可以将 d2 中的两个人的信息添加到 d1 中,得到一个新的数据框。rbind() 函数将两个数据框按行拼接起来,要求它们的列名和列数完全相同。在这个例子中,rbind(d1, d2) 的结果为:
name age
1 Kim 22
2 Choi 27
3 Park 24
4 Lee 32
5 Yoo 23
6 Kang 22
注意,d2 中的列名和 d1 中的列名顺序相反,但是 rbind() 函数会自动调整列的顺序,使得它们和 d1 中的列顺序相同。
相关问题
make sftp-server
Sure, I can help you with that. To set up an SFTP server, you can follow these steps:
1. Install OpenSSH-server:
Run the following command to install OpenSSH-server on your system:
```
sudo apt-get install openssh-server
```
2. Configure SSH:
Open the SSH configuration file using a text editor:
```
sudo nano /etc/ssh/sshd_config
```
3. Uncomment or add the following line to allow SFTP access:
```
Subsystem sftp internal-sftp
```
4. Configure the SFTP subsystem by adding the following lines at the end of the file:
```
Match Group sftp-users
ChrootDirectory /home/%u
X11Forwarding no
AllowTcpForwarding no
ForceCommand internal-sftp
```
5. Create an SFTP group and user:
Run the following commands to create an SFTP group and user:
```
sudo groupadd sftp-users
sudo useradd -g sftp-users -s /bin/false -d /incoming sftpuser
sudo passwd sftpuser
```
6. Restart SSH service:
Run the following command to restart the SSH service:
```
sudo service ssh restart
```
After following these steps, you should have a functioning SFTP server. Clients can now connect to your server using an SFTP client with the provided username and password.
crypto-js html
Crypto-js is a JavaScript library that provides various cryptographic algorithms. To use Crypto-js in an HTML file, you need to include the library in your project and then reference it in your HTML file.
First, you can download the Crypto-js library from the official website or include it using a package manager like npm or yarn.
If you are downloading it manually, you can include the library by adding the following script tag to your HTML file:
```html
<script src="path/to/crypto-js.js"></script>
```
Replace `path/to/crypto-js.js` with the actual path to the Crypto-js library file.
Once you have included the library, you can start using its functionalities in your JavaScript code.
Here's an example of how you can use Crypto-js to encrypt and decrypt a message using the AES algorithm:
```html
<!DOCTYPE html>
<html>
<head>
<title>Crypto-js Example</title>
<script src="path/to/crypto-js.js"></script>
<script>
// Example encryption and decryption
var plaintext = "Hello, World!";
var password = "secret passphrase";
// Encrypt
var ciphertext = CryptoJS.AES.encrypt(plaintext, password).toString();
// Decrypt
var bytes = CryptoJS.AES.decrypt(ciphertext, password);
var decryptedText = bytes.toString(CryptoJS.enc.Utf8);
console.log("Plaintext: " + plaintext);
console.log("Ciphertext: " + ciphertext);
console.log("Decrypted Text: " + decryptedText);
</script>
</head>
<body>
</body>
</html>
```
Remember to replace `path/to/crypto-js.js` with the actual path to the Crypto-js library file.
This is just a basic example, and Crypto-js provides many other cryptographic algorithms and functionalities that you can explore in their documentation.