-2

what does as mean in

as.numeric(T)

or

variable <- as.data.frame('midwest')`

P.S. explaining abbreviation would be much better if you please...

Zheyuan Li
  • 71,365
  • 17
  • 180
  • 248
thsamajisama
  • 51
  • 1
  • 6
  • 2
    quite like its meaning in english — give me some value but *as* a different type of value. e.g. “give me (the data in) this list, but *as* a data frame.” or “give me that piece of paper, but *as* a paper airplane.” or: keep the info the same to the degree possible, but change the vehicle it’s delivered in. – lefft Sep 25 '18 at 03:15
  • u sure about that? is it a presumption? – thsamajisama Sep 25 '18 at 03:33
  • 1
    @HoggyStardust ????? What do you mean “a presumption”. Honestly, read `?as`! This question should be closed because too broad and zero effort. – Maurits Evers Sep 25 '18 at 05:58

1 Answers1

6

It means that you want an object to be converted to another one of a given type.

If I have x <- 1 it is an numeric and thus, it has numeric properties (e.g. can be summed to 1 an become 2 as in x + 1). When you use as.character(x), you basically transform that 1 (numeric) in a "1", which is an object of type "string". And so on. You can transform matrices to data frames with as.data.frame() and the opposite with as.matrix(), for example.

Hope this helps.

Zazen
  • 76
  • 2