小编Ann*_*lee的帖子

将ISIN解析为String

我想从一个非常奇怪的字符串解析ISIN,我的代码看起来像这样:

> df <- fread("C:/Users/WZHPCH/Desktop/Error Messages/df.csv", sep=";", stringsAsFactors=FALSE)
> dput(df)
structure(list(ID = c(1L, 2L, 4L, 2L, 3L, 24L), VAL = c("TES+XS0255015603+ae2s", 
"TEST*XS0255015603+d2aasd", "safd*adf*XS0255015603++", "gasdfs*dsa*US0917971006", 
"asdfsUS0917971006adf", "sd-asd-afds-US0917971006")), .Names = c("ID", 
"VAL"), row.names = c(NA, -6L), class = c("data.table", "data.frame"
), .internal.selfref = <pointer: 0x0000000000110788>)
> df$parsedISIN <- gsub("^[a-zA-Z]{2}[0-9]{10}$", '\\1', df$VAL)
Run Code Online (Sandbox Code Playgroud)

我对gsub做错了什么?

有什么建议?

感谢您的回复!

regex statistics r

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

将字符串连接到数据框列

我想在data.frame中添加相同的字符串.

> df1 <- data.frame(pt1="a", pt2="b", row.names=1)
> df1
  pt1 pt2
1   a   b
Run Code Online (Sandbox Code Playgroud)

结果我希望:

   pt1                 pt2
1  Add this string a   Add this string b
Run Code Online (Sandbox Code Playgroud)

r dataframe

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

将文本添加到data.frame的一列

我想只在一列添加一个文本.

我尝试了以下(这里作为一个例子):

employee <- c('John Doe','Peter Gynn','Jolie Hope')
addMe <- c('test1','test2','test3')
salary <- c(21000, 23400, 26800)
dat <- data.frame(employee, salary, addMe)

dat[] <- lapply(dat$addMe, function(x) paste(' Please delete this col!', x))
Run Code Online (Sandbox Code Playgroud)

但是,我的结果框架如下所示:

     employee                            salary                          addMe
1    Please delete this col! John Doe    Please delete this col! 21000   Please delete this col! test1
2    Please delete this col! Peter Gynn  Please delete this col! 23400   Please delete this col! test2
3    Please delete this col! Jolie Hope  Please delete this col! …
Run Code Online (Sandbox Code Playgroud)

r dataframe

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

在部件之间获取字符串

我有一个字符串:

c(\\", \" \", \" \", \"\", \"\", \"Object:\", \"\", \"\", NA, \"vlg. numb 2\", \"\", NA, NA, NA, NA, \"This: \", NA, \"Date\r\n(21.03.1961)\", \"K..\r\nRom (28.04.2012)\", NA, NA, \"test.test@yahoo.de\", NA, \"Italy, Rome\", NA, \"UP, Ö\", \"BP, \", NA, NA, NA, NA, NA)"
Run Code Online (Sandbox Code Playgroud)

我想获得的字符串numb 2,这是间vlg.numb 2\"

我试过了:

=MID(A18;FIND("vlg.";A18;1)+7;FIND("/object";A18;1)-FIND("\";A18;1)-8)
Run Code Online (Sandbox Code Playgroud)

但是,我才#VALUE回来.

有什么建议我做错了吗?

excel vba spreadsheet excel-vba

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

Laravel Migrations - 列已存在

我正在运行,Laravel Framework version 5.2.45并希望迁移我的数据库迁移.

我有两次迁移.一个是2014_10_12_100000_create_password_resets_table开箱即用的标准,另一个是我新创建的迁移2017_02_19_172350_create_keywords_table:

<?php

use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateKeywordsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('keywords', function (Blueprint $table) {
            $table->increments('id');
            $table->string('keyword');
            $table->timestamps();
            $table->timestamps('published_at');

        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::drop('keywords');
    }
}
Run Code Online (Sandbox Code Playgroud)

php artisan migrate我喜欢的典型(回滚前):

root:~/workspace $ php artisan migrate:rollback
Rolled back: 2014_10_12_100000_create_password_resets_table
root:~/workspace $ php artisan …
Run Code Online (Sandbox Code Playgroud)

php laravel laravel-5 laravel-5.2

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

与 knex 的未定义数据库连接

我正在执行以下脚本node acl.js

acl.js

require('dotenv').config()

const _ = require('lodash');
const buckets = require('./buckets');
const knex = require('../src/config/db'); //HERE I am getting the ERROR

var downSql = 'DROP TABLE IF EXISTS "{{prefix}}{{meta}}";'+
    'DROP TABLE IF EXISTS "{{prefix}}{{resources}}";'+
    'DROP TABLE IF EXISTS "{{prefix}}{{parents}}";'+
    'DROP TABLE IF EXISTS "{{prefix}}{{users}}";'+
    'DROP TABLE IF EXISTS "{{prefix}}{{roles}}";'+
    'DROP TABLE IF EXISTS "{{prefix}}{{permissions}}";';
var upSql = 'CREATE TABLE "{{prefix}}{{meta}}" (key TEXT NOT NULL PRIMARY KEY, value TEXT[][] NOT NULL);'+
    'INSERT INTO "{{prefix}}{{meta}}" VALUES (\'users\', \'{}\');'+
    'INSERT …
Run Code Online (Sandbox Code Playgroud)

javascript postgresql node.js knex.js

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

git-ftp:不是 git 命令

我正在尝试在我的 Windows 8.1 安装下安装git-ftpgit version 2.17.0.windows.1

我做了以下事情:

cd /c/"Program Files"/Git
git clone https://github.com/git-ftp/git-ftp git-ftp.git
cd git-ftp.git && chmod +x git-ftp
cp /c/"Program Files"/Git/git-ftp.git/git-ftp /c/"Program Files"/Git/bin/git-ftp
Run Code Online (Sandbox Code Playgroud)

但是,当以管理员身份在新的 git 控制台上重新启动时,我得到以下信息:

$ git ftp
git: 'ftp' is not a git command. See 'git --help'.

The most similar command is
        fetch
Run Code Online (Sandbox Code Playgroud)

官方安装说明也将cp文件git-ftp复制到该文件夹​​中C:\Program Files (x86)\Git\bin

有什么建议我做错了什么吗?

我很感谢你的回复!

更新 执行后我找到了我的执行路径:

$ git --exec-path
C:\Program Files\Git\mingw64/libexec/git-core
Run Code Online (Sandbox Code Playgroud)

我复制了文件:

cp /c/"Program Files"/Git/git-ftp.git/git-ftp /c/"Program Files"/Git/bin/git-ftp
Run Code Online (Sandbox Code Playgroud)

该文件现在位于:

在此输入图像描述

但是,我仍然收到上述错误git: 'ftp' is …

git

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

将新模块添加到角度应用程序

我有申请:

var testApp = angular.module('testApp', ['ngRoute']);

我安装了一个模块但尚未完全包含在我的应用程序中.

如何添加angular.module('myModule', ['decipher.tags', 'ui.bootstrap.typeahead'];,以便我可以将它用于我的应用程序?

我感谢你的回答!

javascript angularjs

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

无法强制类 typeOf 为 data.frame 的 double

我想将函数的输出转换pcomp()为数据框,问题是使用:

使用时as.data.frame我得到:

Error in as.data.frame.default(data.pca1$loadings) : 
  cannot coerce class ""loadings"" to a data.frame
Run Code Online (Sandbox Code Playgroud)

我的问题是我不知道将数据转换为dataframe.

我的数据:

dput(data.pca1$loading)
structure(c(0.629999587107591, 0.544821342951502, 0.757214347947699, 
0.140799724239407, 0.195350889504226, 0.30782155605534, 0.113779470611058, 
0.25319481053313, 0.530575304369119, 0.161372414349993, 0.172071942829558, 
0.181110279027528, 0.32087938033537, 0.199923250086931, 0.112976439383677, 
0.435960093914842, 0.735714667273012, 0.546839296993964, 0.618721696774699, 
0.157746933602662, 0.196394937008026, 0.323352336171706, 0.312677801641149, 
0.0540081734469586, 0.236882360216423, 0.160496430572191, 0.126509131465792, 
0.160239501804437, 0.28141267308665, 0.286102918406781, 0.59838483667591, 
0.588492755323989, 0.597607970656895, -0.00300183993888212, 0.132863946525179, 
0.3091527351007, 0.967808869898446, 0.460034358552482, 0.0613549566320599, 
0.0823819988685729, 0.243877077120173, 0.0998230648040528, 0.0718231415302767, 
0.241248015517299), .Dim = c(11L, 4L), .Dimnames = list(c("Q1", 
"Q2", "Q3", "Q4", "Q6", "Q7", "Q8", "Q9", …
Run Code Online (Sandbox Code Playgroud)

statistics r

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

获得最后9次出现

我使用MySQL 5.0.12,我有下表:

| post_id | price | created_at          |
|---------|-------|---------------------|
| 10      | 3.5   | 2018-06-18 07:36:34 |
| 11      | 4.8   | 2018-06-17 07:36:34 |
| 10      | 5     | 2018-06-16 07:36:34 |
| 10      | 5     | 2018-06-15 07:36:34 |
| 6       | 3.6   | 2018-06-12 07:36:34 |
| 10      | 2     | 2018-06-14 07:36:34 |
| 10      | 6     | 2018-06-13 07:36:34 |
| 10      | 9     | 2018-06-12 07:36:34 |
| 10      | 4     | 2018-06-11 …
Run Code Online (Sandbox Code Playgroud)

mysql sql

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