可能重复:
R - 在data.frame中删除具有NA的行
我有一个名为sub.new的数据框,其中包含多个列.我试图排除任何包含NA或blank space" ".
I tried to use subset(),但它的目标是特定的列条件.无论如何都要扫描整个数据帧并创建一个没有单元格的子集NA或者blank space?
在下面的示例中,只应保留第一行:
# ID SNP ILMN_Strand Customer_Strand
ID1234 [A/G] TOP BOT
Non-Specific NSB (Bgnd) Green
Non-Polymorphic NP (A) Red
Non-Polymorphic NP (T) Purple
Non-Polymorphic NP (C) Green
Non-Polymorphic NP (G) Blue
Restoration Restore Green
Run Code Online (Sandbox Code Playgroud)
有什么建议?谢谢
我正在around_action为我的customer_mailer班级建设一个班级,这样我begin and rescue每次打电话都不需要回头deliver_now
class CustomerMailer < ApplicationMailer
around_action :rescue_error
def send_email(customer)
...
end
def invite_friend(customer, invitee_email)
...
end
private
def rescue_error
yield
rescue => e
msg = "Caught exception! #{e} | #{action_name}"
puts msg
raise
end
end
Run Code Online (Sandbox Code Playgroud)
所以在救援中,我想用信息记录消息,例如调用了哪个动作,我设法找到方法action_name来显示调用了哪个动作,但是我找不到一种方法来检索传递给它的参数.行动,任何想法?
谢谢!
我有点麻烦这个问题.
我有两个表items和stocks
items
id | name
1 | item_1
2 | item_2
stocks
id | item_id | quantity | expired_on
1 | 1 | 5 | 2015-11-12
2 | 1 | 5 | 2015-11-13
3 | 2 | 5 | 2015-11-12
4 | 2 | 5 | 2015-11-14
Run Code Online (Sandbox Code Playgroud)
我希望能够检索按日期分组的大表,并且对于每个日期,按item_id分组,并显示未过期的数量总和.
result
date | item_id | unexpired
2015-11-11 | 1 | 10
2015-11-11 | 2 | 10
2015-11-12 | 1 | 5
2015-11-12 | 2 | 5
2015-11-13 | …Run Code Online (Sandbox Code Playgroud) 我有一个图像上传功能,支持多个文件上传,但不知何故,它最多只能一次上传5个图像.
我真的需要它可以像一百张图片一样上传.
这是处理上传的php文件
session_start();
$path = $_SERVER['DOCUMENT_ROOT'];
// Include the Image class file and database for the database connection
include_once $path . "/includes/db.php";
include_once $path . "/classes/Image.php";
$folderName = $_SESSION['id'];
// Loop through the image array
for ($i = 0; $i < count($_FILES['upload']); $i++) {
// Creating image location information
$fileLink = "upload/$folderName/" . $_FILES['upload']['name'][$i];
$fileType = $_FILES['upload']['type'][$i];
$fileSize = ($_FILES['upload']['type'][$i]) / 1024;
// See if a photo uploads to just upload not to a specific user
$source = "$path/$fileLink"; …Run Code Online (Sandbox Code Playgroud) 我有一个数组来存储这样的配置
$config = array (
'db' => array(
'db1' => array(
'dbname' => 'mydatabase',
'user' => 'myusername',
'pass' => 'mypassword',
'host' => 'myhost'
)
),
'url' => array(
'homeUrl' => 'http://www.example.com'
)
)
Run Code Online (Sandbox Code Playgroud)
我正在编写一个函数来通过传入一个类似的字符串从数组中检索数据,db.db1.dbname并且它假设给我'mydatabase'
我试图将字符串分解为数组以获取密钥,db, db1, and dbname.但在那之后,我有点坚持我应该如何使用它们$config -> db -> db1 -> dbname或者$config['db']['db1']['dbname']为了获得它们'mydatabase'.
理想情况下,假设我有名为的函数read($arg, $array),我想检索这样的结果
read('db.db1.dbname', $config), returns 'mydatabase'
read('url.homeUrl', $config), returns 'http://www.example.com'
Run Code Online (Sandbox Code Playgroud)
由于我不知道字符串中包含多少个键,因此我需要更加动态.提前致谢