我的数据集如下:
salary number
1500-1600 110
1600-1700 180
1700-1800 320
1800-1900 460
1900-2000 850
2000-2100 250
2100-2200 130
2200-2300 70
2300-2400 20
2400-2500 10
Run Code Online (Sandbox Code Playgroud)
如何计算此数据集的中位数?这是我尝试过的:
x <- c(110, 180, 320, 460, 850, 250, 130, 70, 20, 10)
colnames <- "numbers"
rownames <- c("[1500-1600]", "(1600-1700]", "(1700-1800]", "(1800-1900]",
"(1900-2000]", "(2000,2100]", "(2100-2200]", "(2200-2300]",
"(2300-2400]", "(2400-2500]")
y <- matrix(x, nrow=length(x), dimnames=list(rownames, colnames))
data.frame(y, "cumsum"=cumsum(y))
numbers cumsum
[1500-1600] 110 110
(1600-1700] 180 290
(1700-1800] 320 610
(1800-1900] 460 1070
(1900-2000] 850 1920
(2000,2100] 250 2170
(2100-2200] …Run Code Online (Sandbox Code Playgroud) 我的系统:win7 ultimate 64英文版+ r-3.1(64).
这是我的sessionInfo.
> sessionInfo()
R version 3.1.0 (2014-04-10)
Platform: x86_64-w64-mingw32/x64 (64-bit)
locale:
[1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United States.1252
LC_MONETARY=English_United States.1252 LC_NUMERIC=C
LC_TIME=English_United States.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
Run Code Online (Sandbox Code Playgroud)
1.无法在r控制台中输入中文字符
当我在r控制台中输入中文字符时,它会变成乱码.

2.无法在r控制台上显示中文字符
当我在r控制台中读取数据时,中文字符变成乱码.
您可以下载数据并进行测试
read.table("r1.csv",sep=",")
Run Code Online (Sandbox Code Playgroud)

如果您不知道如何从我的网站获取数据,请查看图表以下载数据.

如何设置我的电脑以在r控制台中正确显示和输入中文字符?我已经更新了中文语言包并启用了它,但问题仍然存在.
我想将全角字符中的所有字符更改为半角字符,编写以下代码来完成工作.例如,要更改中的所有全角字符
???????.?? ? ????????
Run Code Online (Sandbox Code Playgroud)
成半角字符,成
codebit.cn - ????????
Run Code Online (Sandbox Code Playgroud)
有两种方法可以实现目标,但所有这些方法都失败了.
所有的php文件都保存为utf-8格式.
方法1:
<?php
function fulltohalf($str){
$arr=Array(
'?' => '0', '?' => '1', '?' => '2', '?' => '3', '?' => '4',
'?' => '5', '?' => '6', '?' => '7', '?' => '8', '?' => '9',
'?' => 'A', '?' => 'B', '?' => 'C', '?' => 'D', '?' => 'E',
'?' => 'F', '?' => 'G', '?' => 'H', '?' => 'I', '?' => 'J',
'?' => 'K', '?' => …Run Code Online (Sandbox Code Playgroud) 我想在重启或关机之前上传文件.
1.从我的vps到vps
设置upload.service
vim /etc/systemd/system/upload.service
[Unit]
Description=upload files into my vps
Before=shutdown.target reboot.target
Requires=network-online.target
After=network.target
[Service]
ExecStart=/bin/true
ExecStop=/bin/bash /home/upload.sh
[Install]
WantedBy=multi-user.target
Run Code Online (Sandbox Code Playgroud)
upload.sh的脚本
vim /home/upload.sh
/usr/bin/scp -P 22 -i /home/.ssh/id_rsa /home/wp.bak root@remote_ip:/home
Run Code Online (Sandbox Code Playgroud)
是时候测试一下了.
systemctl enable upload
reboot
Run Code Online (Sandbox Code Playgroud)
验证wp.bak可以在重启时从我的vps1上传到vps2.
2.从家里的电脑到vps
ssh凭证已在家里的电脑和vps之间建立.
与case1相同的设置.
journalctl -u upload
Started upload files into my vps.
ssh: connect to host xxxxxxxxxx port 22: Network is unreachable
lost connection
Run Code Online (Sandbox Code Playgroud)
这是没有用的,写After=network.target的After=network.target ssh.service.
像nbari说的那样.
sudo vim /etc/systemd/system/upload.service
[Unit]
Description=upload files into my vps
Before=shutdown.target reboot.target
After=network.target …Run Code Online (Sandbox Code Playgroud) 这是一些示例数据:
dat="x1 x2 x3 x4 x5
1 C 1 16 NA 16
2 A 1 16 16 NA
3 A 1 16 16 NA
4 A 4 64 64 NA
5 C 4 64 NA 64
6 A 1 16 16 NA
7 A 1 16 16 NA
8 A 1 16 16 NA
9 B 4 64 32 32
10 A 3 48 48 NA
11 B 4 64 32 32
12 B 3 48 32 16"
data<-read.table(text=dat,header=TRUE)
aggregate(cbind(x2,x3,x4,x5)~x1, …Run Code Online (Sandbox Code Playgroud) 我的系统是"win7",我想删除文件"workspace".
file.remove("c:\\workspace")
# [1] FALSE
# Warning message:
# In file.remove("c:\\workspace") :
# cannot remove file 'c:\workspace', reason 'Permission denied'
Run Code Online (Sandbox Code Playgroud)
如何让R有权删除它?
file.info("c:\\workspace")
# size isdir mode mtime ctime
# c:\\workspace 0 TRUE 777 2014-01-01 14:42:51 2014-01-01 14:33:27
# atime exe
# c:\\workspace 2014-02-25 09:39:08 no
Run Code Online (Sandbox Code Playgroud) 我已将Github无密码登录设置如下.
ssh-keygen -t rsa -P ''
cat .ssh/id_rsa.pub |xclip
Run Code Online (Sandbox Code Playgroud)
我将公钥粘贴到Github网站上的ssh和gpg密钥中.
git init
git config --global user.name "someone"
git config --global user.email "sbd@gmail.com"
git config remote.origin.url git+ssh://git@github.com/someone/newstart.git
ssh -T git@github.com
git clone git+ssh://git@github.com/someone/newstart.git /tmp/newstart
Run Code Online (Sandbox Code Playgroud)
以上工作.
现在我想为Github使用不同的键名,而不是默认名称id_rsa.
ssh-keygen -t rsa -P '' -f .ssh/id_rsa.github
cat .ssh/id_rsa.github.pub |xclip
Run Code Online (Sandbox Code Playgroud)
我将新的pub密钥粘贴到Github网站上的ssh和gpg密钥中.
git init
git config --global user.name "someone"
git config --global user.email "sbd@gmail.com"
git config remote.origin.url git+ssh://git@github.com/someone/newstart.git
ssh -T git@github.com
Run Code Online (Sandbox Code Playgroud)
以上不起作用.
git clone git+ssh://git@github.com/someone/newstart.git /tmp/newstart
Run Code Online (Sandbox Code Playgroud)
以上也行不通.
ssh -i .ssh/id_rsa.github …Run Code Online (Sandbox Code Playgroud) 环境现状:debian8 + vim8.
filetype在.vimrc和vim/runtime/ftplugin/python.vim中都处于启用状态.
cat .vimrc
execute pathogen#infect()
execute pathogen#helptags()
syntax on
filetype plugin indent on
cat vim/runtime/ftplugin/python.vim
setlocal omnifunc=pythoncomplete#Complete
filetype plugin indent on
"other lines omitted.
Run Code Online (Sandbox Code Playgroud)
有些问题困惑我.
1.on omni completion
1.1模块中
的类名可以完成模块中的类或方法.
1.2内置函数名称
import sys
for key,value in enum
Run Code Online (Sandbox Code Playgroud)
要按ctrlxctrlo,没有enumerate弹出,为什么内置函数名称无法完成ctrlxctrlo?
2.tag完成
没有为python文件准备的标记文件,没有ctags -R *为任何python文件执行.
vim从什么时候开始ctrlxctrl]编辑这些关键字test.py?
要输入filtest.py并调用omni completion with ctrlxctrlo,不会弹出omni completion菜单.
要输入fil …
它是Python 3中的一个简单的光学字符识别(OCR)程序,用于获取字符串,我已经在此处上传了目标gif文件,请下载并将其另存为/tmp/target.gif。
try:
from PIL import Image
except ImportError:
import Image
import pytesseract
print(pytesseract.image_to_string(Image.open('/tmp/target.gif')))
Run Code Online (Sandbox Code Playgroud)
我将所有错误信息粘贴到此处,请修复它以从图像中获取字符。
/usr/lib/python3/dist-packages/PIL/Image.py:925: UserWarning: Couldn't allocate palette entry for transparency
"for transparency")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.5/dist-packages/pytesseract/pytesseract.py", line 309, in image_to_string
}[output_type]()
File "/usr/local/lib/python3.5/dist-packages/pytesseract/pytesseract.py", line 308, in <lambda>
Output.STRING: lambda: run_and_get_output(*args),
File "/usr/local/lib/python3.5/dist-packages/pytesseract/pytesseract.py", line 208, in run_and_get_output
temp_name, input_filename = save_image(image)
File "/usr/local/lib/python3.5/dist-packages/pytesseract/pytesseract.py", line 136, in save_image
image.save(input_file_name, format=img_extension, **image.info)
File "/usr/lib/python3/dist-packages/PIL/Image.py", line 1728, in save
save_handler(self, …Run Code Online (Sandbox Code Playgroud) 我已经安装了 tmux。
tmux -V
tmux 2.3
Run Code Online (Sandbox Code Playgroud)
设置我的配置文件。
cat ~/.tmux.conf
set -g mouse on
Run Code Online (Sandbox Code Playgroud)
输入tmux并在其中打开两个垂直窗口,左侧打开python3控制台,右侧打开vim。
现在用鼠标将光标移动到右侧第一行的开头。
进入正常模式并输入2yy+, 在我的+寄存器中复制两行。
在左侧python3 console窗口移动光标,如何将+寄存器中的内容粘贴到 python 控制台中?
@Kent ,按你说的做:1.将光标移动到第一行的开头,然后键入"+2Y
2.将光标移动到左侧窗口,然后单击鼠标中键,没有任何反应。3.ctrl+b按然后按]键。