Resources
Answers
Examples
Sign in
Get Started
What do you want to save?
Add Code snippet
New code examples in category R
Tucker Nelson
2021-11-20 10:49:21
r while loop
# Basic syntax: while (condition_is_true) { code to be repeated } # Example usage: i = 1 while (i < 5) { # True while i is less than 5 print(i) i = i + 1 # Increment i each iteration } # Returns: [1] 1 [1] 2 [1] 3 [1] 4
Add solution
Parzival
2021-11-19 02:26:14
remove column from matrix r
# Remove third column - by column number MyMatrix <- MyMatrix[,-3] # Remove third and fifth columns - by feeding the matrix a boolean vector MyMatrix <- MyMatrix[,c(TRUE,TRUE,FALSE,TRUE,FALSE,TRUE)]
Add solution
Daniel V
2021-11-19 02:16:18
get plot title over two lines R
x <- rnorm(3) y <- rnorm(3) plot(x, y, main=paste("X:",1," ","Y:", 2," ","\nZ:",3)) # \n in main= paste() environment produces new line in plot titles
Add solution
Mowwwalker
2021-11-19 01:39:25
R empty datafrane
df <-- data.frame()
Add solution
Raph
2021-11-18 14:23:19
r replace na with 0
d[is.na(d)] <- 0
Add solution
Seems
2021-11-18 02:33:13
how to filter a vector by location in r
vec <- c(11,22,33,44,55,66,77,88) indexs <- c(1,8,5) vec[indexs] # will return: [1] 11 88 55
Add solution
RogueModron
2021-11-17 10:25:35
write to csv in r
df <- data.frame(name = c("Jon", "Bill", "Maria"), age = c(23, 41, 32)) write.csv(df,"C:\\Users\\Ron\\Desktop\\MyData.csv", row.names = FALSE)
Add solution
Mario Trucco
2021-11-16 12:38:11
how to throw an error in R
x <- ifelse(x < 0 | x > 1, NA, x ) if( any(is.na(x)) ) warning('x not between 0 and 1') log(x / (1 - x) )
Add solution
Belphegor
2021-11-15 17:19:13
r clean environment
rm(list = ls())
Add solution
Ospalh
2021-11-14 18:26:21
r append to vector
append(x, values, after = length(x))
Add solution
‹
1
2
3
4
5
6
7
8
9
10
...
26
27
›
Best helpers
daily
weekly
monthly
for 3 months
Aralee
+5
Tzetachi
+5
Donald Ellis
+5
Jiang Joanna
+5
AMR
+5
Rondoh
+5
show more
This website uses cookies to make IQCode work for you. By using this site, you agree to our
cookie policy
Welcome Back!
Sign up to unlock all of IQCode features:
Test your skills and track progress
Engage in comprehensive interactive courses
Commit to daily skill-enhancing challenges
Solve practical, real-world issues
Share your insights and learnings
Sign in
E-mail
Password
Recover lost password
Log in
Or log in with
Not registered?
Sign up takes less than a minute
Create a Free Account
Sign up to unlock all of IQCode features:
Test your skills and track progress
Engage in comprehensive interactive courses
Commit to daily skill-enhancing challenges
Solve practical, real-world issues
Share your insights and learnings
Sign up
Email
Password
Sign up for free
Or sign up with
By signing up, you agree to the
Terms and Conditions
and
Privacy Policy
. You also agree to receive product-related marketing emails from IQCode, which you can unsubscribe from at any time.