This is my transaction data:
head(data)
id from_id to_id amount date_trx
<fctr> <fctr> <fctr> <dbl> <date>
226133 7468 5695 700.0 2005-01-04
779717 6213 9379 11832.0 2005-01-08
264887 7517 8170 1000.0 2005-01-10
830594 6143 9845 4276.0 2005-01-12
452670 6254 9640 200.0 2005-01-14
268574 6669 5815 200.0 2005-01-20
...
also
class(data)
[1] "tbl_df" "tbl" "data.frame"
typeof(data)
[1] "list"
I saved it as a csv file, for later use, to my computer via:
write.csv(data, "mydirectory/dataset.csv")
and read it via:
data_read <- read.csv("mydirectory/dataset.csv") %>% select(-X)
also
class(data_read)
[1] "tbl_df" "tbl" "data.frame"
typeof(data_read)
[1] "list"
However, when I want to get the values of 1st column in "data" with:
data[,1]
It returns:
[1] 226133 779717 264887 830594 452670 268574 ...
But, the same command in "data_read":
data_read[,1]
returns the column itself:
id
<fctr>
226133
779717
264887
830594
452670
268574
...
Why is that happening?
Maybe this can help:
data[,1,drop=F]
Also, one looks like a dataframe and the other is a tibble.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.