`
jarod2008
  • 浏览: 82406 次
  • 性别: 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数据库索引

    +----+-------------+-------+-------------+----------------------------+----------------------------+---------+------+------+------------------------------------------------------+ | 1 | SIMPLE | t4 ...

    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 |...

    Mysql Explain 详解.txt

    +----+-------------+------------+--------+-------------------+---------+---------+------+------+-------+ |id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra | +----+-...

    Explain关键字详解.pdf

    +----+-------------+-------+------------+------+---------------+------+---------+------+------+----------+--------------------------------------------------+ | id | select_type | table | partitions | ...

    bootstrap-table-reorder-rows.js.zip

    在本压缩包 "bootstrap-table-reorder-rows.js.zip" 中,核心文件是 "bootstrap-table-reorder-rows.js",这显然是用于实现 Bootstrap Table 的行重排功能。 Bootstrap Table 行内编辑功能允许用户直接在表格单元格...

    bootstrap-table-reorder-rows.js

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

    MYSQL数据库命令分享

    +-------+---------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +-------+---------+------+-----+---------+-------+ | id | int(11) | NO | PRI | NULL | | | name | ...

    一种平价的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

    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

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

    在MySQL数据库中,`SELECT FOUND_ROWS()` 和 `COUNT(*)` 都是用来获取数据表中记录数量的方法,但它们之间存在一些关键的区别。了解这些差异对于优化查询性能和满足特定需求至关重要。 首先,`COUNT(*)` 是一个标准...

    mysql学习笔记之表的基本操作

    +--------+-------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +--------+-------------+------+-----+---------+-------+ | deptno | int(11) | YES | | NULL | ...

    查看三种MySQL字符集的方法(转).docx

    +-----------+--------+---------+------------+------+-----------------+ | Name | Engine | Version | Row_format | Rows | Collation | +-----------+--------+---------+------------+------+--------------...

    linux下mysql数据库

    +-------+----------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +-------+----------+------+-----+---------+-------+ | id | int(3) | YES | | NULL | | | names | ...

    Control_maximum_number_of_rows_in_a_table.zip

    标题"Control_maximum_number_of_rows_in_a_table.zip"提示我们关注如何限制表中记录的数量。描述中提到的情况是特定场景的应用,即可能希望对特定业务规则进行限制,比如每个订单的订单行数不超过三个。 首先,...

    UseMySQL.txt

    +-----------+---------------+------+-----+---------+-------+ 3 rows in set (0.00 sec) ``` 这里展示了 `rs_dept` 表的三个字段:`dept_id`、`dept_name` 和 `dept_code` 及其详细信息。 #### 六、创建表...

    MySQL数据库基本操作教程

    +-------+----------+------+-----+---------+----------------+ | FIELD | Type | NULL | KEY | DEFAULT | Extra | +-------+----------+------+-----+---------+----------------+ | id | int(4) | NO | PRI | ...

Global site tag (gtag.js) - Google Analytics