我有一个包含6列的R数据框,我想创建一个只有三列的新数据框.
假设我的数据帧df,并且我想提取列A,B和E,这是唯一的命令,我可以计算出:
data.frame(df$A,df$B,df$E)
Run Code Online (Sandbox Code Playgroud)
有更紧凑的方式吗?
编辑:我已经使用Postgres和PostGIS几个月了,我很满意.
我需要分析几百万个地理编码记录,每个记录都有纬度和经度.这些记录包括至少三种不同类型的数据,我将试图看看每一组是否影响另一组.
什么数据库最适合所有这些数据的底层数据存储?这是我的愿望:
我已经使用MySql进行了一些开发,但如果有必要我可以更改.
我试图在Postgres 9.1.3中使用此查询:
WITH stops AS (
SELECT citation_id,
rank() OVER (ORDER BY offense_timestamp,
defendant_dl,
offense_street_number,
offense_street_name) AS stop
FROM consistent.master
WHERE citing_jurisdiction=1
)
UPDATE consistent.master
SET arrest_id = stops.stop
WHERE citing_jurisdiction=1
AND stops.citation_id = consistent.master.citation_id;
Run Code Online (Sandbox Code Playgroud)
我收到此错误:
ERROR: missing FROM-clause entry for table "stops"
LINE 12: SET arrest_id = stops.stop
^
********** Error **********
ERROR: missing FROM-clause entry for table "stops"
SQL state: 42P01
Character: 280
Run Code Online (Sandbox Code Playgroud)
我真的很困惑.根据Postgres文档,WITH子句显示正确.如果我在WITH子句中单独运行查询,我会得到正确的结果.
我的C#应用程序不会给我任何东西,但SOAP调用的结果为null.
我们已经使用SOAP Web服务公开了一些PeopleSoft ERP数据.
我从Visual Studio 2012 ASP.NET C#应用程序访问此SOAP服务.我有一个名为CampusDirectoryService的服务引用,它使用ERP生成的WSDL构建.
这是C#代码:
var service = new CampusDirectoryService.TEST_PortTypeClient();
var input = new CampusDirectoryService.InputParameters();
input.First_Name = FirstNameBox.Text;
input.Last_Name = LastNameBox.Text;
var returnData = service.TEST_OP(input);
Run Code Online (Sandbox Code Playgroud)
问题returnData是始终为空.通过Wireshark,我确认我实际上是通过数据获得有效的SOAP响应.returnData不应该为空.
我也通过soapUI确认了SOAP服务的正确有效结果.提交.NET发送的完全相同的SOAP请求(我将其从Wireshark中复制出来),我得到了预期的结果.
这是SOAP请求:
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<InputParameters xmlns="http://xmlns.oracle.com/Enterprise/Tools/schemas">
<Last_Name xmlns="">cambre</Last_Name>
<First_Name xmlns="">aren</First_Name>
</InputParameters>
</s:Body>
</s:Envelope>
Run Code Online (Sandbox Code Playgroud)
这是SOAP响应,ReturnID元素内部的一些内部数据被混淆或删除:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<root xmlns="http://peoplesoft.com/rootResponse">
<ReturnID>
<PRF_Name>Cambre,Aren</PRF_Name>
<Camp_Email>valid@email.com</Camp_Email>
</ReturnID>
</root>
</soapenv:Body>
</soapenv:Envelope>
Run Code Online (Sandbox Code Playgroud)
方法的返回类型TEST_OP是CampusDirectoryService.rootReturnID[]. …
我有一个ASP.NET应用程序,要求用户使用基本身份验证登录其域帐户.用户可以进行选择,然后按下按钮.
在按下按钮后的某个时刻是这段代码:WindowsIdentity.Impersonate(userIdentity.Token).userIdentity的类型为WindowsIdentity,之前设置为(WindowsIdentity)User.Identity.
userIdentity存储为会话变量,我认为这是因为按下按钮后,包含此代码的页面将通过AJAX调用.
当我点击这段代码时,它大约有2/3的时间,但是1/3的时间,我得到了这个例外:用于模仿的无效令牌 - 它不能被复制.我觉得对我来说最大的问题是为什么它有时会起作用而不是其他时候?在某些会话中,它在失败之前会工作几次.在其他人,它立即失败.
这是堆栈跟踪:
在System.Security.Principal.WindowsIdentity.CreateFromToken(IntPtr userToken)
在System.Security.Principal.WindowsIdentity..ctor(IntPtr userToken,String authType,Int32 isAuthenticated)
在System.Security.Principal.WindowsIdentity.Impersonate(IntPtr userToken)
at Resource_Booker.BLL.ReservationAgent.SubmitReservationRequest(预订,Patron赞助人)在C:\ dev\RoomRes\Resource Booker\BLL\ReservationAgent.cs:第101行
在C:\ dev\RoomRes\Resource Booker\Reserve.aspx.cs中的Resource_Booker.Reserve.reserve_Click(Object sender,EventArgs e):第474行
在System.EventHandler.Invoke(Object sender,EventArgs e)
在System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument)
在System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint,Boolean includeStagesAfterAsyncPoint)
这是一个令人困惑的因素:我无法在我的本地Windows 7 x64工作站上重现此问题 - 虽然我的身份验证是在此处隐式传递的,因为我使用的是localhost - 或者在Windows 2003 32位IIS 6.0环境中.它只发生在一个漂亮的Windows 2008 R2环境中.所有这些环境都是域成员.
我有一个WCF SOAP使用者,它由Visual Studio 2012从WSDL实现.WSDL由PeopleTools生成.基础对象是类型System.ServiceModel.ClientBase.
我需要SOAP请求类似于:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:sch="http://xmlns.oracle.com/Enterprise/Tools/schemas">
<soapenv:Header>
<wsse:Security soap:mustUnderstand="1" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
<wsse:UsernameToken>
<wsse:Username>[plain text username goes here]</wsse:Username>
<wsse:Password>[plain text password goes here]</wsse:Password>
</wsse:UsernameToken>
</wsse:Security>
</soapenv:Header>
<soapenv:Body>
<sch:InputParameters>
<Last_Name>Aren</Last_Name>
<First_Name>Cambre</First_Name>
</sch:InputParameters>
</soapenv:Body>
</soapenv:Envelope>
Run Code Online (Sandbox Code Playgroud)
这是我们最接近的地方:
<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope" xmlns:a="http://www.w3.org/2005/08/addressing">
<s:Header>
<a:Action s:mustUnderstand="1">http://schemas.xmlsoap.org/ws/2005/02/trust/RST/Issue</a:Action>
<a:MessageID>urn:uuid:3cc3f2ca-c647-466c-b38b-f2423462c837</a:MessageID>
<a:ReplyTo>
<a:Address>http://www.w3.org/2005/08/addressing/anonymous</a:Address>
</a:ReplyTo>
<a:To s:mustUnderstand="1">http://[internal URL to soap listener]</a:To>
</s:Header>
<s:Body>
<t:RequestSecurityToken Context="uuid-7db82975-2b22-4236-94a1-b3344a0bf04d-1" xmlns:t="http://schemas.xmlsoap.org/ws/2005/02/trust">
<t:TokenType>http://schemas.xmlsoap.org/ws/2005/02/sc/sct</t:TokenType>
<t:RequestType>http://schemas.xmlsoap.org/ws/2005/02/trust/Issue</t:RequestType>
<t:KeySize>256</t:KeySize>
<t:BinaryExchange ValueType=" http://schemas.xmlsoap.org/ws/2005/02/trust/tlsnego" EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary">FgMBAFoBAABWAwFQ9IhUFGUO6tCH+0baQ0n/3us//MMXzQA78Udm4xFj5gAAGAAvADUABQAKwBPAFMAJwAoAMgA4ABMABAEAABX/AQABAAAKAAYABAAXABgACwACAQA=</t:BinaryExchange>
</t:RequestSecurityToken>
</s:Body>
</s:Envelope>
Run Code Online (Sandbox Code Playgroud)
你会发现两个问题:
Body不在Header.InputParameters.这是必不可少的C#代码:
var …Run Code Online (Sandbox Code Playgroud) 我在C#程序中有以下PLINQ语句:
foreach (ArrestRecord arrest in
from row in arrestQueue.AsParallel()
select row)
{
Geocoder geocodeThis = new Geocoder(arrest);
writeQueue.Enqueue(geocodeThis.Geocode());
Console.Out.WriteLine("Enqueued " + ++k);
}
Run Code Online (Sandbox Code Playgroud)
这两个arrestQueue和writeQueue是ConcurrentQueues.
什么都没有并行:
geocodeThis.Geocode(),Visual Studio的Thread下拉只是说[ pid ]主线程.它永远不会去任何其他线程.geocodeThis.Geocode().即使我将Pooling = false添加到数据库连接字符串中,为了强制连接不被合并,我也从未看到过多使用过1个连接geocodeThis.Geocode().这看起来像是一个简单的PLINQ案例研究,我正在摸索为什么没有任何东西并行运行.
我有一个 Postgres 9.1.3 表,在WHERE Y=1之后有 206 万行,如下所示(它总共只有几万行,没有任何WHERE)。我正在尝试使用如下查询将数据添加到空字段:
WITH B AS (
SELECT Z,
rank() OVER (ORDER BY L, N, M, P) AS X
FROM A
WHERE Y=1
)
UPDATE A
SET A.X = B.X
FROM B
WHERE A.Y=1
AND B.Z = A.Z;
Run Code Online (Sandbox Code Playgroud)
该查询运行了几个小时并且似乎进展非常缓慢。事实上,我第二次尝试此操作时,在查询运行约 3 小时后停电了。恢复电源后,我分析了该表并得到了以下结果:
INFO: analyzing "consistent.master"
INFO: "master": scanned 30000 of 69354 pages, containing 903542 live rows and 153552 dead rows; 30000 rows in sample, 2294502 estimated total rows
Total query runtime: 60089 ms. …Run Code Online (Sandbox Code Playgroud) 我正在尝试在运行 Ubuntu 20.10 64 位的 Raspberry Pi 4 上安装 R 4.0.3。它已完全更新。
在我做任何事情之前,我使用 为该操作系统添加了正确的 CRAN 存储库sudo add-apt-repository 'deb https://cloud.r-project.org/bin/linux/ubuntu groovy-cran40/'。
当我运行时sudo apt install r-base,出现错误:r-base-core和r-recommendrf都被指定为需要 version >= 4.0.3-1.2010.0,“不会安装”。
单独检查它们,似乎r-base-core是问题所在。如果我尝试自行安装r-recommished,则会收到错误消息,指出它需要“r-base-core (>= 4.0.3-1.2010.0),但要安装 4.0.2-1build1”。
如果我检查https://cloud.r-project.org/bin/linux/ubuntu/groovy-cran40/,我注意到r-base-core 4.0.3 仅在 AMD64 变体中可用,根据amd64中的文件名。我观察到r-base包的文件的文件名中没有amd64 。对我来说,这表明,目前,如果您使用的是 Intel/AMD 64 位平台,则只能在 Ubuntu 20.10 上运行 R 4.0.3。https://cloud.r-project.org/bin/linux/ubuntu/groovy-cran40/Packages似乎支持这一点。
除了等待与更多平台兼容的r-base-core 4.0.3 软件包出现之外,还有其他实用的选择吗?
我在Windows 7 x64上运行Postgres 9.1.3 32位.(已使用32位因为没有Windows的PostGIS版本与64位兼容的Postgres)(编辑:作为PostGIS的2.0,它是与Windows Postgres的64位兼容.)
我有一个查询,左边连接一个table(consistent.master)与临时表,然后将结果数据插入第三个表(consistent.masternew).
由于这是a left join,因此结果表应与查询中的左表具有相同的行数.但是,如果我运行这个:
SELECT count(*)
FROM consistent.master
Run Code Online (Sandbox Code Playgroud)
我得到2085343.但如果我运行这个:
SELECT count(*)
FROM consistent.masternew
Run Code Online (Sandbox Code Playgroud)
我得到2085703.
怎么masternew会有更多的行master?不应该与查询中的左表masternew有相同的行数master?
以下是查询.在master与masternew表应该是相同的结构.
--temporary table created here
--I am trying to locate where multiple tickets were written on
--a single traffic stop
WITH stops AS (
SELECT citation_id,
rank() OVER (ORDER BY offense_timestamp,
defendant_dl,
offense_street_number,
offense_street_name) …Run Code Online (Sandbox Code Playgroud) postgresql ×5
c# ×4
r ×2
ajax ×1
asp.net ×1
asp.net-4.5 ×1
dataframe ×1
geocoding ×1
gis ×1
left-join ×1
linux ×1
mysql ×1
npgsql ×1
peoplesoft ×1
plinq ×1
postgis ×1
soap ×1
sql ×1
sql-insert ×1
sql-update ×1
ubuntu ×1
wcf ×1
web-services ×1
with-clause ×1
ws-security ×1
xml ×1