You are on page 1of 1

C1 <- c(4,3,1,8,3) # create C1 vector

C2 <- c(3,4,1,6,6) # create C2 vector


data <- cbind(C1, C2) # bind the vectors to create a matrix
lab=c("Mon","Tue","Wed","Thu","Fri") # legend labels
fill <- c("red","yellow","green","blue","purple") # bar colors
barplot(data, # plot the data matrix
beside= TRUE, # don't stack the bars
col=fill, # use the colors listed
main="The Barplot", # main title
ylab="Number", # y-axis label
legend=lab, # legend
args.legend = list(x = "topleft") # put the legend top left
)

setwd("~")
f1 <- read.table(file = "f1.txt", sep=",")
fn1 <- f1[-3]
write.table(fn1, "fn1.txt", row.names = FALSE, col.names = FALSE)

fnI <-function(n){

s <- 0
{
num <- (1:n)
den <- (1:n*1:n)
s <- (sum(num)/sum(den))
}

fnI=s
fnI }
fnI(12)

print("Alternatively since the series can be reduced to 3/(2n+1) we can use this")

fnAlternative <-function(n){

z <- 0
{
s <- (3/(2*n+1))
}

fnAlternative=s
fnAlternative }
fnAlternative(12)

You might also like