R Online Compiler

Run R code online with ggplot2, dplyr, tidyr and data.table installed. See the console output and your plots side by side. Free, no setup.

사전 설치 라이브러리
3 총 실행 (3 이번 달)
퍼가기
출력

Python 코딩 챌린지로 연습하기

이 에디터에서 직접 문제를 풀고, 샘플 테스트 실행 및 제출, AI 코드 리뷰를 받아보세요.

모든 Python 챌린지
쉬움

Rectangle Perimeter

Compute the perimeter of a rectangle from its sides.

배우는 내용 산술반환값
초급Learning-pathVariables
쉬움

Distance Between Points

Compute the straight-line distance between two points.

배우는 내용 피타고라스 정리제곱근
초급함수Learning-path수학
쉬움

세 수의 평균

세 개의 정수를 평균하세요.

배우는 내용 산술나눗셈
초급Learning-pathVariables
쉬움

두 벡터의 내적

두 벡터를 원소별로 곱한 뒤 모두 더합니다. 모든 뉴런의 핵심 연산입니다.

배우는 내용 벡터내적
신경망ai머신 러닝
쉬움

Days in a Month

Return how many days a month has, including leap years.

배우는 내용 달력 규칙도우미 함수
초급조건문함수Learning-path
쉬움

소수 판별

숫자가 소수인지 판별하세요.

배우는 내용 나누어떨어짐 판별반복문 최적화
초급반복문수입문자
쉬움

Celsius to Fahrenheit

Convert a temperature from Celsius to Fahrenheit.

배우는 내용 공식연산자 우선순위
초급Learning-pathVariables
쉬움

Number Triangle

Build a triangle of increasing numbers.

배우는 내용 길어지는 행행을 넘나드는 카운터
초급Learning-path중첩 반복문패턴 출력
쉬움

Min and Max Together

Find the smallest and largest value in one pass.

배우는 내용 한 번의 순회여러 반환값
Arrays초급함수Learning-path
쉬움

Count Pairs With a Sum

Count pairs of positions whose values add up to a target.

배우는 내용 인덱스 쌍중복 세기 피하기
Arrays초급Learning-path중첩 반복문
쉬움

Absolute Value Without abs

Compute an absolute value with a condition.

배우는 내용 부호 바꾸기내장 함수 없이
초급조건문Learning-path
쉬움

Largest of Three

Pick the largest of three numbers without a built-in max.

배우는 내용 비교조건 결합
초급조건문Learning-path

🧩 About This R Online Compiler

The CodeUtility R Online Compiler lets you write and run R code in your browser - no R installation, RStudio or package setup needed. Your code runs with R 4.4 in an isolated sandbox, and the console output appears next to the editor.

Popular packages are already installed: tidyverse (dplyr, tidyr, readr, purrr, stringr), ggplot2, data.table, lubridate, janitor, zoo, patchwork, viridis, scales, and modelling packages such as caret, randomForest, rpart, e1071, glmnet and cluster. Load them with library() as usual.

Charts work out of the box: every plot your code draws (base R or ggplot2) is shown as an image under the output, and you can open it full size or download it as a PNG.

It is a quick way for students to practise R, for analysts to test a snippet before running it on real data, and for teachers to share a working example with a class.

단순한 코드 실행기 그 이상

하나의 실행기에서 다중 파일 편집기, 격리된 실행 터미널, 런타임별 라이브러리, 영구 작업 공간, 공유 및 실시간 협업을 이용하세요.

이 실행기는 어떻게 사용하나요?

런타임을 선택하고 파일을 열거나 만든 다음 코드를 작성하고 실행을 선택하세요. 출력은 터미널에 표시되며, 로그인한 사용자는 작업 공간에 파일을 보관하고 라이브러리를 설치하며 공유를 통해 협업할 수 있습니다.

  1. 버전을 선택하고 현재 파일을 편집하거나 작업 공간의 다른 파일을 여세요.
  2. 코드를 실행하고 요청 시 터미널에 입력한 다음 저장된 실행 기록을 확인하세요.
  3. 작업에 둘 이상의 코드 조각이 필요하면 라이브러리, 작업 공간 도구, 공유 및 채팅을 사용하세요.

💡 R Basics Guide for Beginners

1. Variables and Assignment

R uses <- to assign a value (= works too). Names are case-sensitive.

name <- "Alice"
age <- 30
is_student <- FALSE
cat(name, "is", age, "years old\n")

2. Vectors

A vector holds values of one type. Most operations work on the whole vector at once.

scores <- c(72, 88, 95, 64)
mean(scores)        # 79.75
scores * 2          # every value doubled
scores[scores > 70] # 72 88 95
length(scores)

3. Conditionals

Use if / else for one value and ifelse() for a whole vector.

x <- 7
if (x %% 2 == 0) {
  print("even")
} else {
  print("odd")
}

ifelse(scores >= 70, "pass", "fail")

4. Loops

for walks over a vector; while repeats while a condition holds.

for (i in 1:3) {
  cat("Step", i, "\n")
}

n <- 1
while (n < 100) n <- n * 2
print(n)  # 128

5. Functions

Functions are values; the last expression is returned. Arguments can have defaults.

area <- function(width, height = width) {
  width * height
}
area(3, 4)  # 12
area(5)     # 25

6. Lists

A list can hold values of different types, with names.

person <- list(name = "Bao", age = 21, langs = c("R", "SQL"))
person$name
person[["langs"]][2]  # "SQL"
str(person)

7. Data Frames

A data frame is a table: each column is a vector of the same length.

df <- data.frame(
  city = c("Hanoi", "Paris", "Lima"),
  temp = c(31, 18, 22)
)
df[df$temp > 20, ]
summary(df$temp)

8. Apply Functions

sapply() and lapply() run a function on every element, without writing a loop.

words <- c("apple", "kiwi", "banana")
sapply(words, nchar)
lapply(1:3, function(n) n^2)

9. dplyr Pipelines

The pipe (|> or %>%) passes a result to the next step.

library(dplyr)
mtcars |>
  group_by(cyl) |>
  summarise(avg_mpg = mean(mpg), cars = n()) |>
  arrange(desc(avg_mpg))

10. Plots with ggplot2

Map columns to axes and colours, then add layers. The chart appears under the output.

library(ggplot2)
ggplot(mtcars, aes(wt, mpg, color = factor(cyl))) +
  geom_point(size = 3) +
  labs(title = "Weight vs. fuel use", color = "Cylinders")

11. Strings

paste() joins text, sprintf() formats it, and stringr has friendly helpers.

paste("Hello", "R", sep = ", ")
sprintf("%.1f%% done", 42.567)
toupper("data")
library(stringr)
str_detect(c("cat", "dog"), "a")

12. Handling Errors

tryCatch() runs code and handles an error or a warning instead of stopping.

result <- tryCatch(
  log(-1),
  warning = function(w) {
    message("Warning: ", conditionMessage(w))
    NA
  }
)
print(result)