Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- {
- "cells": [
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "### R의 Data Type과 Data Class"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 1,
- "metadata": {},
- "outputs": [
- {
- "data": {
- "text/html": [
- "'character'"
- ],
- "text/latex": [
- "'character'"
- ],
- "text/markdown": [
- "'character'"
- ],
- "text/plain": [
- "[1] \"character\""
- ]
- },
- "metadata": {},
- "output_type": "display_data"
- },
- {
- "data": {
- "text/html": [
- "'character'"
- ],
- "text/latex": [
- "'character'"
- ],
- "text/markdown": [
- "'character'"
- ],
- "text/plain": [
- "[1] \"character\""
- ]
- },
- "metadata": {},
- "output_type": "display_data"
- }
- ],
- "source": [
- "#문자열\n",
- "typeof('dataset')\n",
- "class('dataset')"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 2,
- "metadata": {},
- "outputs": [
- {
- "data": {
- "text/html": [
- "'NULL'"
- ],
- "text/latex": [
- "'NULL'"
- ],
- "text/markdown": [
- "'NULL'"
- ],
- "text/plain": [
- "[1] \"NULL\""
- ]
- },
- "metadata": {},
- "output_type": "display_data"
- },
- {
- "data": {
- "text/html": [
- "'NULL'"
- ],
- "text/latex": [
- "'NULL'"
- ],
- "text/markdown": [
- "'NULL'"
- ],
- "text/plain": [
- "[1] \"NULL\""
- ]
- },
- "metadata": {},
- "output_type": "display_data"
- }
- ],
- "source": [
- "#NULL Type\n",
- "typeof(NULL)\n",
- "class(NULL)"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 3,
- "metadata": {},
- "outputs": [
- {
- "data": {
- "text/html": [
- "'integer'"
- ],
- "text/latex": [
- "'integer'"
- ],
- "text/markdown": [
- "'integer'"
- ],
- "text/plain": [
- "[1] \"integer\""
- ]
- },
- "metadata": {},
- "output_type": "display_data"
- },
- {
- "data": {
- "text/html": [
- "'integer'"
- ],
- "text/latex": [
- "'integer'"
- ],
- "text/markdown": [
- "'integer'"
- ],
- "text/plain": [
- "[1] \"integer\""
- ]
- },
- "metadata": {},
- "output_type": "display_data"
- },
- {
- "data": {
- "text/html": [
- "'integer'"
- ],
- "text/latex": [
- "'integer'"
- ],
- "text/markdown": [
- "'integer'"
- ],
- "text/plain": [
- "[1] \"integer\""
- ]
- },
- "metadata": {},
- "output_type": "display_data"
- },
- {
- "data": {
- "text/html": [
- "'integer'"
- ],
- "text/latex": [
- "'integer'"
- ],
- "text/markdown": [
- "'integer'"
- ],
- "text/plain": [
- "[1] \"integer\""
- ]
- },
- "metadata": {},
- "output_type": "display_data"
- }
- ],
- "source": [
- "#Integer\n",
- "typeof(1L)\n",
- "class(1L)\n",
- "y<- 1:10\n",
- "typeof(y)\n",
- "class(y)"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 4,
- "metadata": {},
- "outputs": [
- {
- "data": {
- "text/html": [
- "'double'"
- ],
- "text/latex": [
- "'double'"
- ],
- "text/markdown": [
- "'double'"
- ],
- "text/plain": [
- "[1] \"double\""
- ]
- },
- "metadata": {},
- "output_type": "display_data"
- },
- {
- "data": {
- "text/html": [
- "'numeric'"
- ],
- "text/latex": [
- "'numeric'"
- ],
- "text/markdown": [
- "'numeric'"
- ],
- "text/plain": [
- "[1] \"numeric\""
- ]
- },
- "metadata": {},
- "output_type": "display_data"
- }
- ],
- "source": [
- "#double : 부동소수점, numeric\n",
- "z <- as.numeric(y)\n",
- "typeof(z)\n",
- "class(z)"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 5,
- "metadata": {},
- "outputs": [
- {
- "data": {
- "text/html": [
- "'complex'"
- ],
- "text/latex": [
- "'complex'"
- ],
- "text/markdown": [
- "'complex'"
- ],
- "text/plain": [
- "[1] \"complex\""
- ]
- },
- "metadata": {},
- "output_type": "display_data"
- },
- {
- "data": {
- "text/html": [
- "'complex'"
- ],
- "text/latex": [
- "'complex'"
- ],
- "text/markdown": [
- "'complex'"
- ],
- "text/plain": [
- "[1] \"complex\""
- ]
- },
- "metadata": {},
- "output_type": "display_data"
- }
- ],
- "source": [
- "#복소수\n",
- "typeof(2+3i)\n",
- "class(2+3i)"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 6,
- "metadata": {},
- "outputs": [
- {
- "data": {
- "text/html": [
- "'list'"
- ],
- "text/latex": [
- "'list'"
- ],
- "text/markdown": [
- "'list'"
- ],
- "text/plain": [
- "[1] \"list\""
- ]
- },
- "metadata": {},
- "output_type": "display_data"
- },
- {
- "data": {
- "text/html": [
- "'list'"
- ],
- "text/latex": [
- "'list'"
- ],
- "text/markdown": [
- "'list'"
- ],
- "text/plain": [
- "[1] \"list\""
- ]
- },
- "metadata": {},
- "output_type": "display_data"
- }
- ],
- "source": [
- "#list\n",
- "list1 <- list(name='eunchong', address = 'Iksan', tel ='010-****-3702', ages ='31')\n",
- "typeof(list1)\n",
- "class(list1)"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 7,
- "metadata": {},
- "outputs": [],
- "source": [
- "#closure & function\n",
- "f <- function(n){\n",
- " for (i in 1:n){\n",
- " print(i)\n",
- " }\n",
- "}"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 8,
- "metadata": {},
- "outputs": [
- {
- "data": {
- "text/html": [
- "'closure'"
- ],
- "text/latex": [
- "'closure'"
- ],
- "text/markdown": [
- "'closure'"
- ],
- "text/plain": [
- "[1] \"closure\""
- ]
- },
- "metadata": {},
- "output_type": "display_data"
- },
- {
- "data": {
- "text/html": [
- "'function'"
- ],
- "text/latex": [
- "'function'"
- ],
- "text/markdown": [
- "'function'"
- ],
- "text/plain": [
- "[1] \"function\""
- ]
- },
- "metadata": {},
- "output_type": "display_data"
- }
- ],
- "source": [
- "typeof(f)\n",
- "class(f)"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 9,
- "metadata": {},
- "outputs": [
- {
- "data": {
- "text/html": [
- "'integer'"
- ],
- "text/latex": [
- "'integer'"
- ],
- "text/markdown": [
- "'integer'"
- ],
- "text/plain": [
- "[1] \"integer\""
- ]
- },
- "metadata": {},
- "output_type": "display_data"
- },
- {
- "data": {
- "text/html": [
- "'array'"
- ],
- "text/latex": [
- "'array'"
- ],
- "text/markdown": [
- "'array'"
- ],
- "text/plain": [
- "[1] \"array\""
- ]
- },
- "metadata": {},
- "output_type": "display_data"
- }
- ],
- "source": [
- "#array\n",
- "array1 <- array(c(1:12), dim=c(2,2,3))\n",
- "typeof(array1)\n",
- "class(array1)"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 10,
- "metadata": {},
- "outputs": [
- {
- "data": {
- "text/html": [
- "'list'"
- ],
- "text/latex": [
- "'list'"
- ],
- "text/markdown": [
- "'list'"
- ],
- "text/plain": [
- "[1] \"list\""
- ]
- },
- "metadata": {},
- "output_type": "display_data"
- },
- {
- "data": {
- "text/html": [
- "'data.frame'"
- ],
- "text/latex": [
- "'data.frame'"
- ],
- "text/markdown": [
- "'data.frame'"
- ],
- "text/plain": [
- "[1] \"data.frame\""
- ]
- },
- "metadata": {},
- "output_type": "display_data"
- }
- ],
- "source": [
- "#dataframe\n",
- "df <- data.frame(array1)\n",
- "typeof(df)\n",
- "class(df)"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 11,
- "metadata": {},
- "outputs": [
- {
- "data": {
- "text/html": [
- "'logical'"
- ],
- "text/latex": [
- "'logical'"
- ],
- "text/markdown": [
- "'logical'"
- ],
- "text/plain": [
- "[1] \"logical\""
- ]
- },
- "metadata": {},
- "output_type": "display_data"
- },
- {
- "data": {
- "text/html": [
- "'logical'"
- ],
- "text/latex": [
- "'logical'"
- ],
- "text/markdown": [
- "'logical'"
- ],
- "text/plain": [
- "[1] \"logical\""
- ]
- },
- "metadata": {},
- "output_type": "display_data"
- },
- {
- "data": {
- "text/html": [
- "'logical'"
- ],
- "text/latex": [
- "'logical'"
- ],
- "text/markdown": [
- "'logical'"
- ],
- "text/plain": [
- "[1] \"logical\""
- ]
- },
- "metadata": {},
- "output_type": "display_data"
- },
- {
- "data": {
- "text/html": [
- "'logical'"
- ],
- "text/latex": [
- "'logical'"
- ],
- "text/markdown": [
- "'logical'"
- ],
- "text/plain": [
- "[1] \"logical\""
- ]
- },
- "metadata": {},
- "output_type": "display_data"
- }
- ],
- "source": [
- "#logical\n",
- "typeof(NA)\n",
- "class(NA)\n",
- "typeof(TRUE)\n",
- "class(TRUE)"
- ]
- }
- ],
- "metadata": {
- "kernelspec": {
- "display_name": "R",
- "language": "R",
- "name": "ir"
- },
- "language_info": {
- "codemirror_mode": "r",
- "file_extension": ".r",
- "mimetype": "text/x-r-source",
- "name": "R",
- "pygments_lexer": "r",
- "version": "3.6.0"
- }
- },
- "nbformat": 4,
- "nbformat_minor": 2
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement