标题说明了一切:我在另一个应用程序中打开了我的数据(例如,电子表格,如Excel或文本编辑器).如果我将该数据复制到我的操作系统剪贴板,我如何将其作为data.frame读入R?
我有一个带有辅助功能的个人R包,可在各种项目中使用。但是,我想让一个项目使用该项目的特定版本,然后继续添加代码。我知道我可以用分支来做到这一点,但我更喜欢用提交标签来做到这一点。
查看文档,devtools::install_git似乎如果我标记了一个提交,那么我应该能够安装该特定的提交,但这对我不起作用。
但是尝试安装它给了我这个:
devtools::install_git(url = 'http://<username>@<company stash url>/scm/preamp.git', branch = 'v0.0.1')
# > Downloading git repo http://<username>@<company stash url>/scm/preamp.git
# > Error in .local(object, ...) : 'v0.0.1' did not match any branch
Run Code Online (Sandbox Code Playgroud)
我的R会话信息:
> sessionInfo()
R version 3.2.3 (2015-12-10)
Platform: x86_64-apple-darwin13.4.0 (64-bit)
Running under: OS X 10.11.1 (El Capitan)
locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
attached base packages:
[1] parallel splines stats graphics grDevices utils datasets methods base
other attached packages:
[1] tidyr_0.5.1 lazyeval_0.2.0 assertthat_0.1
[4] beepr_1.2 preamp_0.1 stringr_1.0.0 …Run Code Online (Sandbox Code Playgroud) 我正在使用Anaconda 2.7,我的fill_between()尝试也变得毫无结果.我不确定我是否错过了一个包或者我的绘图语法是否抛出python ...
这是我的代码:
from scipy import stats
import matplotlib.pyplot as plt
from numpy import linspace
alpha_A = 11
beta_A = 41
alpha_B = 3
beta_B = 3
x = linspace(0,1,num = 1000)
postA = stats.beta(alpha_A, beta_A).pdf(x)
postB = stats.beta(alpha_B, beta_B).pdf(x)
plt.figure(2, figsize = (6,4))
plt.plot(postA, color = 'r', label = "A: Beta(" + str(alpha_A) + ',' + str(beta_A) + ')')
plt.plot(postB, color = 'b',label = "B: Beta(" + str(alpha_B) + ',' + str(beta_B) + ')')
plt.legend(loc = …Run Code Online (Sandbox Code Playgroud) 在先前版本的RI中,可以使用以下小函数组合没有"显着"音量阈值的因子级别:
whittle = function(data, cutoff_val){
#convert to a data frame
tab = as.data.frame.table(table(data))
#returns vector of indices where value is below cutoff_val
idx = which(tab$Freq < cutoff_val)
levels(data)[idx] = "Other"
return(data)
}
Run Code Online (Sandbox Code Playgroud)
这需要一个因子向量,寻找不会出现"经常"的水平,并将所有这些水平组合成一个"其他"因子水平.一个例子如下:
> sort(table(data$State))
05 27 35 40 54 84 9 AP AU BE BI DI G GP GU GZ HN HR JA JM KE KU L LD LI MH NA
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 …Run Code Online (Sandbox Code Playgroud) 这个问题听起来与此相似,但有所不同。当我按键F5在Spyder中运行脚本时,控制台将显示以下行:
runfile('C:/Users/usr/Documents/Python Scripts/BanditBook/algorithms/ucb/test_ucb1.py'
, wdir='C:/Users/usr/Documents/Python Scripts/BanditBook/algorithms/ucb')
Run Code Online (Sandbox Code Playgroud)
我想将该wdir参数更改为两个级别,以便自动运行脚本wdir = C:/Users/usr/Documents/Python Scripts/BanditBook。如何在Spyder中做到这一点?我正在运行Python 2.7。