-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dataframe_List.R
72 lines (36 loc) · 1.49 KB
/
Dataframe_List.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# List ve Dataframe
# --List--
movie <- list("Toy Story", 1995, c("Animation", "Adventure", "Comedy"))
movie
movie[2] #2. deðere ulaþma
movie <- list(name = "Toy Story",
year = 1995,
genre = c("Animation", "Adventure", "Comedy")) #Listenin düzenli olmasý için baþlýklara isim verilebilir.
movie$genre #liste içerisinde tanýmlý yere ulaþma
movie["genre"] #liste içerisinde tanýmlý yere ulaþma
class(movie$name) #class ile belirtilen yerin data tipi öðrenilebilir.
movie[["age"]] <- 5 # "Age" isimli yeni bir yer eklemek.
movie
movie[["age"]] <- NULL #Mevcut yeri liste içerisinden silme
movie
# --DataFrames--
movies <- data.frame(name = c("Toy Story", "Akira", "The Breakfast Club", "The Artist",
"Modern Times", "Fight Club", "City of God", "The Untouchables"),
year = c(1995, 1998, 1985, 2011, 1936, 1999, 2002, 1987),
stringsAsFactors=F)
movies
movies$name
movies[1]
str(movies) #Data frame hakkýnda bilgi alma
movies[1,2] #1-Toy Story, 2-1995
#Head/Tail ile ilk ve son n deðere ulaþýlabilir.
head(movies,2)
movies['length'] <- c(81, 125, 97, 100, 87, 139, 130, 119) #Yeni sütun eklemek
movies
movies <- rbind(movies, c(name="Dr. Strangelove", year=1964, length=94)) #Yeni satýr eklemek.
movies
movies <- movies[-9,] # 9. satýrý silmek
movies
movies[["length"]] <- NULL # "length isimli sütunu silmek
movies
data.frame("student" = c("john", "mary"), "id" = c(1, 2))