- Bağlantıyı al
- X
- E-posta
- Diğer Uygulamalar
- Bağlantıyı al
- X
- E-posta
- Diğer Uygulamalar
R'da her sütunda kaç 0 var ?
Sifir=apply(dataset, 2, function(c) sum(c==0))
R ondalık aşağı yuvarlama nasıl yapılır?
floor(dataset * 100) / 100
R değişkenlerin farkı nasıl alınır ?
apply(dataset, 2,diff)
R üzerinde çalışma alanı hangi dosyada depolanıyor?
Which directory your R session is using as its current working directory using getwd()
List all the objects in your local workspace using ls()
List all the files in your working directory using dir()
R'da seri oluşturmak ?
Ranging from 0 to 10, incremented by 0.5
seq(0, 10, by=0.5)
R'da tesadüfi seri oluşturmak ?
Binsayi<- rnorm(1000)
R'da bazı değişkenleri kullanmamak?
x[-c(2, 10)]
efso 2 ve 10 harici hepsini verir.
R'da fonksiyonlar ?
If you want to see the source code for any function, just type the function name without any arguments or parentheses.
R'da lapply ve sapply ?
The lapply() function takes a list as input, applies a function to each element of the list, then returns a list of the same length as the original one. Since a data frame is really just a list of vectors
cls_list <- lapply(flags, class)
class(cls_list)=list
to apply the class() function to each column of the flags dataset and store the result in a variable called cls_list.
The 'l' in 'lapply' stands for 'list'.
cls_vect <- sapply(flags, class)
class(cls_vect)=character
To get a list containing the sum of each column of flag_colors, call the lapply() function with two arguments. The first argument is the object over which we are looping (i.e. flag_colors) and the second argument is the name of the function we wish to apply to each column (i.e. sum).
Remember that the second argument is just the name of the function with no parentheses, etc.
list
sapply(flag_colors,sum)
vector
sapply(flag_colors, mean)
sapply() always attempts to simplify the result given by lapply()
unique(c(3, 4, 5, 5, 5, 6, 6))
[1] 3 4 5 6
unique_vals <- lapply(flags, unique)
lapply(unique_vals,length)
sapply(unique_vals, length)
R'da vapply ve tapply ?
If we wish to be explicit about the format of the result we expect, we can use
vapply(flags,class, character(1)).
The 'character(1)' argument tells R that we expect the class function to return a character vector of length 1 when applied to EACH column of the flags dataset.
tapply(flags$animate, flags$landmass, mean)
to apply the mean function to the 'animate' variable separately for each of the six landmass groups, thus giving us the proportion of flags containing an animate image WITHIN each landmass group.
R'da random diziler üretmek ?
sample(1:6, 4, replace = TRUE)
5 3 4 3
sample(1:6, 4, replace = TRUE)
1 6 3 5
rnorm(10) will generate 10 random numbers from a standard normal distribution
rnorm(10, mean=100, sd=25)
5 3 4 3
sample(1:6, 4, replace = TRUE)
1 6 3 5
rnorm(10) will generate 10 random numbers from a standard normal distribution
rnorm(10, mean=100, sd=25)
Yorumlar
Yorum Gönder