You can use the setDF function from the data.table package that is a helper function to convert a data.table or list of equal length to data.frame by reference.
Usage:
setDF(x, rownames=NULL)
Arguments
x
A data.table, data.frame or list of equal length.
rownames
A character vector to assign as the row names of x.
In your case:
df <- data.frame(VALUE = c("1007_s_at","1053_at","117_at","121_at","1255_g_at","1294_at"),
ABS_CALL= c(957.7292,320.6327,429.8423,2395.7364,116.4936,739.9271),
DETECTION = c("P","P","P","P","A","A"),
P.VALUE = c(0.004862793,0.031335632,0.017000453,0.011447358,0.397993682,0.066864977))
df
df
VALUE ABS_CALL DETECTION P.VALUE
1 1007_s_at 957.7292 P 0.004862793
2 1053_at 320.6327 P 0.031335632
3 117_at 429.8423 P 0.017000453
4 121_at 2395.7364 P 0.011447358
5 1255_g_at 116.4936 A 0.397993682
6 1294_at 739.9271 A 0.066864977
Using setDT function:
library(data.table)
setDT(df, keep.rownames = TRUE)[]
rn VALUE ABS_CALL DETECTION P.VALUE
1: 1 1007_s_at 957.7292 P 0.004862793
2: 2 1053_at 320.6327 P 0.031335632
3: 3 117_at 429.8423 P 0.017000453
4: 4 121_at 2395.7364 P 0.011447358
5: 5 1255_g_at 116.4936 A 0.397993682
6: 6 1294_at 739.9271 A 0.066864977
You can also use the rownames_to_column() as follows:
df <- tibble::rownames_to_column(df, "S.NO")
df
S.NO VALUE ABS_CALL DETECTION P.VALUE
1 1 1007_s_at 957.7292 P 0.004862793
2 2 1053_at 320.6327 P 0.031335632
3 3 117_at 429.8423 P 0.017000453
4 4 121_at 2395.7364 P 0.011447358
5 5 1255_g_at 116.4936 A 0.397993682
6 6 1294_at 739.9271 A 0.066864977