a <- 12 + 6
a
## [1] 18
b<- a + 45
b
## [1] 63
c<- b/a
c
## [1] 3.5
d<- b*c
d
## [1] 220.5
em<- c(1,2,3,4)
em
## [1] 1 2 3 4
lt<- c("ahmet","mehmet","mustafa")
lt
## [1] "ahmet" "mehmet" "mustafa"
myvec<-c(birici<-em,ikinci<-lt)
myvec
## [1] "1" "2" "3" "4" "ahmet" "mehmet" "mustafa"
library(wooldridge)
data(intdef)
head(intdef)
## year i3 inf rec out def i3_1 inf_1 def_1 ci3 cinf
## 1 1948 1.04 8.1 16.2 11.6 -4.6000004 NA NA NA NA NA
## 2 1949 1.10 -1.2 14.5 14.3 -0.1999998 1.04 8.1 -4.6000004 0.06000006 -9.3
## 3 1950 1.22 1.3 14.4 15.6 1.2000008 1.10 -1.2 -0.1999998 0.12000000 2.5
## 4 1951 1.55 7.9 16.1 14.2 -1.9000006 1.22 1.3 1.2000008 0.32999992 6.6
## 5 1952 1.77 1.9 19.0 19.4 0.3999996 1.55 7.9 -1.9000006 0.22000003 -6.0
## 6 1953 1.93 0.8 18.7 20.4 1.6999989 1.77 1.9 0.3999996 0.15999997 -1.1
## cdef y77
## 1 NA 0
## 2 4.400001 0
## 3 1.400001 0
## 4 -3.100001 0
## 5 2.300000 0
## 6 1.299999 0
tail(intdef)
## year i3 inf rec out def i3_1 inf_1 def_1 ci3
## 51 1998 4.81 1.6 20.0 19.2 -0.7999992 5.07 2.3 0.3000011 -0.2600002
## 52 1999 4.66 2.2 20.0 18.6 -1.3999996 4.81 1.6 -0.7999992 -0.1500001
## 53 2000 5.85 3.4 20.9 18.4 -2.5000000 4.66 2.2 -1.3999996 1.1900001
## 54 2001 3.45 2.8 19.8 18.6 -1.1999989 5.85 3.4 -2.5000000 -2.3999999
## 55 2002 1.62 1.6 17.9 19.4 1.5000000 3.45 2.8 -1.1999989 -1.8300000
## 56 2003 1.02 2.3 16.5 19.9 3.3999996 1.62 1.6 1.5000000 -0.6000000
## cinf cdef y77
## 51 -0.6999999 -1.1000004 1
## 52 0.6000000 -0.6000004 1
## 53 1.2000000 -1.1000004 1
## 54 -0.6000001 1.3000011 1
## 55 -1.1999999 2.6999989 1
## 56 0.6999999 1.8999996 1
?intdef
## starting httpd help server ... done
plot(inf~year, data = intdef)

plot( intdef$inf ~ intdef$year)

attach(intdef)
plot(inf ~ year)

detach(intdef)
ilkmodel<- lm(intdef$i3 ~ intdef$inf)
summary(ilkmodel)
##
## Call:
## lm(formula = intdef$i3 ~ intdef$inf)
##
## Residuals:
## Min 1Q Median 3Q Max
## -6.5689 -1.0385 0.0678 0.8962 5.0119
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 2.42032 0.46328 5.224 2.88e-06 ***
## intdef$inf 0.64056 0.09425 6.797 8.81e-09 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 2.125 on 54 degrees of freedom
## Multiple R-squared: 0.461, Adjusted R-squared: 0.4511
## F-statistic: 46.19 on 1 and 54 DF, p-value: 8.812e-09
matris1 <- matrix(c(1,2,3,4,5,6), nrow=2 , ncol=3)
matris1[1,]
## [1] 1 3 5
matris1[,2]
## [1] 3 4
matris1[1,, drop = FALSE]
## [,1] [,2] [,3]
## [1,] 1 3 5
rownames(matris1) <- c("a","b")
matris1
## [,1] [,2] [,3]
## a 1 3 5
## b 2 4 6
colnames(matris1) <- c("c","d","e")
matris1
## c d e
## a 1 3 5
## b 2 4 6