Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #Creare data.frame noi
- Female <- data.frame("V1"=c(40,42,50), "V2"=c(0,2,3))
- Male <- data.frame("V1"=c(60,40), "V2"=c(3,2))
- People <- rbind(Female,Male)
- #Import csv Excercitiul 2
- setwd("d:\\MASTER\\Introducere in R\\R\\")
- hsdem <- read.csv("hsdem.csv")
- hstest <- read.csv("hstest.csv")
- hs2 <- merge(hsdem,hstest)
- #ex 3
- note <- data.frame("Sem 1"=c(8.75,7.35,7.75,9.35,9.75),"Sem 2"=c(9.25,8.35,8.25,9.45,10))
- grades <- stack(note)
- gradesunstacked <- unstack(grades)
- #ex 4
- buildings <- data.frame(location=c(1, 2, 3), name=c("building1", "building2", "building3"))
- data <- data.frame(survey=c(1,1,1,2,2,2), location=c(1,2,3,2,3,1), efficiency=c(51,64,70,71,80,58))
- buildingStats <- merge(buildings,data, by.x = "location")
- #ex 5
- buildings <- data.frame(location=c(1, 2, 3), name=c("building1", "building2", "building3"))
- data <- data.frame(survey=c(1,1,1,2,2,2), LocationID=c(1,2,3,2,3,1),
- efficiency=c(51,64,70,71,80,58))
- buildingStats <- merge(buildings, data, by.x = "location", by.y ="LocationID")
- # ex 6
- # scoatem argumentul by.x by.y pentru ca este inutile
- # merge(buildings, data)
- #ex 7
- buildingStates <- merge(buildings, data, by.x="location",all=TRUE)
- #ex 8
- buildingStates <- merge(buildings, data, by="location",all.x=TRUE)
- #ex 10
- buildings <- data.frame(location=c(1, 2, 3), name=c("building1", "building2", "building3"))
- buildings2 <- data.frame(location=c(5, 4, 6), name=c("building5", "building4", "building6"))
- buildingStates <- merge(buildings,buildings2, all=TRUE)
- # ex 11
- world95 <- read.csv("World95.csv")
- #
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement