as.data.frame()中的R函数t()
我有一个关于R编程的问题 我得到了一个示例代码。这是as.data.frame()中的R函数t(),r,dataframe,R,Dataframe,我有一个关于R编程的问题 我得到了一个示例代码。这是 x <- read.table("example.txt", sep="=", header=F, nrows=6, fill=T) x <-x[,c(1:2)] x_t <- as.data.frame(t(x1)) names(x_t) <- c("ID", "URL", "SIZE", "DATE", "TIME", "DATASET") x_t <- x_t[c(2),] rownames(x
x <- read.table("example.txt", sep="=", header=F, nrows=6, fill=T)
x <-x[,c(1:2)]
x_t <- as.data.frame(t(x1))
names(x_t) <- c("ID", "URL", "SIZE", "DATE", "TIME", "DATASET")
x_t <- x_t[c(2),]
rownames(x_t) <- NULL
如何编写源代码
若你们知道答案,请帮帮我。
谢谢。谢谢!我能再问一个问题吗?我想添加V1,V2,V3。。。在ID、URL、大小等方面使用V6。。。。数据集。我怎样才能解决这个问题?左边的“1”是什么?对不起,我必须使用变量assignpastea,i,_t,sep=,docxtracr::assign_colnames as.data.frame tpastea,i,sep=,stringsAsFactors=FALSE,1你能再帮我一个吗?
data.frame(
V1 = c("ID", "URL", "SIZE", "DATE", "TIME", "DATASET"),
V2 = c("A0001", "htttp://long.url", "54258", "27/06/02", "16:47:17", "Commercial Banks"),
stringsAsFactors=FALSE # use stringsAsFactors = FALSE in your `read.table()` call as well
) -> xdf
xdf
## V1 V2
## 1 ID A0001
## 2 URL htttp://long.url
## 3 SIZE 54258
## 4 DATE 27/06/02
## 5 TIME 16:47:17
## 6 DATASET Commercial Banks
docxtractr::assign_colnames(
as.data.frame(
t(xdf),
stringsAsFactors=FALSE
),
1)
## ID URL SIZE DATE TIME DATASET
## 1 A0001 htttp://long.url 54258 27/06/02 16:47:17 Commercial Banks
assign(rownames(paste("a", i, "_t")), NULL)
data.frame(
V1 = c("ID", "URL", "SIZE", "DATE", "TIME", "DATASET"),
V2 = c("A0001", "htttp://long.url", "54258", "27/06/02", "16:47:17", "Commercial Banks"),
stringsAsFactors=FALSE # use stringsAsFactors = FALSE in your `read.table()` call as well
) -> xdf
xdf
## V1 V2
## 1 ID A0001
## 2 URL htttp://long.url
## 3 SIZE 54258
## 4 DATE 27/06/02
## 5 TIME 16:47:17
## 6 DATASET Commercial Banks
docxtractr::assign_colnames(
as.data.frame(
t(xdf),
stringsAsFactors=FALSE
),
1)
## ID URL SIZE DATE TIME DATASET
## 1 A0001 htttp://long.url 54258 27/06/02 16:47:17 Commercial Banks