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.
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
)
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
)
— 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
分享到:
相关推荐
+----------+--------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +----------+--------------+------+-----+---------+----------------+ | id | int(11) |...
+----+-------------+-------+-------------+----------------------------+----------------------------+---------+------+------+------------------------------------------------------+ | 1 | SIMPLE | t4 ...
+-------------+-------------+------+-----+---------+-------+ 4 rows in set (0.00 sec) · 6、 往表中加入记录 我们先用SELECT命令来查看表中的数据: mysql> select * from mytable; Empty set (0.00 sec...
+-------+---------------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +-------+---------------------+------+-----+---------+----------------+ | id | ...
+-------+----------------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +-------+----------------------+------+-----+---------+----------------+ | id |...
+----+-------------+------------+--------+-------------------+---------+---------+------+------+-------+ |id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra | +----+-...
+----+-------------+-------+------------+------+---------------+------+---------+------+------+----------+--------------------------------------------------+ | id | select_type | table | partitions | ...
在本压缩包 "bootstrap-table-reorder-rows.js.zip" 中,核心文件是 "bootstrap-table-reorder-rows.js",这显然是用于实现 Bootstrap Table 的行重排功能。 Bootstrap Table 行内编辑功能允许用户直接在表格单元格...
bootstrap-table-reorder-rows.js ,bootstraptable行拖动
+-------+---------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +-------+---------+------+-----+---------+-------+ | id | int(11) | NO | PRI | NULL | | | name | ...
一种平价的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-reorder-rows.css
在MySQL数据库中,`SELECT FOUND_ROWS()` 和 `COUNT(*)` 都是用来获取数据表中记录数量的方法,但它们之间存在一些关键的区别。了解这些差异对于优化查询性能和满足特定需求至关重要。 首先,`COUNT(*)` 是一个标准...
+--------+-------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +--------+-------------+------+-----+---------+-------+ | deptno | int(11) | YES | | NULL | ...
+-----------+--------+---------+------------+------+-----------------+ | Name | Engine | Version | Row_format | Rows | Collation | +-----------+--------+---------+------------+------+--------------...
+-------+----------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +-------+----------+------+-----+---------+-------+ | id | int(3) | YES | | NULL | | | names | ...
标题"Control_maximum_number_of_rows_in_a_table.zip"提示我们关注如何限制表中记录的数量。描述中提到的情况是特定场景的应用,即可能希望对特定业务规则进行限制,比如每个订单的订单行数不超过三个。 首先,...
+-----------+---------------+------+-----+---------+-------+ 3 rows in set (0.00 sec) ``` 这里展示了 `rs_dept` 表的三个字段:`dept_id`、`dept_name` 和 `dept_code` 及其详细信息。 #### 六、创建表...
+-------+----------+------+-----+---------+----------------+ | FIELD | Type | NULL | KEY | DEFAULT | Extra | +-------+----------+------+-----+---------+----------------+ | id | int(4) | NO | PRI | ...