小编Sto*_*ace的帖子

如何从向量中删除多个值?

我有一个像这样的矢量:a = c(1:10)我需要删除多个值,例如:2, 3, 5

如何在向量中删除这些数字(它们不是向量中的位置)?

此刻我循环向量并执行以下操作:

a[!a=NUMBER_TO_REMOVE]
Run Code Online (Sandbox Code Playgroud)

但我认为有一个功能可以自动完成.

r

114
推荐指数
4
解决办法
22万
查看次数

matplotlib中的直方图,x轴上的时间

我是matplotlib(1.3.1-2)的新手,我找不到合适的起点.我想用matplotlib在直方图中绘制点随时间的分布.

基本上我想绘制一个日期的累积总和.

date
2011-12-13
2011-12-13
2013-11-01
2013-11-01
2013-06-04
2013-06-04
2014-01-01
...
Run Code Online (Sandbox Code Playgroud)

这会

2011-12-13 -> 2 times
2013-11-01 -> 3 times
2013-06-04 -> 2 times
2014-01-01 -> once
Run Code Online (Sandbox Code Playgroud)

由于多年来会有很多积分,我想设置start date我的x-Axisend date,然后标记n-time steps(即1年步骤),最后确定bins将有多少.

我怎么做到这一点?

python time plot matplotlib histogram

25
推荐指数
2
解决办法
2万
查看次数

无法安装rgdal

我想安装rgdal"R version 3.2.3 (2015-12-10)".我下载并安装了

  • GDAL 1.11完成
  • PROJ框架v4.9.2-2
  • GEOS框架v3.5.0-1

来自KyngChaos

然后在RStudio我打字install.packages("rgdal")给了我这个:

> .... 
> 
> configure: CC: clang configure: CXX: clang++ configure: rgdal:
> 1.1-1 checking for /usr/bin/svnversion... yes configure: svn revision: 
> 572 checking for gdal-config... 
> no no configure: error: gdal-config
> not found or not executable. ERROR: configuration failed for package
> ‘rgdal’
> * removing ‘/Library/Frameworks/R.framework/Versions/3.2/Resources/library/rgdal’
> Warning in install.packages :   installation of package ‘rgdal’ had
> non-zero exit status …
Run Code Online (Sandbox Code Playgroud)

macos r gdal rgdal

24
推荐指数
3
解决办法
2万
查看次数

SpatialPoints和SpatialPointsDataframe

使用R中的sp包我想知道何时使用SpatialPoints和SpatialPointsDataframe.在我看来,差别不大?!

唯一的区别是在SpatialPointsDataframe中我可以存储更多属性吗?!如果是这样,我可以从现有的Dataframe创建一个SpatialPointDataframe(如果坐标在此数据框中不存在),而不必绕道创建spatialPoints吗?

r r-sp

16
推荐指数
1
解决办法
1万
查看次数

词法或预处理器问题 - 找不到 event2/event-config.h 文件

我有一个干净安装的 Mac 10.15.7,里面有新安装的 xCode ( 12.4) 。我react-native按照此处的官方说明进行安装。我创建了一个新项目并尝试构建它(从 Xcode),但最终出现此错误:

词法或预处理器问题 - 找不到 event2/event-config.h 文件

错误信息

似乎与Flipper. 我完全不知道如何解决这个问题,因为我不熟悉CPP开发和它需要的文件/数据结构......

javascript xcode flipper react-native

16
推荐指数
1
解决办法
1万
查看次数

View有阴影集但无法在React Native中有效计算阴影

我在 iOS 上收到此警告。

RCTView 类型的 View ... 有阴影集,但无法有效计算阴影。考虑设置背景颜色来解决此问题,或将阴影应用到更具体的组件。

可以在这里找到https://github.com/facebook/react-native/commit/e4c53c28aea7e067e48f5c8c0100c7cafc031b06

我不明白是什么导致了警告。<View />这是应用于导致问题的样式。

const styles = StyleSheet.create({
  borderColor: '#EDAE49',
  borderWidth: 2,
  borderRadius: 7,
  backgroundColor: '#EDAE49',
  padding: 7,
  marginBottom: 5,
  width: '100%',
  shadowColor: '#000',
  shadowOffset: {width: 0, height: 2},
  shadowOpacity: 0.5,
  shadowRadius: 2,
  elevation: 2,
});
Run Code Online (Sandbox Code Playgroud)

是什么导致了这里的低效率?有backgroundColor规定,没有透明度backgroundColor

javascript ios react-native

15
推荐指数
1
解决办法
2万
查看次数

Python中的子进程:文件名太长

我尝试通过Python 2.6中的子进程模块调用一个shellcript.

import subprocess

shellFile = open("linksNetCdf.txt", "r")

for row in shellFile:
    subprocess.call([str(row)])
Run Code Online (Sandbox Code Playgroud)

我的文件名长度介于400到430个字符之间.调用脚本时,我收到错误:

File "/usr/lib64/python2.6/subprocess.py", line 444, in call
return Popen(*popenargs, **kwargs).wait()
File "/usr/lib64/python2.6/subprocess.py", line 595, in __init__
errread, errwrite)
File "/usr/lib64/python2.6/subprocess.py", line 1106, in _execute_child
raise child_exception
OSError: [Errno 36] File name too long
Run Code Online (Sandbox Code Playgroud)

内线的一个例子linksNetCdf.txt

./ShellScript 'Title' 'Sometehing else' 'InfoInfo' 'MoreInformation' inputfiile outputfile.txt 3 2
Run Code Online (Sandbox Code Playgroud)

任何想法如何仍然运行脚本?

python shell

11
推荐指数
2
解决办法
1万
查看次数

创建SpatialPointsDataframe

我有一个df1包含10列的数据框.其中两列是lnglat.我想创建一个SpatialPointsDataframefrom df1.当我读到如何创建SpatialPointsDataframe时,感觉就像我必须m1从我的两个坐标列创建一个矩阵,然后将该矩阵分配给数据帧'df1`.

这将是一个绕道,因为我的坐标已经是我的数据框中的一列df1.此外,我如何确保矩阵m1中的坐标分配给我的数据帧中的正确行df1

多数民众赞成我的df1样子

> df1
    a    b    c    d    e    lat   lng
1   12   f2   23   dd   2d   15.6  80.9
2   12   g5   99   NA   hh   20.9  10.9
3   13   g4   12   aa   3r3  1.2   81.8
4   ..   ..   ..   ..   ..   ..    .. 
Run Code Online (Sandbox Code Playgroud)

r spatial geospatial r-sp

11
推荐指数
2
解决办法
2万
查看次数

将对象解构为数组

我有这个对象

const foo = {
    a: 'kitten',
    b: 'puppy',
    c: 'lion'
};
Run Code Online (Sandbox Code Playgroud)

将其解构为变量就像这样

const { a, b, c } = foo;
Run Code Online (Sandbox Code Playgroud)

是否有一个简单的方法如何将其解构为数组,以便结果是

const array = [a, b, c];
Run Code Online (Sandbox Code Playgroud)

javascript destructuring

10
推荐指数
1
解决办法
9164
查看次数

BeautifulSoup有错误的回应

我正试着用BS弄湿我的脚.我试图通过文档工作,但在我遇到问题的第一步.

这是我的代码:

from bs4 import BeautifulSoup
soup = BeautifulSoup('https://api.flickr.com/services/rest/?method=flickr.photos.search&api_key=5....1b&per_page=250&accuracy=1&has_geo=1&extras=geo,tags,views,description')

print(soup.prettify())
Run Code Online (Sandbox Code Playgroud)

这是我得到的回应:

Warning (from warnings module):
File "/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/site-packages/bs4/__init__.py", line 189
'"%s" looks like a URL. Beautiful Soup is not an HTTP client. You should probably use an     
HTTP client to get the document behind the URL, and feed that document to Beautiful Soup.' % markup)
UserWarning: "https://api.flickr.com/services/rest/?method=flickr.photos.search&api_key=5...b&per_page=250&accuracy=1&has_geo=1&extras=geo,tags,views,description" 
looks like a URL. Beautiful Soup is not an HTTP client. You should 
probably use an HTTP client to get the document behind the …
Run Code Online (Sandbox Code Playgroud)

html python beautifulsoup html-parsing

9
推荐指数
1
解决办法
9750
查看次数