前段时间看到plotnine库(封装的R语言ggplot2)作的图太美了,有点想重新拾起R语言^_^
R语言代码略带凌乱,讲真的还是更喜欢Python代码简洁。不过好几年不琢磨R语言,对R语言代码的凌乱美有些新奇,很好玩,这也许就是久别胜新欢吧。
而且R语言的文本分析生态也挺全的,Python与R结合起来,完美~
R语言读写操作
本章文件读写用到的包有
readtext
readr
readxl
writexl
其中readr、readxl均为tidyverse内的子包,做数据分析一般绕不开tidyverse
tidyverse含有的包
library(tidyverse)
tidyverse::tidyverse_packages()
## [1] "broom" "cli" "crayon" "dbplyr" "dplyr"
## [6] "forcats" "ggplot2" "haven" "hms" "httr"
## [11] "jsonlite" "lubridate" "magrittr" "modelr" "pillar"
## [16] "purrr"
前段时间看到plotnine库(封装的R语言ggplot2)作的图太美了,有点想重新拾起R语言^_^R语言代码略带凌乱,讲真的还是更喜欢Python代码简洁。不过好几年不琢磨R语言,对R语言代码的凌乱美有些新奇,很好玩,这也许就是久别胜新欢吧。而且R语言的文本分析生态也挺全的,Python与R结合起来,完美~ R语言读写操作本章文件读写用到的包有readtextreadrreadxlwritexl...
#删除month字段中内容是'1/','2/','6/','7/','8/','9/','10','11','12'的行
data=data[~(data['month'].isin(['1/','2/','6/','7/','8/','9/','10','11','12']))]
#仅删除字段名为month的一整列数据
data=data.drop(['month'],axis=1)
import pandas as pd
import numpy as np
#
导入
数据
#data .
> tab<- read.
csv
("data.
csv
",header = TRUE,stringsAsFactors = F,na.strings = "")
Warning messages:
1: In read.table(file = file, header = header, sep = sep, quote = quote, :
line 1 appears to...
r
语言
读
入
csv
文件
With the help of specific functions offered by R, reading the
CSV
files into data frames is much easier. 借助R提供的特定功能,将
CSV
文件
读
入数据帧要容易得多。
什么是
CSV
文件
? (What is a
CSV
file?)
CSV
is expanded as Com...
第一行解释:data表示定义的数据名称(随便取);read.table表示
读
取数据表;括号中双引号里是
文件
所在路径,注意使用“/”,而不是“\”;header=TRUE表示
读
取表标题。
第二行解释:直接运行data即数据名称即可输出
txt
中的数据。