当前位置: 首页 > news >正文

R notes[2]

文章目录

  • sequence
  • references

sequence

  1. organized equence is a regular facility of R language,it can be generated by the seq() function.of couse ,in oder to make arbitrary list, the c() is used to achieve the task,that is explained at the previous note.
    the seq funtcion forms as follows.
seq(from_value,to_value,step)
> seq(1,10,2)
[1] 1 3 5 7 9
> seq(1,10,1)[1]  1  2  3  4  5  6  7  8  9 10
> seq(1,10,7)
[1] 1 8
> seq(10,1,-1)[1] 10  9  8  7  6  5  4  3  2  1

you may assign arguments in keyword,for example, seq(to=1,from=10,by=-1).
the rep function also make sequence which is different from seq,rep puts the same elements together into a list with specified number of times by default.

> rep(-1,3)
[1] -1 -1 -1
> rep(1,each=2)
[1] 1 1
> rep(1,times=2)
[1] 1 1
> rep(1,2)
[1] 1 1

We need to pay attention that if given element is a list,the rep have a argument named each which will repeatedly generate each element of given list for specified number of times and then arrange them in the original order of those elements .

> a<-c(1,2)
> rep(a,3)
[1] 1 2 1 2 1 2
> rep(a,times=3)
[1] 1 2 1 2 1 2
> rep(a,each=3)
[1] 1 1 1 2 2 2

references

  1. https://cran.r-project.org/doc/manuals/
http://www.dtcms.com/a/359550.html

相关文章:

  • VMware虚拟机网盘下载与安装指南(附安装包)
  • GaRe:面向非约束户外照片集的可重光照 3D 高斯溅射技术简要解析
  • Python与Rust语法对比详解:从入门到精通
  • Day19_【机器学习—线性回归 (1)】
  • Linux-搭建NFS服务器
  • Hutool DsFactory多数据源切换
  • 深度学习篇---MobileNet网络结构
  • 揭秘数据分组的智慧:Self-Constrained Clustering Ensemble 介绍
  • leetcode_240 搜索二维矩阵 II
  • Windows PostgreSQL JDBC驱动安装包位置
  • 基于开源AI大模型、AI智能名片与S2B2C商城小程序的“教育用户”模式探究
  • C数据结构:排序
  • Knit-易用的prompt管理和调试工具
  • 程序员独立开发直播卖产品 SOP 教程
  • 下载 | Win10正式版最新原版ISO系统映像 (22H2、19045.6282、多合一版本)-系统问题修复
  • Spring Boot 3.0 应用 HTTP 到 HTTPS 技术改造方案
  • AI 相关内容:Agent、MCP、Prompt 与 RAG 入门指南
  • VSCode `tasks.json` 中 `tasks` 数组的详细解析
  • AI 应用 图文 解说 (二) -- 百度智能云 ASR LIM TTS 语音AI助手源码
  • VSCode的launch.json配置文件在C++项目调试中的全面应用
  • React学习教程,从入门到精通, ReactJS - 架构(6)
  • 心路历程-基础命令3
  • 编程与数学 03-004 数据库系统概论 11_数据库的维护
  • OpenCV 图像处理实战与命令行参数配置:从轮廓检测到模板匹配
  • 嵌入式Linux RAMDisk驱动开发
  • 介绍Ansible和实施Ansible PlayBook
  • Linux 特殊文件系统
  • LeetCode每日一题,2025-8-31
  • k8s中 discovery-token和token 的区别
  • COLA:大型语言模型高效微调的革命性框架