Is it possible to convert a file from .mp3 to .wav in R in order to be able to play the song with R?
Yes (probably). Here's an example:
Converting MP3 to WAV is pretty straightforward:
library(tuneR)
r <- readMP3("04 Trip to Paris.mp3") ## MP3 file in working directory
writeWave(r,"tmp.wav",extensible=FALSE)
(to install tuneR on Linux, see here).
Playback is harder and platform-dependent. tuneR::play() tries to use an external player.
On Windows it tries to guess:
If under Windows and no
player is given, “mplay32.exe” or “wmplayer.exe” (if the
former does not exists as under Windows 7) will be chosen as
the default.
On MacOS, specifying "open" probably works.
On Linux, specifying "play" probably works if you have the sox package installed (sudo apt-get install sox).
So on my MacOS system
tuneR::play("tmp.wav","open")
works.
An alternative that does not use external resources is audio::play().
library(audio)
w <- load.wave("tmp.wav")
play(load.wave("tmp.wav"))
It works on MacOS. I don't know if it works on Windows. It does not work on my Linux system; audio doesn't even install unless you sudo apt-get install portaudio19-dev first, and works poorly even once installed.
(When I say "Linux" here I mean the only system I've tested, Ubuntu 14.04. The sudo apt-get install ... incantations I've listed are likely to work on other reasonably recent Debian-based systems, but ... ???)
Related
I'm noticing an issue where the pdftools package in R seems to be performing differently when run locally on my Windows 7 machine versus when I run it on a shared Ubuntu server via ssh.
My code:
download.file("http://www.nber.org/lbid/docs/LinkCO95Guide.pdf",
"1995codebook.pdf",
mode = "wb",
method = "libcurl")
codebook <- pdf_text("1995codebook.pdf")
On my local windows 7 machine, the object codebook shows up as "Large character (258 elements, 710.2 Kb)", whereas on the Ubuntu server it shows up as "Large character (258 elements, 701.9 Kb)".
As you might imagine, this is causing problems for me downstream where code that works on my local machine is not producing the same results on the Ubuntu server. Looking at the text contained in codebook the first difference I notice right away is that where the version produced on Windows has "\r\n" the version produced on Ubuntu only has "\n" instead (I rely on "\r\n" downstream).
Why would that character series be different? Might it have something to do with encoding? Any help appreciated on what's causing this and how I can get the same results on both machines.
One last thing to mention: I had to install the poppler library to my home directory on the Ubuntu server (don't have sudo access) in order to get pdftools to install:
apt-get source poppler
cd poppler-0.24.5
./configure --prefix=$HOME/myapps
make
make install
export PKG_CONFIG_PATH=$HOME/myapps/lib/pkgconfig
After having done so, install.packages("pdftools") seems to run correctly. And pdftools loads without issue. So if it's a bad install I'm not sure what has gone wrong.
A few things:
Windows has different line endings, this is extensively documented. This alone accounts for the size difference
Even after the download, you can convert between both conventions. One tool to do so is dos2unix which you can get via apt-get install dos2unix
You are making your life too complicated by building poppler. As the configure script for pdftools says, just install the library via apt-get install libpoppler-cpp-dev
However: most sane programs, and R included, treat \r\n and n identically so your imported data should be the same. If yours does not,
use dos2unix or equivalent tools to convert as needed. In the longer run you want your code to not care.
I downloaded GNAT ADA GPL 2014 and now trying to install on my Mac.
The directions below are the ones I am following, but I do not know where to look to find the file called doinstall. I might still need some help after finding it, but can anyone help me out here?
Navigate to the directory that contains a file called: doinstall
Enter: sudo mkdir /usr/local/gnat
Enter: sudo ./doinstall
Update your path as needed for your shell
You should have downloaded gnat-gpl-2014-x86_64-darwin-bin.tar.gz.
Go to some temporary directory (I use ~/tmp):
cd ~/tmp
Unpack the download, which creates a directory gnat-gpl-2014-x86_64-darwin-bin containing the binary distribution to be installed:
tar zxvf ~/Downloads/gnat-gpl-2014-x86_64-darwin-bin.tar.gz
Enter that directory, which contains (amongst others) doinstall:
cd gnat-gpl-2014-x86_64-darwin-bin
Execute doinstall to enter the installation dialog:
sudo ./doinstall
Remove the unpacked download:
cd ..
rm -rf gnat-gpl-2014-x86_64-darwin-bin
Now you can update PATH as needed for your shell.
What Simon Wright said is correct, but if you're running on Yosemite there's an extra problem: for some obscure reason, Adacore GNAT is broken on Yosemite. You have to make it think it's compiling for Mavericks:
export MACOSX_DEPLOYMENT_TARGET=10.9 # Yosemite workaround
That can go in a few different places, but I put it near the top of the /usr/local/gnat/bin/gps script so it doesn't interfere with the xcodebuild environment.
Also, I found GTKAda to be nearly impossible to install from source; if you download the XNAdaLib-GPL package from http://sourceforge.net/projects/gnuada/ you can install that and get everything you need without having to wade through Adacore's mess. (You may want to use the Adacore version of Glade for GUI design though; for some reason the Sourceforge package's version is localized in French and I'm not sure if it can be switched to English.)
Finally, since this is a bit duct-tape-and-baling-wire, I would recommend not shipping any production mission-critical code with this environment; either roll back to Mavericks or wait for GNAT 2015.
I would like to encrypt my org files(org-mode) or a region of the file in emacs. The option given in the tool does not work (gives me the error apply: Searching for program: no such file or directory, gpg). I guess because I am using emacs on windows and all the search on this topic point towards encrypting the files on UNIX platform. Can you please help me on how encryption can be achieved on windows. Thanks in advance.
I am using ergoemacs for windows downloaded from http://ergoemacs.org/index.html. The version is as follows:
GNU Emacs 24.2.1 (i386-mingw-nt6.1.7601) of 2012-08-29 on MARVIN ErgoEmacs distribution 2.0.0
Install GnuPG onto your Windows machine. Binary versions (i.e. ones that you don't have to compile yourself) are available from http://gpg4win.org/.
Once GnuPG is installed, and assuming you add its binary directory to your Windows %PATH%, Emacs should be able to use it.
solved the problem by installing cygwin (which has GPG installed) and using the same in emacs.
This can be done by giving the cgywin installed directory in the option cygwin-root-directory of the emacs editor
I'm new to R and I decided to put R on a machine I have and see if I can remotely run code that is on my desktop computer.
While searching for "how to do" that, I came across the names "Rserve" and "RStudio". As far as I could tell, RServe is a package (actually, it seems to be the package) which I can use to configure the server, while RStudio is an IDE.
My question is: does RStudio use RServe "under the hood"? And, if it doesn't, then how does RStudio compare to RServe? (I.e., which one is better and why?)
[I figured out that this question could possibly be a duplicate, but I couldn't find any similar question]
Rserve is a client server implemenation written in pure c that starts a server and spawns multiple processes each with it's own R workspace. This is not threads but processes due to R's limitation on multithreading. It uses a QAP packing protocol as it's primary form of transport between the client and the server. You execute commands via the client (PHP, Java, C++) to the server and it returns you REXP objects that are essentially mappings to R's underlying SEXP data objects. Rserve also offers a websockets version that does will can transmit data through websockets but the api is not well documented. It also supports basic authentication through a configuration file.
Rstudio is a C++ and gwt application that provides a web based front end to R. AFAIK it uses json as it's primary transport and supports authentication through pam. Each user has a workspace configured in their home directory. It runs a server very similar but not the same as Rserve to communicate with R using RCPP. It also has it's own plotting driver used to wrap the plot device so that it can pickup the plots to be served to the ui. It has much more functionality such as stepping through your code from the ui and viewing workspace variables.
Functionally they are similar in that they provide a client/server connection to R but IMHO the comparison stops there.
I believe they are separate projects (though I could be wrong). I've never heard of RServe and there does not appear to be any mention of it in the documentation for RStudio. I have used and would recommend RStudio Server. It is relatively easy to set up and super easy to use once it is set up. This is a helpful guide to setting up a server on Amazon EC2:
#Create a user, home directory and set password
sudo useradd rstudio
sudo mkdir /home/rstudio
sudo passwd rstudio
#Enter Password
sudo chmod -R 0777 /home/rstudio
#Update all files from the default state
sudo apt-get update
sudo apt-get upgrade
#Be Able to get R 3.0
sudo add-apt-repository 'deb http://cran.rstudio.com/bin/linux/ubuntu precise/'
#Update files to use CRAN mirror
#Don't worry about error message
sudo apt-get update
#Install latest version of R
#Install without verification
sudo apt-get install r-base
#Install a few background files
sudo apt-get install gdebi-core
sudo apt-get install libapparmor1
#Change to a writeable directory
#Download & Install RStudio Server
cd /tmp
wget http://download2.rstudio.org/rstudio-server-0.97.551-amd64.deb
sudo gdebi rstudio-server-0.97.551-amd64.deb
#Once you’ve installed the above commands, you can now access RStudio through your local browser. Navigate to the Public DNS of your image on port 8787, similar to:
#http://ec2-50-19-18-120.compute-1.amazonaws.com:8787
The earlier answer about 3 years old provide old information, such as here.
Updated correction
RStudio is a firm that provides the open source RStudio IDE for R. They also sell commercial services such as RStudio Server Pro that markets itself with load balancing and related things. Apparently, the successuful open source project has lead the way to markets.
You may also mean Microsoft R Server, which is now called Microsoft Machine Learning Server?
There is also RServer by RStudio.
Anyway how to install both can be found here.
My programming experience is about 1 year of C/C++ experience from high school, but I did my research and wrote a simple program with OpenCL a few months ago. I was able to compile and run this on an Apple computer relatively easily with g++ and the --framework option. Now I'm on my Ubuntu machine and I have no idea how to compile it. The correct drivers have been downloaded along with ATI's Stream SDK (I have an ATI Radeon HD5870). Any help would be appreciated!
Try
locate libOpenCL.so
If it is in one of the standard directories (most likely /usr/lib, or /usr/local/lib) you need to replace "--framework OpenCL" with "-lOpenCL". If g++ cannot find the lib you can tell g++ to look in a specific directory by adding "-L/path/to/library".
I wish I had my Linux to be more helpful... It is probably best if you redownload the ati-stream-sdk, after extracting it, open the Terminal and "cd /path/to/extracted/files"; in that directory execute make && sudo make install
make you probably know this from windows, this compiles, whatever needs to be compiled
&& chains commands together, the following commands will only be executed if the first command succeeded
sudo make install this will put the files in the expected places (sudo executes a command with superuser priviledges, you will have to enter your password)
Hope that helps.
You might be missing the dynamic libraries from the dynamic linker configuration.
Search for where the libraries are. Most likely /usr/lib, or /usr/local/lib.
Make sure the path location is also configured at one of these places:
LD_LIBRARY_PATH - you can set it in you environment shell, like .bashrc
/etc/ld.so.conf - you will need to call ldconfig to update the cache and it requires root access to change the file.
Reason
Aside from #bjoernz, my system can't find the libOpenCL.so file
It's because the correct file directory is missing
After searchig over the internet, I found out that libOpenCL.so file can provided by ocl-icd-opencl-dev package
Solution
You just need to install the package mentioned above by typing into cmd
sudo apt update
sudo apt install ocl-icd-opencl-dev
Therefore, libOpenCL.so can be found under /usr/lib/x86_64-linux-gnu/ folder
My System Information
OS: Ubuntu 16.04 LTS
GPU: NVIDIA GeForce GTX 660
GPU Driver: nvidia-375
OpenCL: 1.2
Reference:
[1] How to install libOpenCL.so on ubuntu
[2] How to set up OpenCL in Linux