Monthly Archives: June 2012

R – reading tabular data files

commandline session

> dfrm <- read.table("first.txt",sep="-")
> print(dfrm
dfrm
> print(dfrm)
    V1      V2
1 Name Jeffrin
2  Age      35
3  Sex    Male
> dfrm <- read.table("first.txt",sep=" ")
> print(dfrm)
            V1
1 Name-Jeffrin
2       Age-35
3     Sex-Male
> dfrm <- read.table("first.txt",sep=".")
> print(dfrm)
            V1
1 Name-Jeffrin
2       Age-35
3     Sex-Male
> class(dfrm$V1)
[1] "factor"
> class(dfrm$V1)
[1] "factor"
> class(dfrm$V2)
[1] "NULL"
> class(dfrm$V3)
[1] "NULL"
>

$ 4.2.20 6 506---> cat first.txt
Name-Jeffrin
Age-35
Sex-Male
$ 4.2.20 7 507--->

R – package installation

Get The Hang

> install.packages(c("Rpad"))
Installing package(s) into ‘/usr/local/lib/R/site-library’
(as ‘lib’ is unspecified)
--- Please select a CRAN mirror for use in this session ---
Loading Tcl/Tk interface ... done
trying URL 'http://ftp.iitm.ac.in/cran/src/contrib/Rpad_1.3.0.tar.gz'
Content type 'application/x-gzip' length 1745840 bytes (1.7 Mb)
opened URL
==================================================
downloaded 1.7 Mb

* installing *source* package ‘Rpad’ ...
** package ‘Rpad’ successfully unpacked and MD5 sums checked
** R
** inst
** preparing package for lazy loading
** help
*** installing help indices
** building package indices
** testing if installed package can be loaded

* DONE (Rpad)

The downloaded source packages are in
	‘/tmp/Rtmp75RiAi/downloaded_packages’
>

R – reading tabular files

commandline session

> test <- read.table("first.txt")
> print(test)
    V1      V2
1 Name Jeffrin
2  Age      35
3  Sex    Male
> version
               _
platform       x86_64-pc-linux-gnu
arch           x86_64
os             linux-gnu
system         x86_64, linux-gnu
status
major          2
minor          15.1
year           2012
month          06
day            22
svn rev        59600
language       R
version.string R version 2.15.1 (2012-06-22)
nickname       Roasted Marshmallows
>
Save workspace image? [y/n/c]: y
$ 4.2.20 2 502---> cat first.txt
Name Jeffrin
Age  35
Sex  Male
$ 4.2.20 3 503--->

R – loading libraries and data related

Get The Hang

> library(ggplot2)
Error in library(ggplot2) : there is no package called ‘ggplot2’
> library(ggplot2)
Loading required package: reshape
Loading required package: plyr

Attaching package: ‘reshape’

The following object(s) are masked from ‘package:plyr’:

    rename, round_any

Loading required package: grid
Loading required package: proto
>

sed – stream editor for filtering and transforming text

commandline session

$ 4.2.20 36 535---> cat tiles.txt
1.
width 2 meters and 15 centimeters
height 1 meters and 50 centimeters

area =  2.15 * 1.50 = 3.225  square meter


2.

width 2 meters and 15 centimeters
height 43 centimeters

area = .9245 square meter


Sum = 4.1495 square meter.


1 tile =  .1350 square meter


approximatley 40 tiles related.

1800 rupees related
$ 4.2.20 37 536---> sed  s/related/connected/g tiles.txt
1.
width 2 meters and 15 centimeters
height 1 meters and 50 centimeters

area =  2.15 * 1.50 = 3.225  square meter


2.

width 2 meters and 15 centimeters
height 43 centimeters

area = .9245 square meter


Sum = 4.1495 square meter.


1 tile =  .1350 square meter


approximatley 40 tiles connected.

1800 rupees connected
$ 4.2.20 38 537--->

coproc . Coprocesses in GNU Bash

commandline session

$ 4.2.20 3 503---> coproc ls
[1] 4620
$ 4.2.20 4 504---> coproc ls
bash: warning: execute_coproc: coproc [4620:COPROC] still exists
[2] 4621
[1]   Done                    coproc COPROC ls
$ 4.2.20 5 505---> coproc top
bash: warning: execute_coproc: coproc [4621:COPROC] still exists
[3] 4622
[2]   Done                    coproc COPROC ls
$ 4.2.20 6 506---> 	top: failed tty get

[3]+  Exit 1                  coproc COPROC top
$ 4.2.20 6 506---> coproc date
[1] 4624
$ 4.2.20 7 507---> coproc arch
bash: warning: execute_coproc: coproc [4624:COPROC] still exists
[2] 4625
[1]   Done                    coproc COPROC date
$ 4.2.20 8 508---> coproc arch
bash: warning: execute_coproc: coproc [4625:COPROC] still exists
[3] 4628
[2]   Done                    coproc COPROC arch
$ 4.2.20 9 509---> fg 1
bash: fg: 1: no such job
[3]+  Done                    coproc COPROC arch
$ 4.2.20 10 510--->

accident in experiments : ls !a and ls ?a

accident in experiments

$ 4.2.20 8 507---> cat .bashrc
#export PS1="[33[0;31m] $ V # ! "
export PS1="$ V # !---> "

shellp()
{
pre=: post=:
printf "$pre%s$postn" "$@"
}

$ 4.2.20 9 508---> shopt -u extglob
accident fixme
$ 4.2.20 10 509---> ls ?a
NetworkSystemAdministration.pdf
$ 4.2.20 26 525---> pwd
/home/jeffrin
$ 4.2.20 27 526---> cd sa
$ 4.2.20 28 527---> pwd
/home/jeffrin/sa
$ 4.2.20 29 528---> ls
NetworkSystemAdministration.pdf
$ 4.2.20 30 529---> ls ?a
ls: cannot access ?a: No such file or directory
$ 4.2.20 31 530---> cd ..
$ 4.2.20 32 531---> pwd
/home/jeffrin
$ 4.2.20 33 532---> ls ?a
NetworkSystemAdministration.pdf
$ 4.2.20 34 533--->

$ 4.2.20 11 510---> ls ?b
bb
$ 4.2.20 12 511---> ls ?c
ls: cannot access ?c: No such file or directory
$ 4.2.20 13 512---> ls ?t
rt
$ 4.2.20 14 513---> ls ?a
NetworkSystemAdministration.pdf
$ 4.2.20 15 514---> shopt -s extglob
$ 4.2.20 16 515---> ls ?a
NetworkSystemAdministration.pdf
accident
$ 4.2.20 17 516---> ls !a
ls apropos "device driver"
ls: cannot access apropos: No such file or directory
ls: cannot access device driver: No such file or directory
$ 4.2.20 18 517---> shopt -u extglob
$ 4.2.20 19 518---> ls !a
ls apropos "device driver"
ls: cannot access apropos: No such file or directory
ls: cannot access device driver: No such file or directory
$ 4.2.20 20 519--->
 ! is a history expansion character in GNU bash