Tenta 2018-03-28
1. Datastrukturer och beräkningar
och avrunda till 4 decimaler, där x = 1.789 och där e är Eulers tal.
x <- 1.789
y <- (sin^(x)/x) + (exp(x)-exp(-x))/(exp(x)+exp(-x))
y <- arund(y, 4)
dim_vect<- c(4,5,2)my_array <- array(data = runif(n = prod(dim_vect)), dim=dim_vect)
str(my_array)
dim(my_array)
library(ggplot2)
librart(dplyr)
data(diamonds)
temp <- filter(diamonds, color == "E"&depth >=65)
temp <- select(temp, color, price,depth)
temp <- mutate(temp, x1=price^2, x2=log(depth))
my_diamonds <-arrange(temp,desc(price)
head(my_diamonds,4)
tail(my_diamonds,4)
Tenta 2018-08-14
x <- 2
y <- exp(x-3)* x^(3-log(x))
y <- arund(y,4)
my_list <- list(1:4)
my_list
my_df<- data.frame(numeric=6:1, boolean = rep(c(TRUE,FALSE), character = letters[1:3]
my_matrix <- matrix(data=1:12, nrow =3, ncol = 4,
dimnames=list(c("x1, x2, x3), c("y1, y2,y3,y4)))
Tenta 2018-06-07
x <- sqrt(2)
exp(1+x)*cos(pi/4)
data(ChickWeigh)
weight_mean <- mean(ChickWeigh$weight)
weight_by_diet <- aggregate(ChickWeigh$Weight, by=list(ChickWeigh$Diet, FUN=mean)
list=(weight_mean=ChickWeigh$weight, weight_by_diet = weight_by_diet[,2]
Tenta 2017-08-14
a <- 5
b <- 2
(factorial(x=1) - b^a)^0.1
data(OrchardSprays)
my_df <- OrchardSprays
dim(my_df)[1]
index <- seq(from=1, to=dim(my_df)[1], by=2)
my_df <- my_df[index,1:2]
head(my_df)
tail(my_df)
my_text <- rep(letters, 1000)
x_vect<-rep(c(1,2,3,2,1), each=3)
A <- matrix(data=x_vect, nrow=5, ncol=3, byrow=TRUE)
rownames(A) <- c("w","a","r", "y","f")
Tenta 2017-06-07
round((1-cos(pi*2.3))^(1-sqrt(7))
data(trees)
data("AirPassengers")
data(iris)
my_list<-list(trees=trees, AirPassengers=AirPassengers, iris=iris)
str(my_list)
my_array<- array(rnorm(5*3*2), mean=14, sd=2), dim=c(5,3,2))
mean(my_array)
sd(my_array)
dim(my_array)
colnames(iris)
my_frame<- iris[iris$Species=="versicolor", c(1,3,5)]
Tenta 2017-03-23
name <- c("Kalle","Jane","Andrej","Lisa","Kim")
analysis <-c(9,19,6,8,11)
sociology <- c(5,13,22,27,13)
sex <- c("Male", "Female", "Male","Female","Female")
sex <- as.factor(sex)
studenter <- data.frame(name,analysis,sociology,sex)
studenter[studenter$analysis >= 10,1]
library(dplyr)
data(ChickWeight)
time_21 <- filter(ChickWeight, Time=="21")
time_21 <- group_by(.data=time_21, Diet)
summarise(time_21,weight = mean(weight))
rename(.data=time_21, W=weight, T=Time, C=Chick, D=Diet)