Binning NMR data in R - r

I've imported NMR spectra on R as .csv file ( first column represent the ppm values the others, signal intensity for various spectra) and I would like to bin the data, let's say, make every 5 points one. Any suggestions?
Cheers,
Marcelo

Marcelo, you can look at ChemoSpec on GitHub here: https://github.com/bryanhanson/ChemoSpec
The function binBuck will do what you ask. There is a fairly complete vignette available once you have the package installed.
To use ChemoSpec, you may have to import your data set differently than you apparently currently have it, or if you have the skills you can modify what you have now. Again, the vignette explains how ChemoSpec stores the data.
Let me know if you need further assistance. Bryan

I know it's an old question, but it can be useful for other users.
You can use "prospectr" package in R through function "binning". You can set "bin" as your final spectral size or "bin.size" for as ratio.

Related

How to use weight with the package "crsosstable" for R

The crosstable package give me exactly what I need to do some exploratory work in a data set composed of answers to a survey. But I need to weight the crosstabulation to get a representative results of the population I'm studying. Any ideas how I could use weights with this package?
So far I have used the "survey" package to do that, but it's lacking presentation tool to get publication ready tables.
Thanks.
I'm the dev of the crosstable package and it is unfortunately not supporting weights yet.
I would love to implement this as a feature one day, so you should definitely open a Feature Request on GitHub.
As I've never had to do a weighted description myself, please add a simplified version of your use case so that I can make something useful to everyone.

How to load a xls or csv data file to work with the rugarch and rmgarch packages in R

I am new to R and have just started to use it. I am currently experimenting with the quantmod, rugarch and rmgarch packages.
In particular, I'm implementing the last package to make a multivariate portfolio analysis for the case of the european markets. In this sense, I need to download the 3-month german treasury bills, in order to use them as risk free rate. However, as far as I known, I canĀ“t download the the mentioned data serie from Yahoo, Google or FDRA databases, so I have already downloaded them from investing.com and I want to load them in R.
The fact here is, my data is different from the ones downloaded by the getsymbols () function of yahoo, because in this case I only have 2 columns, the date column and the closing price column. To sump up, the question arises here is, is there any way to load this type of data in R for rmgarch purposes??
thanks in advance
Not sure if this is the issue, but this is how you might go about getting the data from a csv file.
data <- read.csv(file="file/path/data.csv")
head(data) # Take a look at your data
# Do this if you want the data only replacing ColumnName with the proper name
data_only <- data$ColumnName
It looks like the input data for rugarch needs to be an xts vector. So, you might want to take a look at this. You might also want to take a look at ?read.csv.

How to see which data is used in an example of a package

I am using the library(eventstudies)(Event Studies Package). In the sample they use:
(data(StockPriceReturns))
(data(SplitDates))
(head(SplitDates))
However I do not know how to set up my own dataset to use the package. My quesiton is:
How to look into the StockPriceReturns data?
I appreciate your answer!
I think you want to read a data set into a data frame or table.
I'm not familiar with that package, so I'm not sure about required format. If the data set you read in matches the schema of StockPriceReturns, I'm sure R will process it just fine. This PDF appears to explain it well.

R Raster writeRaster doesn't overwrite

Identifying a potential bug here. When calling writeRaster overwrite=TRUE, the new raster values remain unchanged. I originally wrote the wrong raster object, then corrected the code, and wrote a new raster to the same file name. The values in the attribute table of the written file are the same as the original, even though the raster object I am writing has the correct attributes when viewed in R.
Workaround was to give the new raster a different name (or manually delete the old).
R 3.0.0, Windows 7 64-b
Apologies to Brian, with whom I share our modeling workstation. This was my post.
Josh O'Brien- Looks like you were right, there was something locking the write-protection. I think ArcCatalog was locking it up.
This tool has performed as expected many times since this incident.
I found the same issue.
I confirm that if you have ArcMap open, the R function overwrite=TRUE doesn't work.
By the way, without any warning message.
Hope this help other R-user in managing raster files.

Convert a Graph to a Data Frame in R

So a while back (6 months+) I saw a blog post where the author took a line graph someone had posted on the internet, fed the image into R, and used a function to convert the image into a data frame.
I've looked everywhere, and I can't seem to find this blog post (even though I'm sure I bookmarked it). So I was wondering if any of you had also read said blog post, or if someone knew of a quick and easy way to convert a line graph to a data frame in R?
Was this it? I searched for "R digitize plot". The package used is "ReadImages". For completeness, the steps listed were (see link):
library(ReadImages) #Load package
mygraph <- read.jpeg('plot.jpg') #Import image
plot(mygraph) # Plot the image
calpoints <- locator(n=4,type='p',pch=4,col='blue',lwd=2) # Calibrate the plot by selecting known coordinates
data <- locator(type='p',pch=1,col='red',lwd=1.2,cex=1.2) # Collect the data points in a dataframe
When you say 'the image as a data frame', do you mean you want to get back to the original data that made the line?
It's not R, but I've used Engauge Digitizer for this sort of thing:
http://digitizer.sourceforge.net/
Also look at the updateusr function in the TeachingDemos package. Once you have the image displayed as in Benjamin's post, you can use the updateusr function with the known points to change the user coordinates so that then the results from the locator function do not need any additional transformation.
As i write this, the digitize package and the ReadImages package are no longer available for R 3.0.2. Engauge Digitizer is a good option but if you still want to do this sort of thing in R, take a loook at http://rscriptsandtips.blogspot.no/
You can also use im2graph to convert graphs to data. It's free and available of Windows and Linux (http://www.im2graph.co.il).

Resources