To run a command in R, you simply need to type the command into the R console and press Enter. Here are some examples:
1. Print the text "Hello, world!":
print("Hello, world!")
Output:
[1] "Hello, world!"
2. Create a variable x and assign it the value 5:
x <- 5
3. Calculate the sum of two numbers, 3 and 4:
sum <- 3 + 4
print(sum)
Output:
[1] 7
4. Generate a sequence of numbers from 1 to 10:
numbers <- 1:10
print(numbers)
Output:
[1] 1 2 3 4 5 6 7 8 9 10
5. Create a plot of a sine wave:
x <- seq(0, 2 * pi, length.out = 100)
y <- sin(x)
plot(x, y)
This will create a plot of a sine wave.