In a situation where this matters to you, you can check what type of number you've got by using the class() function: If you want the integer 3, you need to signify it as 3L or with the as.integer() function. (If you don't create a list, you may be unpleasantly surprised that your variable containing (3, 8, "small") was turned into a vector of characters ("3", "8", "small") ).Īnd by the way, R assumes that 3 is the same class as 3.0 - numeric (i.e., with a decimal point). If you want to mix numbers and strings or numbers and TRUE/FALSE types, you need a list. (See the screen shot, below.) If you've got a vector with lots of values so the printout runs across multiple lines, each line will start with a number in brackets, telling you which vector item number that particular line is starting with. If you've got a vector with lots of values so the printout runs across multiple lines, each line will start with a number in brackets, telling you which vector item number that particular line is starting with. That's telling you that your screen printout is starting at vector item number one. When you access the value of a variable that's got just one value, such as 73 or "Learn more about R at ," you'll also see this in your console before the value:
The best way for a beginner to deal with this is to use the preferred assignment operator Ī single number or character string is also a vector - a vector of 1. When can you use it and when can you not? To add to the potential confusion, the equals sign actually can be used as an assignment operator in R - but not all the time.