Werbung / Advertisements

R – Tipps und Tricks

Info

R Packages installieren

Werbung / Advertisements

Falls Packages noch nicht installiert sein sollten, ist einfach folgender Code anzuwenden: 

install.packages("NameOfThePackage") 

Eine andere Möglichkeit ist, die Packages wenn nicht vorhanden automatisch zu installieren. Dies erfordert allerdings ein wenig Programmcode, sollte aber immer gemacht werden.

wants <- c("NameOfThePackage1", "NameOfThePackage2", "NameOfThePackage3", ...) 
has   <- wants %in% rownames(installed.packages()) 
if(any(!has)) install.packages(wants[!has]) 

R Java not found / R Java nicht gefunden 

If Java is not found (no JAVA_HOME / JAVA_PATH) add the following line (note that you add the original path):

Sys.setenv(JAVA_HOME='C:/Program Files (x86)/Java/jre1.8.0_45') 

Problems with R portable library

If libraries not found (portable version of R), install libraries in portable path and add the following code line (check the path to R-Portale!):

.libPaths(c("C:/Temp/R-Portable/App/R-Portable/library", .libPaths()) 

Portable Version of R not running / Batch file not running

Werbung / Advertisements

If portable version not running, start 32 Bit Version of portable version in the batch file (even if the system is 64bit). In a batch file add for example the following line (note that the path has not be the same!):

C:\Temp\R-Portable\App\R-Portable\bin\i386\R.exe (add i386 for Win32 into the path)

R verschiedene Farben bei Plots / R different color plotting

Oftmals will man einen Plot mit verschiedenen Farben zeichnen. Diese händisch und manuell einzutippen ist allerdings zeitaufwändig und oftmals wird die Anzahl der Variablen im vorhinein nicht gewusst. Aber da gibt es eine einfache Alternative. Dazu ist allerdings die Installation des Packages „zoo“ notwendig. Danach übergibt man die an die Variable col (für Color) einen Array aus Regenbogenfarben. Die Anzahl der Farben kann in der Klammer angegeben werden (z.B. Länge des Vektors)

plot(..., col=rainbow(ncol(vektor)), ....)

Blogofant

Betreiber mehrere Webseiten, Autor, Student und vieles mehr!

You may also like...

Werbung / Advertisements