Lapply, apply,sapply, vapply,mapply funksiyalaridan foydalanish. Darsda dasturni o’rganishda bajarilgan ishlarni topshiring


Download 57.01 Kb.
Sana30.11.2020
Hajmi57.01 Kb.
#156358
Bog'liq
DUVP7


O‘ZBEKISTON RESPUBLIKASI AXBOROT TEXNOLOGIYALARI VA KOMMUNIKATSIYALARINI RIVOJLANTIRISH VAZIRLIGI

MUHAMMAD AL-XORAZMIY NOMIDAGI

TOSHKENT AXBOROT TEXNOLOGIYALARI UNIVERSITETI

Dasturlash usullari va paradigmalar



fanidan
Laboratoriya
TOPSHIRIQ № 7

Bajardi: DIF


317-18_guruh
_______Pirimqulova Zilola Avaz qizi______

talabaning F.I.Sh.


Qabul qildi: Mirzayeva Nilufar


Toshkent 2020

R dasturlash tilida Vektorlar, Matritsalar bilan ishlash:

lapply(), apply(),sapply(), vapply(),mapply() funksiyalaridan foydalanish. Darsda dasturni o’rganishda bajarilgan ishlarni topshiring.


T/R

R dasturlash tilida namuna

Natija

1

cartoons <- c("KUNGFU PANDA",

"SHAHZODA VA BO'RI",

"ETIK KIYGAN MUSHUK",

"MOANA")


cartoons_lower <-lapply(cartoons, tolower)

str(cartoons_lower)






2

m1 <- matrix(C<-(1:10),nrow=5, ncol=6)

m1

sum_columns <- apply(m1, 2, sum)



sum_rows <- apply(m1, 1, sum)

sum_columns



sum_rows




3

mylist <- list(c(1,2,3,4),c(10,20,30,40),c(5,5,5,5))

sapply(mylist,mean)






4

statef <- c("tas", "sa", "qld", "nsw", "nsw", "nt", "wa", "wa", "qld", "vic", "nsw", "vic", "qld", "qld", "sa", "tas", "sa", "nt", "wa", "vic", "qld", "nsw", "nsw", "wa", "sa", "act", "nsw", "vic", "vic", "act")

incomes <- c(60, 49, 40, 61, 64, 60, 59, 54, 62, 69, 70, 42, 56, 61, 61, 61, 58, 51, 48, 65, 49, 49, 41, 48, 52, 46, 59, 46, 58, 43)


(incmeans <- tapply(incomes, statef, mean))




5

mapply(rep, 1:4, 4:1)
mapply(rep, times = 1:4, x = 4:1)
mapply(rep, times = 1:4, MoreArgs = list(x = 42))
mapply(function(x, y) seq_len(x) + y,

c(a = 1, b = 2, c = 3),

c(A = 10, B = 0, C = -10))
word <- function(C, k) paste(rep.int(C, k), collapse = "")

utils::str(mapply(word, LETTERS[1:6], 6:1, SIMPLIFY = FALSE))






Download 57.01 Kb.

Do'stlaringiz bilan baham:




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling