0

I want to read data and specify the data type at the beginning.

I have csv data look like this, it's data type is "character":

  • Id
  • "76561198042769362 "
  • "76561198049454009 "
  • "76561198066403163 "
  • "76561198079071374 "

And when I read data, it gives me this:

f<-read.csv('community_friendship.csv')
  • ID
  • 1 7.65612e+16
  • 2 7.65612e+16
  • 3 7.65612e+16
  • 4 7.65612e+16
  • 5 7.65612e+16

I try to transform it back to character, however, it round the origin data so I can not have people's real ID

as.character(f)
  • ID
  • "76561198042769360"
  • "76561198049454016"
  • "76561198066403168"
  • "76561198079071376"
  • "76561198083602880"

Do anyone know how to read origin data without transform data type?

S.F. Yeh
  • 59
  • 1
  • 11
  • 1
    Can you just use colClasses to declare ID as character? f <- read.csv('community_friendship.csv', colClasses=c(ID="character")) – Ben May 26 '19 at 14:05
  • @Ben oh~ It did work! thanks a lot! I did see this on R document but do not really understand what it is saying. – S.F. Yeh May 27 '19 at 04:50

0 Answers0