C call R Using .R file in C T. B. Chen in NCTU 2019/5/29.

Slides:



Advertisements
Similar presentations
Automating Software Module Testing for FAA Certification Usha Santhanam The Boeing Company.
Advertisements

CPSC 441 TUTORIAL – JANUARY 16, 2012 TA: MARYAM ELAHI INTRODUCTION TO C.
Linkage Editors Difference between a linkage editor and a linking loader: Linking loader performs all linking and relocation operations, including automatic.
Unix Continuum of Tools Do something once: use the command line Do something many times: –Use an alias –Use a shell script Do something that is complex.
Functions Definition: Instruction block called by name Good design: Each function should perform one task and do it well Functions are the basic building.
Informationsteknologi Monday, September 10, 2007Computer Systems/Operating Systems - Class 31 Today’s class Review of more C Operating system overview.
CS-502 Fall 2006Processes in Unix, Linux, & Windows 1 Processes in Unix, Linux, and Windows CS502 Operating Systems.
Lab2 TA Notes. Set up for Visual C++ New Workspace Win32 Console Application – This runs from a command line Chose Blank Project Add your.C file Build.
Unix & Windows Processes 1 CS502 Spring 2006 Unix/Windows Processes.
Advanced Programming in the UNIX Environment Hop Lee.
An Introduction to C Programming Geb Thomas. Learning Objectives Learn how to write and compile a C program Learn what C libraries are Understand the.
PRINCIPLES OF OPERATING SYSTEMS Lecture 6: Processes CPSC 457, Spring 2015 May 21, 2015 M. Reza Zakerinasab Department of Computer Science, University.
Python File Handling. In all the programs you have made so far when program is closed all the data is lost, but what if you want to keep the data to use.
C for Java Programmers Tomasz Müldner Copyright:  Addison-Wesley Publishing Company, 2000 Introduction to C Muldner, Chapters 1, 2.
C Basic File Input/Output Manipulation C Programming – File Outline v File handling in C - opening and closing. v Reading from and writing to files.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition Chapter 2: Operating-System Structures T.Yang, 2012 Partially based on the.
CS 590 Programming Environments with UNIX. Computer Lab Account Course Homepage
Introduction to GL Geb Thomas. Example Code int main(int argc, char **argv) { glutInit(&argc, argv); glutInitDisplayMode ( GLUT_SINGLE | GLUT_RGB | GLUT_DEPTH);
ITEC 320 C++ Examples.
Chapter 8 Scope of variables Name reuse. Scope The region of program code where it is legal to reference (use) a variable The scope of a variable depends.
CS-1030 Dr. Mark L. Hornick 1 Java Review Interactive.
Lin Chen 09/06/2011. Global variables const int maxCandidates = 10; // Names of the candidates participating in this state's primary string candidate[maxCandidates];
Java and C++ Transitioning. A simple example public class HelloWorldApp { public static void main(String[] args) { //Display the string. System.out.println("Hello.
C. C ? K & R C – The Kernighan and Richie classic ANCI C -- started 1983 – ANSI X and ISO/IEC 9899:1990 – Standard C, C89, C90 C90 –
C Programming Lecture 12 : File Processing
1/31/20161 Operating Systems Design (CS 423) Elsa L Gunter 2112 SC, UIUC Based on slides by Roy Campbell, Sam King,
July FLTK The Fast Light Toolkit • A C++ graphical user interface toolkit • Can be used under X, Windows, MacOS • Supports OpenGL • Provides: – Interactive.
Computer Graphics -practical- Lecture 6. (visual c++) open gl library To use open GL with VC++ we add these files:- 1)Glut.h C:\program files\ Microsoft.
1 Reading compiler errors ls2.c:1: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘:’ token In file included from /usr/include/stdio.h:75,
Pseudocode FORTRAN (original) INPUT number
Practical Session 3.
Buffer Overflow By Collin Donaldson.
LINKED LISTS.
Chapter 3 General-Purpose Processors: Software
Thread & Processor Scheduling
Precept 14 : Ish dup() & Signal Handling
Chapter 6 CS 3370 – C++ Functions.
A bit of C programming Lecture 3 Uli Raich.
CISC105 – General Computer Science
University of Washington Computer Programming I
How do we tackle the extended requirements?
Agenda Make Utility Command Line Arguments in Unix
Understand argc and argv
CS399 New Beginnings Jonathan Walpole.
Structure of C Programs
FLTK The Fast Light Toolkit
Allegro Basics Game Library.
Processes in Unix, Linux, and Windows
Device Routines and device variables
TCL command in C, a simple example Nguyen Truong – GCS VN Aug 5, 2004
Processes in Unix, Linux, and Windows
Yung-Hsiang Lu Purdue University
File I/O We are used to reading from and writing to the terminal:
When I want to execute the subroutine I just give the command Write()
C Stuff CS 2308.
Processes in Unix, Linux, and Windows
CSE1320 Strings Dr. Sajib Datta
The Designer.
Device Routines and device variables
DNA microarrays. Infinite Mixture Model-Based Clustering of DNA Microarray Data Using openMP.
Jonathan Walpole Computer Science Portland State University
Processes in Unix, Linux, and Windows
Processes in Unix and Windows
Iteration Statement for
Compile and run c files.
Makefile Assignment Create a file called f1.cpp. It should contain the following function: int squareIt ( int x ) { //insert code to calc and return the.
Intro to the Shell with Fork, Exec, Wait
Threads CSE 2431: Introduction to Operating Systems
File I/O We are used to reading from and writing to the terminal:
Presentation transcript:

C call R Using .R file in C T. B. Chen in NCTU 2019/5/29

Why Using “BATCH” file runs R functions. Fast : Without using R’s GUI. Easy : Only including a .R file in C. Combination advantages of R and C. Avoid looping control in R. Text file, I/O in C, could share with R. Easy handling user’s sub-routines. 2019/5/29

Principle R GUI Packages .R File DLL I/O Text File .c File System library User’s library External library 2019/5/29

.R File Simulation a model using R. Codes Y = u + Bx + error, error~N(0,1) Codes u = 10; B=3.5; N=10000; error=rnorm(N); x=rpois(N,10); Y=u+B*x+error Xx=cbind(x,Y) write.csv(Xx, file='d:/XYdata.txt‘,row.names = FALSE) 2019/5/29

.C File Using .R Codes: #include <stdio.h> #include <stdlib.h> FILE *in; void main(){ Expr………. system(“C:/progra~1/R/R-2.3.1/bin/R CMD BATCH D:/RunR/Test.R”); in = fopen(“d:/XYdata.txt”,”r”); fclose(in); } 2019/5/29

.C File Using .R (2) Codes: #include <stdio.h> #include <stdlib.h> FILE *in, *out; void main(int argc, char** argv){ Expr………. out = fopen(“d:/Runr/Ch14.R”,”w”); fprintf(out,” error=rnorm(%d)\n”,N); ……………………… fprintf(out,” write.csv(Xx, file=‘%s', row.names = FALSE)\n”,argv[1]); fclose(out); system(“C:/progra~1/R/R-2.3.1/bin/R CMD BATCH D:/RunR/Ch14.R”); in = fopen(“d:/XYdata.txt”,”r”); fclose(in); } 2019/5/29