|
1. Read data off of hard drive
2. R stores it as an object
Working directory
setwd("D:/myData/") change a new working directory
list.files() show all the files in this directory
Read data from this directory
myData <- read.csv("data1.csv")
or
myData <- read.csv(list.files()[3])
Write data to this directory
write.csv(myData, "updated data.csv")
list.files()
head() shows the first few or 6 lines of the data
tail() shows the last few or 6 lines of the data
names() gives the column name of the data
Pulling out columns
Data$columnname
Data[, columnname]
Data[,3]
Archiver|手机版|科学网 ( 京ICP备07017567号-12 )
GMT+8, 2024-9-19 16:53
Powered by ScienceNet.cn
Copyright © 2007- 中国科学报社