`
jarod2008
  • 浏览: 80729 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

remove_rows_data_frame -+Table of Cont

    博客分类:
  • R
阅读更多

Using the built-in data set air quality , fir st load the data and check what var iables it contains:

data


(
air
quality
)

names

(
air
quality
)

Among ways to subset r ows of a data fr ame in S language, ther e ar e two usual appr oaches. Either you delete r ows by extr acting all other r ows of the data fr ame using a vector of logical values, or you r emove these r ows using a vector of negative indices.

Subset by logical indices

Assume that days 5 and 7 in May of the air quality measur ements ar e outlier s and you want to r epeat an analysis without these r ows. You wr ite:

length

(
air
quality
$Day
)

air
quality2
 <- subset

(
air
quality
, !(
Day %in% c

(
5
, 7
)
 & Month
 == 5
)
)

length

(
air
quality2
$Day
)

Subset by negative indices

Similar ly, you can delete specific r ows. In or der to delete lines 2 and 7, you wr ite:

length

(
air
quality
$Day
)

air
quality3
 <- air
quality
[
-c

(
2
, 7
)
, ]
 
length

(
air
quality3
$Day
)

Tr aps for beginner s

Claudia Beleites 2008/01/02

Be car eful with logical ver sus numer ic index vector s:

new

.data

 <- data

[
!outlier
s
, ]
  # logical indices

new

.data

 <- data

[
-outlier
s
, ]
  # numer
ic indices

Using the numer ic for m for a logical index vector will delete the fir st r ow only:

 >
 data

 <- 1
:10

 >
 outlier
s
 <- data


 %in% 3
:7

 >
 new

.data

 <- data

[
!outlier
s
]
  # (desir
ed effect)

 >
 new

.data

 [1]  1  2  8  9 10 

 >
 new

.data

 <- data

[
-outlier
s
]
  # (wr
ong code)

 >
 new

.data

 [1]  2  3  4  5  6  7  8  9 10
分享到:
评论

相关推荐

    eclipse +jsp+ servlet+MySQL省市县 三级菜单的查询

    +----------+--------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +----------+--------------+------+-----+---------+----------------+ | id | int(11) |...

    MySQL 入门学习 ——基础教程

    +-------------+-------------+------+-----+---------+-------+ 4 rows in set (0.00 sec) · 6、 往表中加入记录 我们先用SELECT命令来查看表中的数据: mysql&gt; select * from mytable; Empty set (0.00 sec...

    阿里巴巴分类信息 信息分类数据表MySQL UTF8 记录数9,553

    +-------+---------------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +-------+---------------------+------+-----+---------+----------------+ | id | ...

    中国 省市区三级级联菜单 数据库Mysql修正版本

    +-------+----------------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +-------+----------------------+------+-----+---------+----------------+ | id |...

    JAVA网吧计费管理系统

    +----------+-------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +----------+-------------+------+-----+---------+-------+ | uid | varchar(30) | NO | PRI | 0 |...

    bootstrap-table-reorder-rows.js.zip

    BootStrapTable行内编辑;压缩包内包含行内编辑所需要的js+css; BootStrapTable行内编辑;压缩包内包含行内编辑所需要的js+css;

    mysql字符串连接函数

    +------+---------------------------------------+ 3 rows in set (0.00 sec) repeat()函数 用来复制字符串,如下'ab'表示要复制的字符串,2表示复制的份数 mysql&gt; select repeat('ab',2); +---------------...

    mysql清除记录数

    1.mysql清空表语句后,新插入的语句会ID会以之前存在的序号记录下去,使用truncate命令清除记录,新插入的...+----+------+ | id | name | +----+------+ | 1 | ac6 | +----+------+ =================================

    mysql SELECT FOUND_ROWS()与COUNT()用法区别1

    那么,在SELECT查询中包含SQL_CALC_FOUND_ROWS选项,然后执行FOUND_ROWS()就可以了:代码如下mysql&gt; SELECT SQL_

    一种平价的chatgpt实现方案, 基于ChatGLM-6B + LoRA

    一种平价的chatgpt实现方案,基于清华的 ChatGLM-6B + LoRA 进行finetune. 数据集: alpaca 有colab的同学可以直接在colab...python tokenize_dataset_rows.py \ --jsonl_path data/alpaca_data.jsonl \ --save_path

    数据库数据库数据库数据库

    +------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ ...

    Control_maximum_number_of_rows_in_a_table.zip

    有时,您可能需要控制可以向表中添加多少条记录。这可以是整体限制或基于表中某些列的限制,例如基于外键。一个简化的示例可能是您希望将单个订单的订单行数限制为三个。

    oracle恢复工具-FY_Recover_Data

    Recover_Truncate_data.recover_table(tgtowner, tgttable, tgtowner, rectab, tgtowner, rsttab, datadir, datadir, recfile,datadir, copyfile, blksz); end; 第七步:查看输出内容和构造表名: 15:32:...

    UseMySQL.txt

    1. database express ...+--------------------+ | Database | +--------------------+ | information_schema | | kevinb | | mysql | | test | +--------------------+ 4 rows in set (0.03 sec)

    bootstrap-table-reorder-rows.js

    bootstrap-table-reorder-rows.js ,bootstraptable行拖动

    部署wordpress.txt

    Reading table information for completion of table and column names You can turn off this feature to get a quicker startup with -A Database changed mysql&gt; select User from user; +--------+ | ...

    bootstrap-table实现 行拖拽 插件jquery.tablednd.js bootstrap-table-reorder-rows.js

    bootstrap-table实现 行拖拽 插件 jquery.tablednd.js bootstrap-table-reorder-rows.js bootstrap-table-reorder-rows.css

    ABAP中的ALV操作

    DATA: DDEL_ROWS TYPE STANDARD TABLE OF SPFLI. METHODS: HANDLE_DATA_CHANGED FOR EVENT DATA_CHANGED OF CL_GUI_ALV_GRID IMPORTING ER_DATA_CHANGED. METHODS: UPDATE_DELTA_TABLES IMPORTING PR_...

    MySQL查看和修改时区的方法

    今天发现有一个程序插入的时间...+------------------+--------+ | Variable_name | Value | +------------------+--------+ | system_time_zone | EDT | | time_zone | SYSTEM | +------------------+--------+ 2 rows

    Mysql 查询数据库容量大小的方法步骤

    查询所有数据库的总大小 方法如下: mysql&gt; use information_schema; mysql&gt; select concat(round(sum(DATA_LENGTH/1024/1024),2),'MB') as ...每张表数据量=AVG_ROW_LENGTH*TABLE_ROWS+INDEX_LENGTH SELECT SUM

Global site tag (gtag.js) - Google Analytics