Advertisement
Guest User

Untitled

a guest
Jun 20th, 2019
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.67 KB | None | 0 0
  1. {
  2. "cells": [
  3. {
  4. "cell_type": "markdown",
  5. "metadata": {},
  6. "source": [
  7. "### R의 Data Type과 Data Class"
  8. ]
  9. },
  10. {
  11. "cell_type": "code",
  12. "execution_count": 1,
  13. "metadata": {},
  14. "outputs": [
  15. {
  16. "data": {
  17. "text/html": [
  18. "'character'"
  19. ],
  20. "text/latex": [
  21. "'character'"
  22. ],
  23. "text/markdown": [
  24. "'character'"
  25. ],
  26. "text/plain": [
  27. "[1] \"character\""
  28. ]
  29. },
  30. "metadata": {},
  31. "output_type": "display_data"
  32. },
  33. {
  34. "data": {
  35. "text/html": [
  36. "'character'"
  37. ],
  38. "text/latex": [
  39. "'character'"
  40. ],
  41. "text/markdown": [
  42. "'character'"
  43. ],
  44. "text/plain": [
  45. "[1] \"character\""
  46. ]
  47. },
  48. "metadata": {},
  49. "output_type": "display_data"
  50. }
  51. ],
  52. "source": [
  53. "#문자열\n",
  54. "typeof('dataset')\n",
  55. "class('dataset')"
  56. ]
  57. },
  58. {
  59. "cell_type": "code",
  60. "execution_count": 2,
  61. "metadata": {},
  62. "outputs": [
  63. {
  64. "data": {
  65. "text/html": [
  66. "'NULL'"
  67. ],
  68. "text/latex": [
  69. "'NULL'"
  70. ],
  71. "text/markdown": [
  72. "'NULL'"
  73. ],
  74. "text/plain": [
  75. "[1] \"NULL\""
  76. ]
  77. },
  78. "metadata": {},
  79. "output_type": "display_data"
  80. },
  81. {
  82. "data": {
  83. "text/html": [
  84. "'NULL'"
  85. ],
  86. "text/latex": [
  87. "'NULL'"
  88. ],
  89. "text/markdown": [
  90. "'NULL'"
  91. ],
  92. "text/plain": [
  93. "[1] \"NULL\""
  94. ]
  95. },
  96. "metadata": {},
  97. "output_type": "display_data"
  98. }
  99. ],
  100. "source": [
  101. "#NULL Type\n",
  102. "typeof(NULL)\n",
  103. "class(NULL)"
  104. ]
  105. },
  106. {
  107. "cell_type": "code",
  108. "execution_count": 3,
  109. "metadata": {},
  110. "outputs": [
  111. {
  112. "data": {
  113. "text/html": [
  114. "'integer'"
  115. ],
  116. "text/latex": [
  117. "'integer'"
  118. ],
  119. "text/markdown": [
  120. "'integer'"
  121. ],
  122. "text/plain": [
  123. "[1] \"integer\""
  124. ]
  125. },
  126. "metadata": {},
  127. "output_type": "display_data"
  128. },
  129. {
  130. "data": {
  131. "text/html": [
  132. "'integer'"
  133. ],
  134. "text/latex": [
  135. "'integer'"
  136. ],
  137. "text/markdown": [
  138. "'integer'"
  139. ],
  140. "text/plain": [
  141. "[1] \"integer\""
  142. ]
  143. },
  144. "metadata": {},
  145. "output_type": "display_data"
  146. },
  147. {
  148. "data": {
  149. "text/html": [
  150. "'integer'"
  151. ],
  152. "text/latex": [
  153. "'integer'"
  154. ],
  155. "text/markdown": [
  156. "'integer'"
  157. ],
  158. "text/plain": [
  159. "[1] \"integer\""
  160. ]
  161. },
  162. "metadata": {},
  163. "output_type": "display_data"
  164. },
  165. {
  166. "data": {
  167. "text/html": [
  168. "'integer'"
  169. ],
  170. "text/latex": [
  171. "'integer'"
  172. ],
  173. "text/markdown": [
  174. "'integer'"
  175. ],
  176. "text/plain": [
  177. "[1] \"integer\""
  178. ]
  179. },
  180. "metadata": {},
  181. "output_type": "display_data"
  182. }
  183. ],
  184. "source": [
  185. "#Integer\n",
  186. "typeof(1L)\n",
  187. "class(1L)\n",
  188. "y<- 1:10\n",
  189. "typeof(y)\n",
  190. "class(y)"
  191. ]
  192. },
  193. {
  194. "cell_type": "code",
  195. "execution_count": 4,
  196. "metadata": {},
  197. "outputs": [
  198. {
  199. "data": {
  200. "text/html": [
  201. "'double'"
  202. ],
  203. "text/latex": [
  204. "'double'"
  205. ],
  206. "text/markdown": [
  207. "'double'"
  208. ],
  209. "text/plain": [
  210. "[1] \"double\""
  211. ]
  212. },
  213. "metadata": {},
  214. "output_type": "display_data"
  215. },
  216. {
  217. "data": {
  218. "text/html": [
  219. "'numeric'"
  220. ],
  221. "text/latex": [
  222. "'numeric'"
  223. ],
  224. "text/markdown": [
  225. "'numeric'"
  226. ],
  227. "text/plain": [
  228. "[1] \"numeric\""
  229. ]
  230. },
  231. "metadata": {},
  232. "output_type": "display_data"
  233. }
  234. ],
  235. "source": [
  236. "#double : 부동소수점, numeric\n",
  237. "z <- as.numeric(y)\n",
  238. "typeof(z)\n",
  239. "class(z)"
  240. ]
  241. },
  242. {
  243. "cell_type": "code",
  244. "execution_count": 5,
  245. "metadata": {},
  246. "outputs": [
  247. {
  248. "data": {
  249. "text/html": [
  250. "'complex'"
  251. ],
  252. "text/latex": [
  253. "'complex'"
  254. ],
  255. "text/markdown": [
  256. "'complex'"
  257. ],
  258. "text/plain": [
  259. "[1] \"complex\""
  260. ]
  261. },
  262. "metadata": {},
  263. "output_type": "display_data"
  264. },
  265. {
  266. "data": {
  267. "text/html": [
  268. "'complex'"
  269. ],
  270. "text/latex": [
  271. "'complex'"
  272. ],
  273. "text/markdown": [
  274. "'complex'"
  275. ],
  276. "text/plain": [
  277. "[1] \"complex\""
  278. ]
  279. },
  280. "metadata": {},
  281. "output_type": "display_data"
  282. }
  283. ],
  284. "source": [
  285. "#복소수\n",
  286. "typeof(2+3i)\n",
  287. "class(2+3i)"
  288. ]
  289. },
  290. {
  291. "cell_type": "code",
  292. "execution_count": 6,
  293. "metadata": {},
  294. "outputs": [
  295. {
  296. "data": {
  297. "text/html": [
  298. "'list'"
  299. ],
  300. "text/latex": [
  301. "'list'"
  302. ],
  303. "text/markdown": [
  304. "'list'"
  305. ],
  306. "text/plain": [
  307. "[1] \"list\""
  308. ]
  309. },
  310. "metadata": {},
  311. "output_type": "display_data"
  312. },
  313. {
  314. "data": {
  315. "text/html": [
  316. "'list'"
  317. ],
  318. "text/latex": [
  319. "'list'"
  320. ],
  321. "text/markdown": [
  322. "'list'"
  323. ],
  324. "text/plain": [
  325. "[1] \"list\""
  326. ]
  327. },
  328. "metadata": {},
  329. "output_type": "display_data"
  330. }
  331. ],
  332. "source": [
  333. "#list\n",
  334. "list1 <- list(name='eunchong', address = 'Iksan', tel ='010-****-3702', ages ='31')\n",
  335. "typeof(list1)\n",
  336. "class(list1)"
  337. ]
  338. },
  339. {
  340. "cell_type": "code",
  341. "execution_count": 7,
  342. "metadata": {},
  343. "outputs": [],
  344. "source": [
  345. "#closure & function\n",
  346. "f <- function(n){\n",
  347. " for (i in 1:n){\n",
  348. " print(i)\n",
  349. " }\n",
  350. "}"
  351. ]
  352. },
  353. {
  354. "cell_type": "code",
  355. "execution_count": 8,
  356. "metadata": {},
  357. "outputs": [
  358. {
  359. "data": {
  360. "text/html": [
  361. "'closure'"
  362. ],
  363. "text/latex": [
  364. "'closure'"
  365. ],
  366. "text/markdown": [
  367. "'closure'"
  368. ],
  369. "text/plain": [
  370. "[1] \"closure\""
  371. ]
  372. },
  373. "metadata": {},
  374. "output_type": "display_data"
  375. },
  376. {
  377. "data": {
  378. "text/html": [
  379. "'function'"
  380. ],
  381. "text/latex": [
  382. "'function'"
  383. ],
  384. "text/markdown": [
  385. "'function'"
  386. ],
  387. "text/plain": [
  388. "[1] \"function\""
  389. ]
  390. },
  391. "metadata": {},
  392. "output_type": "display_data"
  393. }
  394. ],
  395. "source": [
  396. "typeof(f)\n",
  397. "class(f)"
  398. ]
  399. },
  400. {
  401. "cell_type": "code",
  402. "execution_count": 9,
  403. "metadata": {},
  404. "outputs": [
  405. {
  406. "data": {
  407. "text/html": [
  408. "'integer'"
  409. ],
  410. "text/latex": [
  411. "'integer'"
  412. ],
  413. "text/markdown": [
  414. "'integer'"
  415. ],
  416. "text/plain": [
  417. "[1] \"integer\""
  418. ]
  419. },
  420. "metadata": {},
  421. "output_type": "display_data"
  422. },
  423. {
  424. "data": {
  425. "text/html": [
  426. "'array'"
  427. ],
  428. "text/latex": [
  429. "'array'"
  430. ],
  431. "text/markdown": [
  432. "'array'"
  433. ],
  434. "text/plain": [
  435. "[1] \"array\""
  436. ]
  437. },
  438. "metadata": {},
  439. "output_type": "display_data"
  440. }
  441. ],
  442. "source": [
  443. "#array\n",
  444. "array1 <- array(c(1:12), dim=c(2,2,3))\n",
  445. "typeof(array1)\n",
  446. "class(array1)"
  447. ]
  448. },
  449. {
  450. "cell_type": "code",
  451. "execution_count": 10,
  452. "metadata": {},
  453. "outputs": [
  454. {
  455. "data": {
  456. "text/html": [
  457. "'list'"
  458. ],
  459. "text/latex": [
  460. "'list'"
  461. ],
  462. "text/markdown": [
  463. "'list'"
  464. ],
  465. "text/plain": [
  466. "[1] \"list\""
  467. ]
  468. },
  469. "metadata": {},
  470. "output_type": "display_data"
  471. },
  472. {
  473. "data": {
  474. "text/html": [
  475. "'data.frame'"
  476. ],
  477. "text/latex": [
  478. "'data.frame'"
  479. ],
  480. "text/markdown": [
  481. "'data.frame'"
  482. ],
  483. "text/plain": [
  484. "[1] \"data.frame\""
  485. ]
  486. },
  487. "metadata": {},
  488. "output_type": "display_data"
  489. }
  490. ],
  491. "source": [
  492. "#dataframe\n",
  493. "df <- data.frame(array1)\n",
  494. "typeof(df)\n",
  495. "class(df)"
  496. ]
  497. },
  498. {
  499. "cell_type": "code",
  500. "execution_count": 11,
  501. "metadata": {},
  502. "outputs": [
  503. {
  504. "data": {
  505. "text/html": [
  506. "'logical'"
  507. ],
  508. "text/latex": [
  509. "'logical'"
  510. ],
  511. "text/markdown": [
  512. "'logical'"
  513. ],
  514. "text/plain": [
  515. "[1] \"logical\""
  516. ]
  517. },
  518. "metadata": {},
  519. "output_type": "display_data"
  520. },
  521. {
  522. "data": {
  523. "text/html": [
  524. "'logical'"
  525. ],
  526. "text/latex": [
  527. "'logical'"
  528. ],
  529. "text/markdown": [
  530. "'logical'"
  531. ],
  532. "text/plain": [
  533. "[1] \"logical\""
  534. ]
  535. },
  536. "metadata": {},
  537. "output_type": "display_data"
  538. },
  539. {
  540. "data": {
  541. "text/html": [
  542. "'logical'"
  543. ],
  544. "text/latex": [
  545. "'logical'"
  546. ],
  547. "text/markdown": [
  548. "'logical'"
  549. ],
  550. "text/plain": [
  551. "[1] \"logical\""
  552. ]
  553. },
  554. "metadata": {},
  555. "output_type": "display_data"
  556. },
  557. {
  558. "data": {
  559. "text/html": [
  560. "'logical'"
  561. ],
  562. "text/latex": [
  563. "'logical'"
  564. ],
  565. "text/markdown": [
  566. "'logical'"
  567. ],
  568. "text/plain": [
  569. "[1] \"logical\""
  570. ]
  571. },
  572. "metadata": {},
  573. "output_type": "display_data"
  574. }
  575. ],
  576. "source": [
  577. "#logical\n",
  578. "typeof(NA)\n",
  579. "class(NA)\n",
  580. "typeof(TRUE)\n",
  581. "class(TRUE)"
  582. ]
  583. }
  584. ],
  585. "metadata": {
  586. "kernelspec": {
  587. "display_name": "R",
  588. "language": "R",
  589. "name": "ir"
  590. },
  591. "language_info": {
  592. "codemirror_mode": "r",
  593. "file_extension": ".r",
  594. "mimetype": "text/x-r-source",
  595. "name": "R",
  596. "pygments_lexer": "r",
  597. "version": "3.6.0"
  598. }
  599. },
  600. "nbformat": 4,
  601. "nbformat_minor": 2
  602. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement