Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I'm at the moment learning R from a fellow student. I have heard that it's possible to download data from Bloomberg and then, for example, calculate the Returns from Prices. Do I have to convert the data into a time series ?
An example would be great.
yes this is possible but you need be able access Bloomberg of course.
The code I'm using to download the data into R is:
start.date=as.Date('2016-01-04')
end.date= as.Date('2017-02-17')
opt = c("periodicitySelection"="DAILY")
blpConnect()
Bloombergdata=bdh(c("DAX Index", INDU Index"),"PX_LAST",start.date,end.date,options=opt,include.non.trading.days = TRUE)
After getting the data I transform this into time series with a function:
f.xts=function(dat.l){
out=as.xts(dat.l[,2],order.by=dat.l[,1])
return(out)}
out=na.locf(do.call("merge",lapply(data,f.xts)))
I hope this will help...
Related
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 days ago.
Improve this question
Download an R software and R studio, write a hardcopy that has the 4probability sampling techniques that does: loads data; simple random sampling with and without replacement,stratified sampling, systematic and cluster sampling. Write a well commented code (R markdown)
I'm new to R so I haven't tried
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
I would like to classify pictures by using R software. I have no knowledge in image processing so it will be great if someone would point me to the right direction. First, how can I turn a picture that I have into a structured dataframe so I'll be able to analyze it? Is there a package for this task? Second, Is there a defined process for picture classification that I can follow?
With this lines you can load images in R and store them in a list.
library(jpeg)
setwd("path/to/folder/with/images/")
pics <- dir()
all_images <- NULL
for(z in pics){
all_images[[z]] <- readJPEG(z, native = T)
}
# check the first image in the list
plot(1:2, type='n')
rasterImage(all_images[[1]],1,1,2,2)
for processing images you can use the imager package.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
In R Studio I have a data set of 10 columns and I am required to add a further column (further variable) which is the average of 2 columns already there.
We have been told to use this formula: Tav = (Tmax+Tmin)/2 to create an extra column for the average of tmax and tmin but it does not work for me.
I attach an image showing my situation:
I have tried to search for a solution on this site and others but cannot seem to find anything that helps my specific situation.
Thanks for any help in advance.
Next time please read these first before posting: https://stackoverflow.com/help/how-to-ask
How to make a great R reproducible example?
Based on your screenshot, I think this is what you're after:
abp$tav <- (abp$tmax+abp$tmin)/2
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I want to pass a data frame to a function as an argument. And then inside the function, I want to work on different combinations of columns for graphical presentation. Basically, I want to do graphical presentation on different data files. I want that, I pass the data file as an argument and then get the graphs. How can I do this in R.
You are not giving us much info but here is a very basic starting point:
library(ggplot2) # if you don't have this library run install.packages('ggplot2')
myAmazingFunction <- function(myDF) {
ggplot(myDF,aes(X,Y))+geom_line()
}
df <-data.frame(X=1:30, Y=runif(30), Z=1.3*runif(30))
myAmazingFunction(df)
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I have data that contains 14 columns of predictors and 1 column of solution variable(y).
I wanted to know if there are any inbuilt functions to normalize and denormalize data in R.
Thank you.
normDataWithin of package {Rmisc} can be used: http://www.inside-r.org/packages/cran/Rmisc/docs/normDataWithin
Else following methods can be used:
(variable-mean)/sd . Following code can be used for a data.frame:
mydata$myNormalizedVar<-(mydata$myvar-mean(mydata$myvar))/sd(myvar)
log (log10), log2, and square root (sqrt)
Normal quantile normalization or normal quantile transformation. Try:
quantNorm = function(x){qnorm(rank(x,ties.method = "average")/(length(x)+1))}
hist(quantNorm(1:10000),100)