0% found this document useful (0 votes)
2 views4 pages

Practice 1

Uploaded by

Atharv Nadkarni
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views4 pages

Practice 1

Uploaded by

Atharv Nadkarni
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 4

R version 3.6.

3 (2020-02-29) -- "Holding the Windsock"


Copyright (C) 2020 The R Foundation for Statistical Computing
Platform: x86_64-apple-darwin15.6.0 (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.


You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

Natural language support but running in an English locale

R is a collaborative project with many contributors.


Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or


'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

During startup - Warning messages:


1: Setting LC_CTYPE failed, using "C"
2: Setting LC_COLLATE failed, using "C"
3: Setting LC_TIME failed, using "C"
4: Setting LC_MESSAGES failed, using "C"
5: Setting LC_MONETARY failed, using "C"
[R.app GUI 1.70 (7735) x86_64-apple-darwin15.6.0]

WARNING: You're using a non-UTF8 locale, therefore only ASCII characters will work.
Please read R for Mac OS X FAQ (see Help) section 9 and adjust your system
preferences accordingly.
[Workspace restored from /Users/atharvnadkarni/.RData]
[History restored from /Users/atharvnadkarni/.Rapp.history]

> 5+s
Error: object 's' not found
> 5+5
[1] 10
> x <- 1
> peint(x)
Error in peint(x) : could not find function "peint"
> print(x)
[1] 1
> x
[1] 1
> msg <- 'hi jessy'
> msg
[1] "hi jessy"
> x! <- 1:11
Error: unexpected '!' in "x!"
> x <- 1:11
> x
[1] 1 2 3 4 5 6 7 8 9 10 11
> x <- 1:10
> x
[1] 1 2 3 4 5 6 7 8 9 10
> x <- c(0.5, 0.6)
> x
[1] 0.5 0.6
> x <- c(TRUE, FALSE)
> x
[1] TRUE FALSE
> x <- c(TRUE,FALSE)
> X
Error: object 'X' not found
> x
[1] TRUE FALSE
> x <- c(1, 2, TRUE, FAlSE)
Error: object 'FAlSE' not found
> x <- c(1, 2, TRUE, FALSE)
> X
Error: object 'X' not found
> x
[1] 1 2 1 0
> x = c(1, 2, 'JESSY', 'DARSH')
> x
[1] "1" "2" "JESSY" "DARSH"
> x=0:6
> class(x)
[1] "integer"
> x
[1] 0 1 2 3 4 5 6
> as.numeric(x)
[1] 0 1 2 3 4 5 6
> as.logical(x)
[1] FALSE TRUE TRUE TRUE TRUE TRUE TRUE
> x <- -2:4
> x
[1] -2 -1 0 1 2 3 4
> as.logical(x)
[1] TRUE TRUE FALSE TRUE TRUE TRUE TRUE
> m <- matrix(1:6, nrow=2, ncol=3)
> m
[,1] [,2] [,3]
[1,] 1 3 5
[2,] 2 4 6
> x <- matrix(1:9, nrow=3, ncol = 3)
> x
[,1] [,2] [,3]
[1,] 1 4 7
[2,] 2 5 8
[3,] 3 6 9
> x <- matrix(1:9, nrow=9, ncol = 1)
> x
[,1]
[1,] 1
[2,] 2
[3,] 3
[4,] 4
[5,] 5
[6,] 6
[7,] 7
[8,] 8
[9,] 9
> x <- matrix(2, 4, 6, 8, 1, 3, 5, 7, 9, 0, nrow=2, ncol=5)
Error in matrix(2, 4, 6, 8, 1, 3, 5, 7, 9, 0, nrow = 2, ncol = 5) :
unused arguments (8, 1, 3, 5, 7, 9, 0)
> x <- matrix(1:9, 9, 1)
> x
[,1]
[1,] 1
[2,] 2
[3,] 3
[4,] 4
[5,] 5
[6,] 6
[7,] 7
[8,] 8
[9,] 9
> x <- [2, 4, 6, 8, 1, 3, 5, 7, 9, 0]
Error: unexpected '[' in "x <- ["
> x <- 2, 4, 6, 8, 1, 3, 5, 7, 9, 0
Error: unexpected ',' in "x <- 2,"
> x <- vector("list", length = 5)
> x
[[1]]
NULL

[[2]]
NULL

[[3]]
NULL

[[4]]
NULL

[[5]]
NULL

> x <- factor(c("yes", "yes", "no", "yes", "no"))


> x
[1] yes yes no yes no
Levels: no yes
> x <- factor(c("yes", "yes", "no", "yes", "no", "maybe"))
> x
[1] yes yes no yes no maybe
Levels: maybe no yes
> table(x)
x
maybe no yes
1 2 3
> x
[1] yes yes no yes no maybe
Levels: maybe no yes
> unclass(x)
[1] 3 3 2 3 2 1
attr(,"levels")
[1] "maybe" "no" "yes"
> x <- factor(c("yes", "yes", "no", "yes", "no")),
Error: unexpected ',' in "x <- factor(c("yes", "yes", "no", "yes", "no")),"
> x <- factor(c("yes", "yes", "no", "yes", "no"), levels = c("yes", "no"))
> x
[1] yes yes no yes no
Levels: yes no
> x <- factor(c("yes", "yes", "no", "yes", "no"), levels = c("yes", "no"))
>
> unclass(x)
[1] 1 1 2 1 2
attr(,"levels")
[1] "yes" "no"
> def fact(x):
Error: unexpected symbol in "def fact"
> if(n<0):
Error: unexpected ':' in "if(n<0):"
> if(n<0){}
Error: object 'n' not found
> n = as.integer(readline(prompt("Enter a number: "))
+ fact = 1
Error: unexpected symbol in:
"n = as.integer(readline(prompt("Enter a number: "))
fact"
> n = as.integer(readline(prompt("Enter a number: "))
+
+ fact = 1)
Error: unexpected symbol in:
"
fact"
>

You might also like