Re: [R] How to make LN(x) transformation in R?

2013-09-27 Thread Berend Hasselman

On 28-09-2013, at 02:21, Xiao Fang  wrote:

> Dear R colleagues,
> 
> I am a newbie to R. I can not figure out how to compute Ln(x) value in R.
> 
> My question may be so easy for you but I will really appreciate if you can
> help me. Thanks so much for your time!
> 

Assuming you mean natural logarithm,  use log and read the help page of log.

Berend

> Kathy
> 
>   [[alternative HTML version deleted]]

Please don't post in HTML.
Read the posting  guide.


> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] How to make LN(x) transformation in R?

2013-09-27 Thread Xiao Fang
Dear R colleagues,

I am a newbie to R. I can not figure out how to compute Ln(x) value in R.

My question may be so easy for you but I will really appreciate if you can
help me. Thanks so much for your time!

Kathy

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] makeCluster help needed

2013-09-27 Thread Jeffrey Flint
This is in regards to the SNOW library.

I'm using Windows.  The problem is that makeSOCKcluster hangs in R as well
as the DOS command line.  Below I've shown that it completes the Rscript
until it reaches the line "slaveLoop(master)" , at which point it hangs.

=

In R:

> cl <-
makeSOCKcluster(names=c("localhost","localhost"),manual=T,outfile="jeff.log")
Manually start worker on localhost with
 C:/PROGRA~1/R/R-214~1.2/bin/Rscript.exe "C:/Program
Files/R/R-2.14.2/library/snow/RSOCKnode.R" MASTER=localhost PORT=11590
OUT=jeff.log SNOWLIB=C:/Program Files/R/R-2.14.2/library
[HANGS]


On the DOS Command Line:

C:\Documents and Settings\Jeff>C:/PROGRA~1/R/R-214~1.2/bin/Rscript.exe
"C:/Program Files/R/R-2.14.2/library/snow/RSOCKno
de.R" MASTER=localhost PORT=11590 OUT=jeff.log SNOWLIB=C:/Program
Files/R/R-2.14.2/library
[HANGS]
^C
C:\Documents and Settings\Jeff>type jeff.log
starting worker for localhost:11590




In the file RSOCKnode.R, stalls after last line, after executing
"slaveLoop(master)".




local({
master <- "localhost"
port <- "8765"
snowlib <- Sys.getenv("R_SNOW_LIB")
outfile <- Sys.getenv("R_SNOW_OUTFILE")

args <- commandArgs()
pos <- match("--args", args)
args <- args[-(1 : pos)]
for (a in args) {
pos <- regexpr("=", a)
name <- substr(a, 1, pos - 1)
value <- substr(a,pos + 1, nchar(a))
switch(name,
   MASTER = master <- value,
   PORT = port <- value,
   SNOWLIB = snowlib <- value,
   OUT = outfile <- value,
   RANK = rank <- value,
   TMPWS = tmpWsName <- value)
}
## these should be passed as arguments to makeNWSmaster
Sys.setenv(MASTER = master)
Sys.setenv(PORT = port)
Sys.setenv(RANK = rank)
Sys.setenv(TMPWS = tmpWsName)

if (! (snowlib %in% .libPaths()))
.libPaths(c(snowlib, .libPaths()))
library(methods) ## because Rscript as of R 2.7.0 doesn't load methods
library(nws)
library(snow)

sinkWorkerOutput(outfile)
master <- makeNWSmaster()
sendData(master, "ping")
cat("starting NWS worker\n")
slaveLoop(master)
})

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Plot lines whose angle and length depict vector quantities

2013-09-27 Thread Jim Lemon

On 09/28/2013 04:56 AM, Conor Ryan wrote:

I am trying to plot points on a map for each ship locations (lat/long),
where
each point is a line whose angle (degrees) denotes ships heading and whose
line length denotes it's speed. Unfortunately arrows(); p.arrows (sfsmisc)
and ms.arrows (TeachingDemos) require start and end coordinates but I only
have a single coordinate and an angle to work with. Can you suggest any
other packages or commands that might allow me to plot this? Alternatively,
can anyone suggest a method of making 'angle' a vector quantity when using
the arrows function? Any advice would be much appreciated!


Hi Conor,
Try the vector.field function (plotrix).

Jim

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Memory distribution using foreach

2013-09-27 Thread pakoun
Thank you Simon for your quick response. Now I understand a lot of things,
and how to use them. Well they should offer some lessons my department how
to work with the cluster but unfortunately they didnt and I am trying to
find alone everything. Thanks again for the great advise

Best wishes
Panos



--
View this message in context: 
http://r.789695.n4.nabble.com/Memory-distribution-using-foreach-tp4677133p4677149.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] netCDF to raster and projection to UTM: output NA

2013-09-27 Thread gabriela bucini
Dear R colleagues,

I'm facing a problem with the projection of a netCDF file.
My original netCDF file is in lat/lon coordinates and I want to
project it in UTM.
I use the raster package with the function"raster" to open the file
and then "projectRaster" to change projection (I want to maintain a
similar cell resolution as the input netCDF). I obtain a raster of two
cells with NA values. Even if I change the resolution for the
projected output, I always obtain a raster of NA values.

Can anybody help me figuring out where I'm making a mistake?

Thank you very much for your help!

Gabriela

This is my code:
nc2r <- 
raster("./../Data/BCCA_daily_original/CMIP5/access1-0.1.rcp45/bcca5/Extraction_pr.nc",
varname = "pr", level=1)
# netCDF info
print(nc2r)
# raster info
nc2r
summary(nc2r)
#define the new projection (UTM)
newproj <- "+proj=utm +zone=18 +ellps=WGS84 +datum=WGS84 +units=m +no_defs"
# change the projection maintaining a similar resolution to input image
pr2 <- projectRaster(nc2r, crs=newproj, res=9)
pr2
summary(pr2)


OUTPUTS:

> print(nc2r)
[1] "File 
C:\\Users\\GB\\Dropbox\\Downscaling\\Data\\BCCA_daily_original\\CMIP5\\access1-0.1.rcp45\\bcca5\\Extraction_pr.nc
(NC_FORMAT_CLASSIC):"
[1] ""
[1] " 1 variables (excluding dimension variables):"
[1] "float pr[longitude,latitude,time,projection]   "
[1] "typeConversion_op_ncl: double converted to float"
[1] "_FillValue: 1.0002004088e+20"
[1] "associated_files: baseURL:
http://cmip-pcmdi.llnl.gov/CMIP5/dataLocation gridspecFile:
gridspec_atmos_fx_ACCESS1-0_historical_r0i0p0.nc areacella:
areacella_fx_ACCESS1-0_historical_r0i0p0.nc"
[1] "missing_value: 1.0002004088e+20"
[1] "history: 2012-01-17T12:34:12Z altered by CMOR:
replaced missing value flag (-1.07374e+09) with standard missing value
(1e+20)."
[1] "cell_measures: area: areacella"
[1] "cell_methods: time: mean"
[1] "units: mm/d"
[1] "comment: at surface; includes both liquid and solid
phases from all types of clouds (both large-scale and convective)"
[1] "long_name: Precipitation"
[1] "standard_name: precipitation_flux"
[1] "time: 0.5"
[1] ""
[1] " 4 dimensions:"
[1] "latitude  Size:13"
[1] "valid_max: 52.875"
[1] "long_name: Latitude"
[1] "valid_min: 25.125"
[1] "units: degrees_north"
[1] "axis: Y"
[1] "longitude  Size:10"
[1] "long_name: Longitude"
[1] "axis: X"
[1] "units: degrees_east"
[1] "modulo: 360"
[1] "topology: circular"
[1] "time  Size:54787"
[1] "calendar: standard"
[1] "units: days since 1950-01-01 00:00:00"
[1] "standard_name: time"
[1] "long_name: time"
[1] "axis: T"
[1] "projection  Size:1   *** is unlimited ***"
[1] ""
[1] "15 global attributes:"
[1] "institution: CSIRO (Commonwealth Scientific and
Industrial Research Organisation, Australia), and BOM (Bureau of
Meteorology, Australia)"
[1] "institute_id: CSIRO-BOM"
[1] "model_id: ACCESS1-0"
[1] "frequency: day"
[1] "experiment: historical"
[1] "experiment_id: historical"
[1] "parent_experiment: pre-industrial control"
[1] "parent_experiment_id: piControl"
[1] "parent_experiment_rip: r1i1p1"
[1] "creation_date: Fri Sep 14 14:51:45 PDT 2012"
[1] "references: Daily BC method: modified version of Maurer
EP, Hidalgo HG, Das T, Dettinger MD, Cayan DR, 2010, Hydrol Earth Syst
Sci 14:1125-1138\nCA method: Hidalgo HG, Dettinger MD, Cayan DR, 2008,
California Energy Commission technical report
CEC-500-2007-123\nReference period obs: updated version of Maurer EP,
Wood AW, Adam JC, Lettenmaier DP, Nijssen B, 2002, J Climate
15(22):3237–3251, \nprovided via
http://www.engr.scu.edu/~emaurer/gridded_obs/index_gridded_obs.html";
[1] "contacts: Bridget Thrasher:
brid...@climateanalyticsgroup.org or Ed Maurer: emau...@scu.edu"
[1] "documentation: http://gdo-dcp.ucllnl.org";
[1] "NCO: 4.0.8"
[1] "Projections: access1-0.1.rcp45, "


# raster info

> nc2r
class   : RasterLayer
dimensions  : 13, 10, 130  (nrow, ncol, ncell)
resolution  : 0.125, 0.125  (x, y)
extent  : 286.625, 287.875, 43.875, 45.5  (xmin, xmax, ymin, ymax)
coord. ref. : +proj=longlat +datum=WGS84 +ellps=WGS84 +towgs84=0,0,0
data source : C:\Users\Gabriela
Bucini\Dropbox\Downscaling\Data\BCCA_daily_original\CMIP5\access1-0.1.rcp45\bcca5\Extraction_pr.nc
names   : Precipitation
z-value : 1
zvar: pr
level   : 1


class   : RasterLayer
dimensions  : 13, 10, 130  (nrow, ncol, ncell)
resolution  : 0.125, 0.125  (x, y)
extent  : 286.625, 287.875, 43.875, 45.5  (xmin, xmax, ymin, ymax)
coord. ref. : +proj=longlat +datum=WGS84 +ellps=WGS84 +towgs84=0,0,0
da

Re: [R] Compare species presence and absence between sites

2013-09-27 Thread arun


Elaine,
Try:
set.seed(248)
 mat1<- matrix(sample(0:1,5*100,replace=TRUE),ncol=100,dimnames=list( 
c("Hokkaido","Honshu","Shikoku","Kyushu","Amami")
,paste0("D",sprintf("%03d",1:100))) )
##to change
 dat<- expand.grid(rownames(mat1),rownames(mat1),stringsAsFactors=FALSE)
dat1<- dat[!paste0(dat[,1],dat[,2])%in% paste0(rownames(mat1),rownames(mat1)),]

#same code:
lst1<- lapply(seq_len(nrow(dat1)),function(i) {x<-mat1[unlist(dat1[i,]),]; 
which(different(x[1,],x[2,]))}) #using Rui's function
 names(lst1)<- paste(dat1[,1],dat1[,2],sep="_")
A.K.


From: Elaine Kuo 
To: arun  
Sent: Friday, September 27, 2013 6:17 PM
Subject: Re: [R] Compare species presence and absence between sites



Hello Arun, 

Thanks for the code, but I have problem replacing Island A-D with real names.
Please kindly indicate where to change in the code.
The real names include Hokkaido, Honshu, Shikoku, Kyushu, and Amami.
Thanks again.

Elaine



On Fri, Sep 27, 2013 at 9:31 PM, arun  wrote:

Just to add:
>
>If you wanted the difference of every combination of rows:
>set.seed(248)
> mat1<- 
>matrix(sample(0:1,5*100,replace=TRUE),ncol=100,dimnames=list(LETTERS[1:5],paste0("D",sprintf("%03d",1:100)))
> )
> dat<-expand.grid(LETTERS[1:5],LETTERS[1:5],stringsAsFactors=FALSE)
>dat1<-dat[!paste0(dat[,1],dat[,2]) %in% paste0(LETTERS[1:5],LETTERS[1:5]),]
> lst1<- lapply(seq_len(nrow(dat1)),function(i) {x<-mat1[unlist(dat1[i,]),]; 
>which(different(x[1,],x[2,]))}) #using Rui's function
>names(lst1)<- paste(dat1[,1],dat1[,2],sep="_")
>
>
>A.K.
>
>
>
>
>- Original Message -
>From: Rui Barradas 
>To: Elaine Kuo 
>Cc: "r-help@r-project.org" 
>Sent: Friday, September 27, 2013 7:39 AM
>Subject: Re: [R] Compare species presence and absence between sites
>
>Hello,
>
>Something like this?
>
>
>different <- function(x, y) x == 1 & y == 0
>
>set.seed(7054)
>mat <- matrix(sample(0:1, 500, TRUE), nrow = 5)
>rownames(mat) <- LETTERS[1:5]
>colnames(mat) <- sprintf("D%03d", 1:100)
>
>different(mat["B",], mat["E",])
>
>
>
>Hope this helps,
>
>Rui Barradas
>
>Em 27-09-2013 11:48, Elaine Kuo escreveu:
>> Dear List,
>>
>>
>>
>> I want to compare the presence and absence of bird species based on the
>> sites in a matrix.
>>
>> The matrix has 5 rows for Island A, B, C, D, and E.
>>
>> It has 100 columns for bird species D001-D100.
>>
>> In each cell of the matrix,
>>
>> the presence-absence of bird species will be recorded as 1 or 0.
>>
>> (For example, if species D001 is found on Island D,
>>
>> the matrix cell of species D001 and Island D will be 1.)
>>
>>
>>
>> Now I want to know the different bird species between Island B and E.
>>
>> In other words, I would like to find out bird species present (1) on Island
>> B but absent (0)on island E, and vice versa (absent (0) on Island B but
>> present (1)on island E).
>>
>>
>>
>> Please kindly advise how to code the purpose above.
>>
>> Thank you in advance.
>>
>>
>>
>> Elaine
>>
>>     [[alternative HTML version deleted]]
>>
>> __
>> R-help@r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>>
>
>__
>R-help@r-project.org mailing list
>https://stat.ethz.ch/mailman/listinfo/r-help
>PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>and provide commented, minimal, self-contained, reproducible code.
>
>

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Compare species presence and absence between sites

2013-09-27 Thread Rui Barradas

Hello,

Maybe something like the following.

res <- different(mat["B",], mat["E",])
res[res]


Rui Barradas

Em 27-09-2013 23:11, Elaine Kuo escreveu:

Thanks Rui and Arun.
Both worked well.

One more question, what shall I add for Rui's code if only the comparison
of TRUE (no FALSE) to be shown in the result?

Elaine

code
different <- function(x, y) x == 1 & y == 0

set.seed(7054)
mat <- matrix(sample(0:1, 500, TRUE), nrow = 5)
rownames(mat) <- LETTERS[1:5]
colnames(mat) <- sprintf("D%03d", 1:100)

different(mat["B",], mat["E",])


On Fri, Sep 27, 2013 at 9:31 PM, arun  wrote:


Just to add:

If you wanted the difference of every combination of rows:
set.seed(248)
  mat1<-
matrix(sample(0:1,5*100,replace=TRUE),ncol=100,dimnames=list(LETTERS[1:5],paste0("D",sprintf("%03d",1:100)))
)
  dat<-expand.grid(LETTERS[1:5],LETTERS[1:5],stringsAsFactors=FALSE)
dat1<-dat[!paste0(dat[,1],dat[,2]) %in% paste0(LETTERS[1:5],LETTERS[1:5]),]
  lst1<- lapply(seq_len(nrow(dat1)),function(i)
{x<-mat1[unlist(dat1[i,]),]; which(different(x[1,],x[2,]))}) #using Rui's
function
names(lst1)<- paste(dat1[,1],dat1[,2],sep="_")


A.K.



- Original Message -
From: Rui Barradas 
To: Elaine Kuo 
Cc: "r-help@r-project.org" 
Sent: Friday, September 27, 2013 7:39 AM
Subject: Re: [R] Compare species presence and absence between sites

Hello,

Something like this?


different <- function(x, y) x == 1 & y == 0

set.seed(7054)
mat <- matrix(sample(0:1, 500, TRUE), nrow = 5)
rownames(mat) <- LETTERS[1:5]
colnames(mat) <- sprintf("D%03d", 1:100)

different(mat["B",], mat["E",])



Hope this helps,

Rui Barradas

Em 27-09-2013 11:48, Elaine Kuo escreveu:

Dear List,



I want to compare the presence and absence of bird species based on the
sites in a matrix.

The matrix has 5 rows for Island A, B, C, D, and E.

It has 100 columns for bird species D001-D100.

In each cell of the matrix,

the presence-absence of bird species will be recorded as 1 or 0.

(For example, if species D001 is found on Island D,

the matrix cell of species D001 and Island D will be 1.)



Now I want to know the different bird species between Island B and E.

In other words, I would like to find out bird species present (1) on

Island

B but absent (0)on island E, and vice versa (absent (0) on Island B but
present (1)on island E).



Please kindly advise how to code the purpose above.

Thank you in advance.



Elaine

 [[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide

http://www.R-project.org/posting-guide.html

and provide commented, minimal, self-contained, reproducible code.



__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.






__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] An Apply function question about changing type of variable

2013-09-27 Thread R. Michael Weylandt


On Sep 27, 2013, at 11:27, Vincent Guyader  wrote:

> Hi everyone,
> 
> plese can you look at this few lines :
> 
> data(iris)
> res<-apply(iris,MARGIN=2,is)
> res[1,]
> 
> the result is :
> Sepal.Length  Sepal.Width Petal.Length  Petal.Width  Species
> "character"  "character"  "character"  "character"  "character"
> 
> How can I conserve the type off each colum? apply seems to convert it into
> "character" adn it could be a problem for me.
> 

lapply(iris, is)

apply() coerces to a matrix before doing its thing, here the lowest common 
denominator was character so that's what you got. 

M

> 
> Regards
> 
>[[alternative HTML version deleted]]
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Compare species presence and absence between sites

2013-09-27 Thread Elaine Kuo
Thanks Rui and Arun.
Both worked well.

One more question, what shall I add for Rui's code if only the comparison
of TRUE (no FALSE) to be shown in the result?

Elaine

code
different <- function(x, y) x == 1 & y == 0

set.seed(7054)
mat <- matrix(sample(0:1, 500, TRUE), nrow = 5)
rownames(mat) <- LETTERS[1:5]
colnames(mat) <- sprintf("D%03d", 1:100)

different(mat["B",], mat["E",])


On Fri, Sep 27, 2013 at 9:31 PM, arun  wrote:

> Just to add:
>
> If you wanted the difference of every combination of rows:
> set.seed(248)
>  mat1<-
> matrix(sample(0:1,5*100,replace=TRUE),ncol=100,dimnames=list(LETTERS[1:5],paste0("D",sprintf("%03d",1:100)))
> )
>  dat<-expand.grid(LETTERS[1:5],LETTERS[1:5],stringsAsFactors=FALSE)
> dat1<-dat[!paste0(dat[,1],dat[,2]) %in% paste0(LETTERS[1:5],LETTERS[1:5]),]
>  lst1<- lapply(seq_len(nrow(dat1)),function(i)
> {x<-mat1[unlist(dat1[i,]),]; which(different(x[1,],x[2,]))}) #using Rui's
> function
> names(lst1)<- paste(dat1[,1],dat1[,2],sep="_")
>
>
> A.K.
>
>
>
> - Original Message -
> From: Rui Barradas 
> To: Elaine Kuo 
> Cc: "r-help@r-project.org" 
> Sent: Friday, September 27, 2013 7:39 AM
> Subject: Re: [R] Compare species presence and absence between sites
>
> Hello,
>
> Something like this?
>
>
> different <- function(x, y) x == 1 & y == 0
>
> set.seed(7054)
> mat <- matrix(sample(0:1, 500, TRUE), nrow = 5)
> rownames(mat) <- LETTERS[1:5]
> colnames(mat) <- sprintf("D%03d", 1:100)
>
> different(mat["B",], mat["E",])
>
>
>
> Hope this helps,
>
> Rui Barradas
>
> Em 27-09-2013 11:48, Elaine Kuo escreveu:
> > Dear List,
> >
> >
> >
> > I want to compare the presence and absence of bird species based on the
> > sites in a matrix.
> >
> > The matrix has 5 rows for Island A, B, C, D, and E.
> >
> > It has 100 columns for bird species D001-D100.
> >
> > In each cell of the matrix,
> >
> > the presence-absence of bird species will be recorded as 1 or 0.
> >
> > (For example, if species D001 is found on Island D,
> >
> > the matrix cell of species D001 and Island D will be 1.)
> >
> >
> >
> > Now I want to know the different bird species between Island B and E.
> >
> > In other words, I would like to find out bird species present (1) on
> Island
> > B but absent (0)on island E, and vice versa (absent (0) on Island B but
> > present (1)on island E).
> >
> >
> >
> > Please kindly advise how to code the purpose above.
> >
> > Thank you in advance.
> >
> >
> >
> > Elaine
> >
> > [[alternative HTML version deleted]]
> >
> > __
> > R-help@r-project.org mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> > and provide commented, minimal, self-contained, reproducible code.
> >
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
>

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Memory distribution using foreach

2013-09-27 Thread Simon Zehnder
First of all LSF is a batch scheduling software. It usually expects an .lsf 
script. Usually the compilers on a cluster are interchangeable via the 'module 
switch  ' and MPI-2 is the message passing 
interface standard. This is also rather an topic for the high-performance R 
list. 

Next, doMC is a multicore package registering cores on one machine - AFAIK, 
i.e. you have to work on one machine with the 24 cores (inform yourself on the 
hardware on your cluster - there should also be introduction presentations 
online! To know what hardware you use and what architecture it has is the first 
step! Try 'bhosts' on your shell to see what hosts are available). If you want 
to use several machines, your backend for foreach should be doMPI and not doMC 
(see http://cran.r-project.org/web/packages/doMPI/vignettes/doMPI.pdf). 

If you found your host, you have to write an lsf-script like the one following 
(for OpenMP on ONE machine - using 24 cores, in most cases this suffices. 
Further, it is faster as you do not have to wait that long because you have to 
use just ONE machine. If you have BULL clusters - take these. A lot of cores 
32/64… and a lot of memory)

So in your case, write a script with extension .lsf containing:

### using the zsh shell
#!/usr/bin/env zsh 

### Job name
#BSUB -J OpenMP

### File/path where output will be written, the %J is the job ID
#BSUB -o OpenMP.%J

### (OFF) Different file for STDERR, if not to be merged with STDOUT
# #BSUB -e OpenM.e%J

### Request the time you need for execution in minutes 
### The format for the parameter is: [hour:]minute,
### that means for 80 minutes you could also use this: 1:20
#BSUB -W 3:00

### Request virtual memory you need for your job in MB (per process)
#BSUB -M 1024

### Request higher amount of stack site (per process)
#BSUB -S 1024
 
### Request the number of compute slots you want to use
#BSUB -n 24

### Specify your mail address 
#BSUB pko...@bgc-jena.mpg.de

### Send a mail when job is done
#BSUB -N

### Use esub for OpenMP 
#BSUB -a openmp

### (OFF) As R is usually compiled via gcc I would load the gcc module on your 
cluster 
# module switch pgi gcc/4.6

### (OFF) load another OpenMP (check which one is usually loaded!! should be 
now OpenMP 4.0) version than the default one
# module switch openmp openmp/3.0

### Set stack and address limits
ulimit -s unlimited
ulimit -v unlimited 

### Change to the work directory 
cd /home/your_username/

### Execute your application (make sure, that R can be loaded via 'R' on the 
shell!!!) 
R --no-restore --no-save --quiet --slave < your_R_script.R



In your R script file, load the packages

library(doMC)
library(foreach)

 
registerDoMC(24)  ## now, foreach knows the backend.

forach(...) %dopar% …..

## save your stuff to your work- or home directory (csv or database)

quit()

---

Then you send the script to LSF via 

bsub <- my_LSF_script.lsf

Look via 'bjobs' if it is is send and what's its status (PEND or RUN). If the 
status is RUN you can look via 'bpeek your_job_ID' what the output looks like, 
while it runs.

Best

Simon



On Sep 27, 2013, at 10:48 PM, pakoun  wrote:

> Dear R users,
> I am struggling with memory issues and try to understand a few things. I am
> using an LSF cluster with PGI compiler and parallel mpi2 computing (whatever
> does that means..) and i submit a job like:
> 
> bsub -R "rusage[mem=3]" -q queue -n 24 R CMD BATCH  
> myjob.r ..log
> 
> According to that I am asking for 24 cores and 30GB RAM. 
> 
> Then I am using 
> library(doMC)
> registerDoMC(24) 
> 
> and a foreach loop either simple or nested with the %dopar% command. 
> 
> 1.  this 30 GB will be distributed among the 24 jobs or each will take 30?
> 2. If i dont ask the -n 24 argument still the foreach loop will run in
> parallel as i check with TOP command. What is the purpose of using it? Just
> to "reserve" the nodes from other users?
> 
> Thank you
> 
> 
> 
> --
> View this message in context: 
> http://r.789695.n4.nabble.com/Memory-distribution-using-foreach-tp4677133.html
> Sent from the R help mailing list archive at Nabble.com.
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Plot lines whose angle and length depict vector quantities

2013-09-27 Thread Greg Snow
The ms.arrows along with my.symbols in the TeachingDemos package does not
require start and end points, it takes a single point along with the angle
and length (and the length can be a single constant to have all the arrows
the same length, or a variable to have different lengths).  You can also
set an adjustment parameter to decide if the arrows should be centered on
the point, start at the point, or end at the point.

The ms.arrows function was designed for exactly what you describe.


On Fri, Sep 27, 2013 at 12:56 PM, Conor Ryan  wrote:

> I am trying to plot points on a map for each ship locations (lat/long),
> where
> each point is a line whose angle (degrees) denotes ships heading and whose
> line length denotes it's speed. Unfortunately arrows(); p.arrows (sfsmisc)
> and ms.arrows (TeachingDemos) require start and end coordinates but I only
> have a single coordinate and an angle to work with. Can you suggest any
> other packages or commands that might allow me to plot this? Alternatively,
> can anyone suggest a method of making 'angle' a vector quantity when using
> the arrows function? Any advice would be much appreciated!
>
> [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



-- 
Gregory (Greg) L. Snow Ph.D.
538...@gmail.com

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] exchange of axis labels in qqnorm function

2013-09-27 Thread Rui Barradas

Hello,

That's documented behavior. From the help page for ?qqnorm:

datax: logical. Should data values be on the x-axis?

(Try it without renaming the axis and it makes more sense.)


Hope this helps,

Rui Barradas

Em 27-09-2013 15:38, Cleber N.Borges escreveu:

Hello all,

Are there a reason for this behaviour in qqnorm function?
(the exchange of axis labels )

 >
 > x <- rnorm(1000)
 > par( mfcol=c(1,2) )
 > qqnorm(x, xlab='X Axis', ylab='Y  Axis', datax=FALSE ) #Default
 > qqnorm(x, xlab='X Axis', ylab='Y  Axis', datax=TRUE )
 >
 >
Thanks for any explanation.

cleber

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Memory distribution using foreach

2013-09-27 Thread pakoun
Dear R users,
I am struggling with memory issues and try to understand a few things. I am
using an LSF cluster with PGI compiler and parallel mpi2 computing (whatever
does that means..) and i submit a job like:

bsub -R "rusage[mem=3]" -q queue -n 24 R CMD BATCH  
myjob.r ..log

According to that I am asking for 24 cores and 30GB RAM. 

Then I am using 
library(doMC)
registerDoMC(24) 

and a foreach loop either simple or nested with the %dopar% command. 

 1.  this 30 GB will be distributed among the 24 jobs or each will take 30?
 2. If i dont ask the -n 24 argument still the foreach loop will run in
parallel as i check with TOP command. What is the purpose of using it? Just
to "reserve" the nodes from other users?

Thank you



--
View this message in context: 
http://r.789695.n4.nabble.com/Memory-distribution-using-foreach-tp4677133.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Help with nested and non-nested factors

2013-09-27 Thread Ana Arjona
Hi,

I am trying to fit a multilevel model with lmer but have some doubts about the 
code:





[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Error: C stack usage is too close to the limit when using list.files()

2013-09-27 Thread William Dunlap
Toss a couple of extra files in there and you will see the output grow 
exponentially.

% touch dir/IMPORTANT_1 dir/subdir/IMPORTANT_2

and in R those two new files cause 82 more strings to appear in list.file's 
output:

> nchar(list.files("dir", recursive=TRUE))
 [1]  11  18  33  40  55  62  77  84  99 106 121 128 143 150 165 172 187 194 209
[20] 216 231 238 253 260 275 282 297 304 319 326 341 348 363 370 385 392 407 414
[39] 429 436 451 458 473 480 495 502 517 524 539 546 561 568 583 590 605 612 627
[58] 634 649 656 671 678 693 700 715 722 737 744 759 766 781 788 803 810 825 832
[77] 847 854 869 876 891 898 901

'find', by default, does not following symbolic links.

% find dir
dir
dir/subdir
dir/subdir/IMPORTANT_2
dir/subdir/linkToUpperDir
dir/IMPORTANT_1

The -L option makes it follow them, but it won't follow loops:

% find -L dir
dir
dir/subdir
dir/subdir/IMPORTANT_2
find: File system loop detected; `dir/subdir/linkToUpperDir' is part of the 
same file system loop as `dir'.
dir/IMPORTANT_1

Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com


> -Original Message-
> From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On 
> Behalf
> Of William Dunlap
> Sent: Friday, September 27, 2013 12:56 PM
> To: Jonathan Greenberg; r-help
> Subject: Re: [R] Error: C stack usage is too close to the limit when using 
> list.files()
> 
> Do you have some symbolic links that make loops in your file system?
> list.files() has problems with such loops and find does not.  E.g.,  on a 
> Linux box:
> 
> % cd /tmp
> % mkdir dir dir/subdir
> % cd dir/subdir
> % ln -s ../../dir linkToUpperDir
> % cd /tmp
> % R --quiet
> > list.files("dir", recursive=TRUE, full=TRUE)
> [1]
> "dir/subdir/linkToUpperDir/subdir/linkToUpperDir/subdir/linkToUpperDir/subdir/linkToU
> pperDir/subdir/linkToUpperDir/subdir/linkToUpperDir/subdir/linkToUpperDir/subdir/linkT
> oUpperDir/subdir/linkToUpperDir/subdir/linkToUpperDir/subdir/linkToUpperDir/subdir/li
> nkToUpperDir/subdir/linkToUpperDir/subdir/linkToUpperDir/subdir/linkToUpperDir/subdi
> r/linkToUpperDir/subdir/linkToUpperDir/subdir/linkToUpperDir/subdir/linkToUpperDir/su
> bdir/linkToUpperDir/subdir/linkToUpperDir/subdir/linkToUpperDir/subdir/linkToUpperDir
> /subdir/linkToUpperDir/subdir/linkToUpperDir/subdir/linkToUpperDir/subdir/linkToUpper
> Dir/subdir/linkToUpperDir/subdir/linkToUpperDir/subdir/linkToUpperDir/subdir/linkToUp
> perDir/subdir/linkToUpperDir/subdir/linkToUpperDir/subdir/linkToUpperDir/subdir/linkTo
> UpperDir/subdir/linkToUpperDir/subdir/linkToUpperDir/subdir/linkToUpperDir/subdir/lin
> kToUpperDir/subdir/linkToUpperDir/subdir/linkToUpperDir"
> > system("find dir")
> dir
> dir/subdir
> dir/subdir/linkToUpperDir
> 
> Bill Dunlap
> Spotfire, TIBCO Software
> wdunlap tibco.com
> 
> 
> > -Original Message-
> > From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On 
> > Behalf
> > Of Jonathan Greenberg
> > Sent: Friday, September 27, 2013 12:13 PM
> > To: r-help
> > Subject: [R] Error: C stack usage is too close to the limit when using 
> > list.files()
> >
> > R-helpers:
> >
> > I'm running a file search on my entire drive (Mac OS X) using:
> >
> > files_found <- 
> > list.files(dir="/",pattern=somepattern,recursive=TRUE,full.names=TRUE)
> > where somepattern is a search pattern (which I have confirmed via a
> > unix "find / -name somepattern" only returns ~ 3 results).
> >
> > I keep getting an error:
> >
> > Error: C stack usage is too close to the limit
> >
> > when running this command.  Any ideas on 1) how to fix this or 2) if
> > there is an alternative to using list.files() to accomplish this
> > search without resorting to an external package?
> >
> > Cheers!
> >
> > --jonathan
> >
> >
> > --
> > Jonathan A. Greenberg, PhD
> > Assistant Professor
> > Global Environmental Analysis and Remote Sensing (GEARS) Laboratory
> > Department of Geography and Geographic Information Science
> > University of Illinois at Urbana-Champaign
> > 259 Computing Applications Building, MC-150
> > 605 East Springfield Avenue
> > Champaign, IL  61820-6371
> > Phone: 217-300-1924
> > http://www.geog.illinois.edu/~jgrn/
> > AIM: jgrn307, MSN: jgrn...@hotmail.com, Gchat: jgrn307, Skype: jgrn3007
> >
> > __
> > R-help@r-project.org mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> > and provide commented, minimal, self-contained, reproducible code.
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-pro

Re: [R] Plot lines whose angle and length depict vector quantities

2013-09-27 Thread Bert Gunter
On Fri, Sep 27, 2013 at 12:44 PM, Sarah Goslee  wrote:
> It's a straightforward trigonometry problem, isn't it?

Indeed! (  (r,theta) to (x,y) coordinates  ) . So I wonder if this is
a homework problem. If so, the OP should note that we try not to do
homework here.

Cheers,
Bert
>
> On Fri, Sep 27, 2013 at 2:56 PM, Conor Ryan  wrote:
>> I am trying to plot points on a map for each ship locations (lat/long),
>> where
>> each point is a line whose angle (degrees) denotes ships heading and whose
>> line length denotes it's speed. Unfortunately arrows(); p.arrows (sfsmisc)
>> and ms.arrows (TeachingDemos) require start and end coordinates but I only
>> have a single coordinate and an angle to work with. Can you suggest any
>> other packages or commands that might allow me to plot this? Alternatively,
>> can anyone suggest a method of making 'angle' a vector quantity when using
>> the arrows function? Any advice would be much appreciated!
>>
>
> --
> Sarah Goslee
> http://www.functionaldiversity.org
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.



-- 

Bert Gunter
Genentech Nonclinical Biostatistics

Internal Contact Info:
Phone: 467-7374
Website:
http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pdb-biostatistics/pdb-ncb-home.htm

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Error: C stack usage is too close to the limit when using list.files()

2013-09-27 Thread Berend Hasselman

On 27-09-2013, at 21:50, Jonathan Greenberg  wrote:

> Ben:
> 
> I'd like to avoid using that (previous version of my code solved it in
> that way) -- I would like cross-platform compatibility and I am pretty
> sure, along with Windows, vanilla Macs don't come with "find" either
> unless XCode has been installed.
> 

As far as I can tell Mac OS X provides a find utility (the Unix version). It is 
not part of Xcode.

Berend

> Is the list.files() code itself recursive when using recursive=TRUE
> (so it has one recursion per bottom-folder)?
> 
> --j
> 
> P.S. I recognized that in my initial post I indicated using "dir" as
> the parameter -- it should have been "path" (the error occurred
> through the correct usage of list.files(path="/",...)   That'll teach
> me not to copy/paste from my code...
> 
> On Fri, Sep 27, 2013 at 2:36 PM, Ben Bolker  wrote:
>> Jonathan Greenberg  illinois.edu> writes:
>> 
>>> 
>>> R-helpers:
>>> 
>>> I'm running a file search on my entire drive (Mac OS X) using:
>>> 
>>> files_found <-
>> list.files(dir="/",pattern=somepattern,recursive=TRUE,full.names=TRUE)
>>> where somepattern is a search pattern (which I have confirmed via a
>>> unix "find / -name somepattern" only returns ~ 3 results).
>>> 
>>> I keep getting an error:
>>> 
>>> Error: C stack usage is too close to the limit
>>> 
>>> when running this command.  Any ideas on 1) how to fix this or 2) if
>>> there is an alternative to using list.files() to accomplish this
>>> search without resorting to an external package?
>> 
>>  I assuming that using
>> 
>> system("find / -name somepattern")
>> 
>> (possibly with intern=TRUE) isn't allowed?  (I don't know what you're
>> trying to do, but if you don't need it to work on Windows-without-cygwin,
>> this should work across most Unix variants (although a "-print" might
>> be required)
>> 
>> __
>> R-help@r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
> 
> 
> 
> -- 
> Jonathan A. Greenberg, PhD
> Assistant Professor
> Global Environmental Analysis and Remote Sensing (GEARS) Laboratory
> Department of Geography and Geographic Information Science
> University of Illinois at Urbana-Champaign
> 259 Computing Applications Building, MC-150
> 605 East Springfield Avenue
> Champaign, IL  61820-6371
> Phone: 217-300-1924
> http://www.geog.illinois.edu/~jgrn/
> AIM: jgrn307, MSN: jgrn...@hotmail.com, Gchat: jgrn307, Skype: jgrn3007
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Error: C stack usage is too close to the limit when using list.files()

2013-09-27 Thread William Dunlap
Do you have some symbolic links that make loops in your file system?
list.files() has problems with such loops and find does not.  E.g.,  on a Linux 
box:

% cd /tmp
% mkdir dir dir/subdir
% cd dir/subdir
% ln -s ../../dir linkToUpperDir
% cd /tmp
% R --quiet
> list.files("dir", recursive=TRUE, full=TRUE)
[1] 
"dir/subdir/linkToUpperDir/subdir/linkToUpperDir/subdir/linkToUpperDir/subdir/linkToUpperDir/subdir/linkToUpperDir/subdir/linkToUpperDir/subdir/linkToUpperDir/subdir/linkToUpperDir/subdir/linkToUpperDir/subdir/linkToUpperDir/subdir/linkToUpperDir/subdir/linkToUpperDir/subdir/linkToUpperDir/subdir/linkToUpperDir/subdir/linkToUpperDir/subdir/linkToUpperDir/subdir/linkToUpperDir/subdir/linkToUpperDir/subdir/linkToUpperDir/subdir/linkToUpperDir/subdir/linkToUpperDir/subdir/linkToUpperDir/subdir/linkToUpperDir/subdir/linkToUpperDir/subdir/linkToUpperDir/subdir/linkToUpperDir/subdir/linkToUpperDir/subdir/linkToUpperDir/subdir/linkToUpperDir/subdir/linkToUpperDir/subdir/linkToUpperDir/subdir/linkToUpperDir/subdir/linkToUpperDir/subdir/linkToUpperDir/subdir/linkToUpperDir/subdir/linkToUpperDir/subdir/linkToUpperDir/subdir/linkToUpperDir/subdir/linkToUpperDir/subdir/linkToUpperDir/subdir/linkToUpperDir"
> system("find dir")
dir
dir/subdir
dir/subdir/linkToUpperDir

Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com


> -Original Message-
> From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On 
> Behalf
> Of Jonathan Greenberg
> Sent: Friday, September 27, 2013 12:13 PM
> To: r-help
> Subject: [R] Error: C stack usage is too close to the limit when using 
> list.files()
> 
> R-helpers:
> 
> I'm running a file search on my entire drive (Mac OS X) using:
> 
> files_found <- 
> list.files(dir="/",pattern=somepattern,recursive=TRUE,full.names=TRUE)
> where somepattern is a search pattern (which I have confirmed via a
> unix "find / -name somepattern" only returns ~ 3 results).
> 
> I keep getting an error:
> 
> Error: C stack usage is too close to the limit
> 
> when running this command.  Any ideas on 1) how to fix this or 2) if
> there is an alternative to using list.files() to accomplish this
> search without resorting to an external package?
> 
> Cheers!
> 
> --jonathan
> 
> 
> --
> Jonathan A. Greenberg, PhD
> Assistant Professor
> Global Environmental Analysis and Remote Sensing (GEARS) Laboratory
> Department of Geography and Geographic Information Science
> University of Illinois at Urbana-Champaign
> 259 Computing Applications Building, MC-150
> 605 East Springfield Avenue
> Champaign, IL  61820-6371
> Phone: 217-300-1924
> http://www.geog.illinois.edu/~jgrn/
> AIM: jgrn307, MSN: jgrn...@hotmail.com, Gchat: jgrn307, Skype: jgrn3007
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Plot lines whose angle and length depict vector quantities

2013-09-27 Thread Sarah Goslee
It's a straightforward trigonometry problem, isn't it?

On Fri, Sep 27, 2013 at 2:56 PM, Conor Ryan  wrote:
> I am trying to plot points on a map for each ship locations (lat/long),
> where
> each point is a line whose angle (degrees) denotes ships heading and whose
> line length denotes it's speed. Unfortunately arrows(); p.arrows (sfsmisc)
> and ms.arrows (TeachingDemos) require start and end coordinates but I only
> have a single coordinate and an angle to work with. Can you suggest any
> other packages or commands that might allow me to plot this? Alternatively,
> can anyone suggest a method of making 'angle' a vector quantity when using
> the arrows function? Any advice would be much appreciated!
>

-- 
Sarah Goslee
http://www.functionaldiversity.org

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Error: C stack usage is too close to the limit when using list.files()

2013-09-27 Thread Jonathan Greenberg
Ben:

I'd like to avoid using that (previous version of my code solved it in
that way) -- I would like cross-platform compatibility and I am pretty
sure, along with Windows, vanilla Macs don't come with "find" either
unless XCode has been installed.

Is the list.files() code itself recursive when using recursive=TRUE
(so it has one recursion per bottom-folder)?

--j

P.S. I recognized that in my initial post I indicated using "dir" as
the parameter -- it should have been "path" (the error occurred
through the correct usage of list.files(path="/",...)   That'll teach
me not to copy/paste from my code...

On Fri, Sep 27, 2013 at 2:36 PM, Ben Bolker  wrote:
> Jonathan Greenberg  illinois.edu> writes:
>
>>
>> R-helpers:
>>
>> I'm running a file search on my entire drive (Mac OS X) using:
>>
>> files_found <-
> list.files(dir="/",pattern=somepattern,recursive=TRUE,full.names=TRUE)
>> where somepattern is a search pattern (which I have confirmed via a
>> unix "find / -name somepattern" only returns ~ 3 results).
>>
>> I keep getting an error:
>>
>> Error: C stack usage is too close to the limit
>>
>> when running this command.  Any ideas on 1) how to fix this or 2) if
>> there is an alternative to using list.files() to accomplish this
>> search without resorting to an external package?
>
>   I assuming that using
>
> system("find / -name somepattern")
>
> (possibly with intern=TRUE) isn't allowed?  (I don't know what you're
> trying to do, but if you don't need it to work on Windows-without-cygwin,
> this should work across most Unix variants (although a "-print" might
> be required)
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.



-- 
Jonathan A. Greenberg, PhD
Assistant Professor
Global Environmental Analysis and Remote Sensing (GEARS) Laboratory
Department of Geography and Geographic Information Science
University of Illinois at Urbana-Champaign
259 Computing Applications Building, MC-150
605 East Springfield Avenue
Champaign, IL  61820-6371
Phone: 217-300-1924
http://www.geog.illinois.edu/~jgrn/
AIM: jgrn307, MSN: jgrn...@hotmail.com, Gchat: jgrn307, Skype: jgrn3007

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Error: C stack usage is too close to the limit when using list.files()

2013-09-27 Thread Ben Bolker
Jonathan Greenberg  illinois.edu> writes:

> 
> R-helpers:
> 
> I'm running a file search on my entire drive (Mac OS X) using:
> 
> files_found <-
list.files(dir="/",pattern=somepattern,recursive=TRUE,full.names=TRUE)
> where somepattern is a search pattern (which I have confirmed via a
> unix "find / -name somepattern" only returns ~ 3 results).
> 
> I keep getting an error:
> 
> Error: C stack usage is too close to the limit
> 
> when running this command.  Any ideas on 1) how to fix this or 2) if
> there is an alternative to using list.files() to accomplish this
> search without resorting to an external package?

  I assuming that using

system("find / -name somepattern")

(possibly with intern=TRUE) isn't allowed?  (I don't know what you're
trying to do, but if you don't need it to work on Windows-without-cygwin,
this should work across most Unix variants (although a "-print" might
be required)

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Plot lines whose angle and length depict vector quantities

2013-09-27 Thread Conor Ryan
I am trying to plot points on a map for each ship locations (lat/long),
where
each point is a line whose angle (degrees) denotes ships heading and whose
line length denotes it's speed. Unfortunately arrows(); p.arrows (sfsmisc)
and ms.arrows (TeachingDemos) require start and end coordinates but I only
have a single coordinate and an angle to work with. Can you suggest any
other packages or commands that might allow me to plot this? Alternatively,
can anyone suggest a method of making 'angle' a vector quantity when using
the arrows function? Any advice would be much appreciated!

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] table of contents link style in R's PDF docs

2013-09-27 Thread Duncan Murdoch

On 26/09/2013 10:33 AM, Duncan Murdoch wrote:

On 25/09/2013 11:38 PM, Ben Harrison wrote:
> Hello,
> I am mildly annoyed each time I use a PDF doc of an R package that the
> table of contents hyperlinks are *only* on the page numbers. To activate
> a hyperlink, one must carefully scan sideways from the text item wanted
> to the far right of the page and click on a tiny box. Multiply that mild
> annoyance by the large number of times I need to look up package help
> docs, and I find myself here writing this message.
>
>   From my understanding (albeit poor), all of the R docs for packages are
> to be written in Rd format. From that they are converted by the
> functions in the tools package as required (to latex and PDF, or HTML,
> etc). So the only thing that controls in the PDF docs the hyperlinks one
> way or another is the latex style file used - in this case I believe it
> is Rd.sty (/usr/share/R/share/texmf/tex/latex/Rd.sty on my system).
>
> Line 303 of that file contains the single setting of the \hypersetup{}
> command for whether or not the text in the table of contents is
> hyperlinked, or the page number:
>
>   linktocpage,%
>
> which causes it to implicitly be set to True. Setting it to false (or
> just commenting out that line I suppose as false is the default) would
> mean the *text* in the TOC is hyperlinked.
>
> So, is the desired behaviour intended to be that only the page numbers
> are hyperlinked (and therefore to annoy me), or has no-one really
> bothered themselves with it that much, or something else?

It's been the way it is for about 14 years, and I don't recall anyone
else complaining, so I'd conclude it must have been set that way with
you in mind.

More seriously, I prefer having the page number clickable to having just
the text clickable.  Having both would be fine for both of us. There's a
partially documented option "linktoc=all" that does that; it was added
to the hyperref package in 2008, so you can hardly blame R for not using
it back in 1999.  The only problem I can see with using it now is that
some users might not have a sufficiently up-to-date LaTeX installation
to use it; if their hyperref package doesn't know about linktoc, they
won't be able to build anything at all.

>
> Can I recreate all the documentation on my system after I make a change
> to Rd.sty?

Easiest would be to just do a rebuild of R, but you could also do the
PDF manuals one at a time using

R CMD Rd2pdf  

from the directory where the package is installed, or where its source
lives.


I took a look at changing this, and decided against it:  we've had 
trouble with varying versions
of hyperref in the past.  However, anyone who wants to control the 
hyperlinking can follow
the instructions in the Installation and Administration file and create 
an Rd.cfg file (and put it on the Latex path, e.g. in 
R_HOME/share/texmf/tex/latex) to configure their own installation. 
Putting the line


\ifthenelse{\boolean{Rd@use@hyper}}{\hypersetup{linktoc=all}}{}

into that file works to give hyperlinks on both the text and page 
number, provided you have a compatible version of

hyperref.  (This will be described in newer versions of the manual.)

Duncan Murdoch

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Error: C stack usage is too close to the limit when using list.files()

2013-09-27 Thread Jonathan Greenberg
R-helpers:

I'm running a file search on my entire drive (Mac OS X) using:

files_found <- 
list.files(dir="/",pattern=somepattern,recursive=TRUE,full.names=TRUE)
where somepattern is a search pattern (which I have confirmed via a
unix "find / -name somepattern" only returns ~ 3 results).

I keep getting an error:

Error: C stack usage is too close to the limit

when running this command.  Any ideas on 1) how to fix this or 2) if
there is an alternative to using list.files() to accomplish this
search without resorting to an external package?

Cheers!

--jonathan


-- 
Jonathan A. Greenberg, PhD
Assistant Professor
Global Environmental Analysis and Remote Sensing (GEARS) Laboratory
Department of Geography and Geographic Information Science
University of Illinois at Urbana-Champaign
259 Computing Applications Building, MC-150
605 East Springfield Avenue
Champaign, IL  61820-6371
Phone: 217-300-1924
http://www.geog.illinois.edu/~jgrn/
AIM: jgrn307, MSN: jgrn...@hotmail.com, Gchat: jgrn307, Skype: jgrn3007

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Logical indexing not working

2013-09-27 Thread Sarah Goslee
Your post demonstrates why we ask people to NOT post in HTML.
Attempting to decode it, I think the problem might be

birds==c(1,23,24,29)

Look at this:

birds <- c(2, 4, 1, 23, 8, 24)
birds <- data.frame(birds)
birds[birds[,1] == c(1,23,24,29),]

And compare
birds[birds[,1] %in% c(1,23,24,29),]

You might also benefit from reading ?subset and the Introduction to R
that came with your installation.

Sarah

On Fri, Sep 27, 2013 at 2:20 PM, Mariki Zietsman
 wrote:
> I have a data frame frugivore.abundance.S1 where some columns are factors and 
> others are numbers.For example these are my independent variables and 
> "density" is my dependent variable. census<-c(1:70)sites<-c(1:5)birds<-c(1:45)
>
> I want to select the data where sites is 1 and birds are 1,23,24 or 29
> So I 
> write:fa1<-frugivore.abundance.S1attach(fa1)(abund.frug.RN1<-fa1[sites==1 & 
> birds==c(1,23,24,29),])
> This code doesn't print all the data it should for some reason. It seems to 
> not print rows where "density" has the same value as another row with the 
> same criteria.
> i.e. if in the original data we have the following then only rows 1 and 3 
> will be printed, not all of them:
> census   sites   birds   density1 1 1 0.0032  
>1 1 0.0033 1 1 
> 0.001
> Can anyone help me out with this please?
> RegardsMariki
>

-- 
Sarah Goslee
http://www.functionaldiversity.org

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Logical indexing not working

2013-09-27 Thread Rui Barradas

Hello,

Please don't post in HTML, it messes up the code and data.
And please use ?dput to post your data:

dput(fa1)  # post the output of this.


As for your problem, maybe if you try ?%in%

fa1[sites==1 & birds %in% c(1,23,24,29),]


Hope this helps,

Rui Barradas

Em 27-09-2013 19:20, Mariki Zietsman escreveu:

I have a data frame frugivore.abundance.S1 where some columns are factors and others are 
numbers.For example these are my independent variables and "density" is my dependent 
variable. census<-c(1:70)sites<-c(1:5)birds<-c(1:45)

I want to select the data where sites is 1 and birds are 1,23,24 or 29
So I write:fa1<-frugivore.abundance.S1attach(fa1)(abund.frug.RN1<-fa1[sites==1 
& birds==c(1,23,24,29),])
This code doesn't print all the data it should for some reason. It seems to not print 
rows where "density" has the same value as another row with the same criteria.
i.e. if in the original data we have the following then only rows 1 and 3 will 
be printed, not all of them:
census   sites   birds   density1 1 1 0.0032
 1 1 0.0033 1 1 
0.001
Can anyone help me out with this please?
RegardsMariki

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.



__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Logical indexing not working

2013-09-27 Thread William Dunlap
> where ... birds are 1,23,24 or 29 ...
> birds==c(1,23,24,29)

Use
   is.element(birds, c(1,23,24,29))
or
   (birds %in% c(1,23,24,29))
if you prefer typing percent signs.

Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com


> -Original Message-
> From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On 
> Behalf
> Of Mariki Zietsman
> Sent: Friday, September 27, 2013 11:20 AM
> To: r-help@r-project.org
> Subject: [R] Logical indexing not working
> 
> I have a data frame frugivore.abundance.S1 where some columns are factors and 
> others
> are numbers.For example these are my independent variables and "density" is my
> dependent variable. census<-c(1:70)sites<-c(1:5)birds<-c(1:45)
> 
> I want to select the data where sites is 1 and birds are 1,23,24 or 29
> So I 
> write:fa1<-frugivore.abundance.S1attach(fa1)(abund.frug.RN1<-fa1[sites==1 &
> birds==c(1,23,24,29),])
> This code doesn't print all the data it should for some reason. It seems to 
> not print rows
> where "density" has the same value as another row with the same criteria.
> i.e. if in the original data we have the following then only rows 1 and 3 
> will be printed,
> not all of them:
> census   sites   birds   density1 1 1 0.0032  
>1 1 0.0033
> 1 1 0.001
> Can anyone help me out with this please?
> RegardsMariki
> 
>   [[alternative HTML version deleted]]
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Logical indexing not working

2013-09-27 Thread Mariki Zietsman
I have a data frame frugivore.abundance.S1 where some columns are factors and 
others are numbers.For example these are my independent variables and "density" 
is my dependent variable. census<-c(1:70)sites<-c(1:5)birds<-c(1:45)

I want to select the data where sites is 1 and birds are 1,23,24 or 29
So I write:fa1<-frugivore.abundance.S1attach(fa1)(abund.frug.RN1<-fa1[sites==1 
& birds==c(1,23,24,29),])
This code doesn't print all the data it should for some reason. It seems to not 
print rows where "density" has the same value as another row with the same 
criteria.
i.e. if in the original data we have the following then only rows 1 and 3 will 
be printed, not all of them:
census   sites   birds   density1 1 1 0.0032
 1 1 0.0033 1 1 
0.001
Can anyone help me out with this please?
RegardsMariki
  
[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] An Apply function question about changing type of variable

2013-09-27 Thread Ben Tupper
Hi,

On Sep 27, 2013, at 11:27 AM, Vincent Guyader wrote:

> Hi everyone,
> 
> plese can you look at this few lines :
> 
> data(iris)
> res<-apply(iris,MARGIN=2,is)
> res[1,]
> 
> the result is :
> Sepal.Length  Sepal.Width Petal.Length  Petal.Width  Species
> "character"  "character"  "character"  "character"  "character"
> 
> How can I conserve the type off each colum? apply seems to convert it into
> "character" adn it could be a problem for me.
> 

Did you intend to use lapply() instead of apply()?  

> res<-lapply(iris,is)
> str(res)
List of 5
 $ Sepal.Length: chr [1:2] "numeric" "vector"
 $ Sepal.Width : chr [1:2] "numeric" "vector"
 $ Petal.Length: chr [1:2] "numeric" "vector"
 $ Petal.Width : chr [1:2] "numeric" "vector"
 $ Species : chr [1:5] "factor" "integer" "oldClass" "numeric" ...

apply() expects an array input, so it will coerce non-array inputs to be so 
with as.matrix() or as.array(). That coercion will change the data type if 
needed, in your case changing all to character to accommodate the factor column.

> iris2 <- as.matrix(iris)
> str(iris2)
 chr [1:150, 1:5] "5.1" "4.9" "4.7" "4.6" "5.0" "5.4" "4.6" "5.0" "4.4" ...
 - attr(*, "dimnames")=List of 2
  ..$ : NULL
  ..$ : chr [1:5] "Sepal.Length" "Sepal.Width" "Petal.Length" "Petal.Width" ...

Cheers,
Ben



> 
> Regards
> 
>   [[alternative HTML version deleted]]
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

Ben Tupper
Bigelow Laboratory for Ocean Sciences
60 Bigelow Drive, P.O. Box 380
East Boothbay, Maine 04544
http://www.bigelow.org

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] snow::makeCluster on Windows hangs

2013-09-27 Thread Jeffrey Flint
Prof Ripley:

Thank you for the help.

   - I used the "manual" option because it was suggested in some postings
   because it shows the parameters being used.  The behavior was the same with
   and without the "manual" option (I needed to use ESC to get out).
   - Would there be some limitation in my hardware that would prevent the
   snow package to work?
   - Is there some sort of diagnostics in the snow package that can report
   setup difficulties?
   - Are you saying my version of R is obsolete at 2/29/12?  I could try to
   use the new version of R to see if that makes a difference.  But wouldn't
   the snow code work the same since it hasn't been updated?
   - I can look at the package parallel.  I used snow because of an example
   in the text "The Art of R Programming".

Jeff


On Thu, Sep 26, 2013 at 10:31 PM, Prof Brian Ripley
wrote:

> You failed to mention this about contributed package 'snow' (and a long
> obsolete version of R: see the postin guide).  That version of R has
> package 'parallel' which would be preferred.   But it looks like you did
> not manually start the workers (and I am not sure why you would want to do
> that).
>
>
> On 27/09/2013 02:26, Jeffrey Flint wrote:
>
>> The command which hangs:
>> I'm hoping there is a simple explanation, but I searched on-line and
>> nothing jumped out.
>>
>>  cl <- makeCluster(type="SOCK",c("**localhost"),manual=TRUE)
>>>
>> Manually start worker on localhost with
>>   C:/PROGRA~1/R/R-214~1.2/bin/**Rscript.exe "C:/Program
>> Files/R/R-2.14.2/library/snow/**RSOCKnode.R" MASTER=localhost PORT=11944
>> OUT=/dev/null SNOWLIB=C:/Program Files/R/R-2.14.2/library
>> [HANGS]
>>
>>> cl <- makeCluster(type="SOCK",c("**localhost","localhost"),**
>>> manual=TRUE)
>>>
>> Manually start worker on localhost with
>>   C:/PROGRA~1/R/R-214~1.2/bin/**Rscript.exe "C:/Program
>> Files/R/R-2.14.2/library/snow/**RSOCKnode.R" MASTER=localhost PORT=11944
>> OUT=/dev/null SNOWLIB=C:/Program Files/R/R-2.14.2/library
>> [HANGS]
>>
>> The computer:
>>
>> Dell Inspiron I6400
>> with T2300 Dual Core processor
>>
>>
>> The OS:
>>
>>  version
>>>
>> _
>> platform   i386-pc-mingw32
>> arch   i386
>> os mingw32
>> system i386, mingw32
>> status
>> major  2
>> minor  14.2
>> year   2012
>> month  02
>> day29
>> svn rev58522
>> language   R
>> version.string R version 2.14.2 (2012-02-29)
>>
>> __**
>> R-help@r-project.org mailing list
>> https://stat.ethz.ch/mailman/**listinfo/r-help
>> PLEASE do read the posting guide http://www.R-project.org/**
>> posting-guide.html 
>> and provide commented, minimal, self-contained, reproducible code.
>>
>>
>
> --
> Brian D. Ripley,  rip...@stats.ox.ac.uk
> Professor of Applied Statistics,  
> http://www.stats.ox.ac.uk/~**ripley/
> University of Oxford, Tel:  +44 1865 272861 (self)
> 1 South Parks Road, +44 1865 272866 (PA)
> Oxford OX1 3TG, UKFax:  +44 1865 272595
>

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] An Apply function question about changing type of variable

2013-09-27 Thread Vincent Guyader
Hi everyone,

plese can you look at this few lines :

data(iris)
res<-apply(iris,MARGIN=2,is)
res[1,]

the result is :
Sepal.Length  Sepal.Width Petal.Length  Petal.Width  Species
 "character"  "character"  "character"  "character"  "character"

How can I conserve the type off each colum? apply seems to convert it into
"character" adn it could be a problem for me.


Regards

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] exchange of axis labels in qqnorm function

2013-09-27 Thread Cleber N.Borges

Hello all,

Are there a reason for this behaviour in qqnorm function?
(the exchange of axis labels )

>
> x <- rnorm(1000)
> par( mfcol=c(1,2) )
> qqnorm(x, xlab='X Axis', ylab='Y  Axis', datax=FALSE ) #Default
> qqnorm(x, xlab='X Axis', ylab='Y  Axis', datax=TRUE )
>
>
Thanks for any explanation.

cleber

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Calculating euclidean distance in R

2013-09-27 Thread Upton, Stephen (Steve) (CIV)
?read.csv 
to read your data in,

then
?dist

to calculate distances.

steve

-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On
Behalf Of Debasish Sahu
Sent: Friday, September 27, 2013 12:26 AM
To: r-help@r-project.org
Subject: [R] Calculating euclidean distance in R

Hello,
I am quite new to R.(in fact for the first time I am using) So forgive me if
I have asked a silly question.

I have a table in.csv format with data for location of samples in X, Y, Z
(column)format.
Now I want to calculate the Euclidean distance for the total sample dataset.

Can you please help me how to get the Euclidean distance of dataset .

Thanks & regards,
Debasish

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] R not ploting lines in the correct order

2013-09-27 Thread arun
Hi,
Not sure if this helps, but you can try ?xts
library(xts)
X<- structure(
xt1<- xts(X[,2],order.by=X[,1])
plot(xt1,type="o")
A.K.





- Original Message -
From: Shane Carey 
To: Sarah Goslee 
Cc: "r-help@r-project.org" 
Sent: Friday, September 27, 2013 10:06 AM
Subject: Re: [R] R not ploting lines in the correct order

Ah ok, Here we go:

structure(list(DATE = structure(c(1348477980, 1350386220, 1351114980,
1347388440, 1345650300, 1344558600, 1344955920, 1348489140, 1351169100,
1352297220, 1350471060, 1352303640, 1351797660, 1351772580, 1349213100,
1354275600, 1351257660, 1345728480, 1355914440, 1344552300, 1347442740,
1349954880, 1344874500, 1347274860, 1345546500, 1354269780, 1351271280,
1349268300), class = c("POSIXct", "POSIXt"), tzone = "GMT"),
    DATA = c(5.61, 5.8, 6.01, 5.65, 5.27, 5.67, 5.66, 5.81, 5.67,
    5.46, 5.81, 5.86, 5.7, 5.33, 5.99, 5.7, 6.06, 5.47, 6.42,
    6.05, 5.49, 5.45, 5.48, 5.61, 5.96, 5.37, 5.77, 5.81)), .Names =
c("DATE",
"DATA"), row.names = c(NA, -28L), class = "data.frame")

The wrong points are being joined by lines. If I use qplot from the ggplot2
library it plots fine, but I want to use plot as it is easier to customise.

Thanks again.


On Fri, Sep 27, 2013 at 2:36 PM, Sarah Goslee wrote:

> If you use dput() correctly, those of us following along via email can
> create an exact duplicate of your R object. All you need to do is:
> dput(X)
> and paste the resulting output into email.
>
> You see, if I look at your object as you pasted it in, I can't tell if
> your Date column is a date format, or character, or factor, or who
> knows what, and that may matter for answering your question.
>
> Also, what are "the wrong points"? What points do you expect to be
> connected?
>
> Sarah
>
>
> On Fri, Sep 27, 2013 at 8:13 AM, Shane Carey  wrote:
> > Hi Sarah,
> >
> > thanks for your reply. Im not sure how to use dput? If I create an
> object of
> > my data, does that mean you can read it in from your side or something?
> >
> > Here is my code:
> > X
> > Data         Date
> > 5.61 24/09/2012 09:13
> > 5.80 16/10/2012 11:17
> > 6.01 24/10/2012 21:43
> > 5.65 11/09/2012 18:34
> > 5.27 22/08/2012 15:45
> > 5.67 10/08/2012 00:30
> > 5.66 14/08/2012 14:52
> > 5.81 24/09/2012 12:19
> > 5.67 25/10/2012 12:45
> > 5.46 07/11/2012 14:07
> > 5.81 17/10/2012 10:51
> > 5.86 07/11/2012 15:54
> > 5.70 01/11/2012 19:21
> > 5.33 01/11/2012 12:23
> > 5.99 02/10/2012 21:25
> > 5.70 30/11/2012 11:40
> > 6.06 26/10/2012 13:21
> > 5.47 23/08/2012 13:28
> > 6.42 19/12/2012 10:54
> > 6.05 09/08/2012 22:45
> > 5.49 12/09/2012 09:39
> > 5.45 11/10/2012 11:28
> > 5.48 13/08/2012 16:15
> > 5.61 10/09/2012 11:01
> > 5.96 21/08/2012 10:55
> > 5.37 30/11/2012 10:03
> > 5.77 26/10/2012 17:08
> > 5.81 03/10/2012 12:45
> > dput(X, "X")
> > plot(X$Data,Y$Date,yaxt="n", xaxt="n",type="o")
> > lines(X$Data,Y$Date,pch=21, col="blue",type="o")
> >
> >
> > Thanks again
> >
> >
> > On Thu, Sep 26, 2013 at 7:23 PM, Sarah Goslee 
> > wrote:
> >>
> >> Hi Shane,
> >>
> >> Please use dput() to provide your data, rather than pasting it in so
> >> that we can work from the same R object you are. Please also provide
> >> the code you're using to make the graph.
> >>
> >> Sarah
> >>
> >> On Thu, Sep 26, 2013 at 1:56 PM, Shane Carey 
> wrote:
> >> > Hi,
> >> >
> >> > I have a set of x, y points where x represents dates and y actual
> >> > values. I
> >> > am trying to plot a line graph of the data with points on top, but R
> is
> >> > connecting the wrong points with lines. Does anyone know how I can
> >> > rectify
> >> > this. Please see sample below:
> >> >
> >> > x=
> >> >  24/09/2009 09:13  16/10/2009 11:17  24/10/2009 21:43  11/09/2009
> >> > 18:34  22/08/2009
> >> > 15:45  10/08/2009 00:30  14/08/2009 14:52  24/09/2009 12:19
> >> > 25/10/2009 12:45  07/11/2009 14:07  17/10/2009 10:51  07/11/2009 15:54
> >> > 01/11/2009 19:21  01/11/2009 12:23  02/10/2009 21:25  30/11/2009 11:40
> >> > 26/10/2009 13:21  23/08/2009 13:28  19/12/2009 10:54  09/08/2009 22:45
> >> >  12/09/2009
> >> > 09:39  11/10/2009 11:28  13/08/2009 16:15  10/09/2009 11:01
>  21/08/2009
> >> > 10:55  30/11/2009 10:03  26/10/2009 17:08  03/10/2009 12:45
> >> >
> >> > y=
> >> >  4.2537264  4.397792  4.5570224  4.284056  3.9959248  4.2992208
> >> > 4.2916384
> >> > 4.4053744  4.2992208  4.1399904  4.4053744  4.4432864  4.321968
> >> > 4.0414192
> >> > 4.5418576  4.321968  4.5949344  4.1475728  4.8679008  4.587352
> >> > 4.1627376
> >> > 4.132408  4.1551552  4.2537264  4.5191104  4.0717488  4.3750448
> >> > 4.4053744
> >> > Thanks
> >> > --
> >> > Shane
> >> >
> >>
> >> --
> >> Sarah Goslee
> >> http://www.functionaldiversity.org
> >
> >
> >
> >
> > --
> > Shane
>



-- 
Shane

    [[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minim

Re: [R] R not ploting lines in the correct order

2013-09-27 Thread Shane Carey
Your a starbar, exactly what Im looking for.

Thanks a mill!!


On Fri, Sep 27, 2013 at 3:26 PM, PIKAL Petr  wrote:

> OK
>
> > -Original Message-
> > From: r-help-boun...@r-project.org [mailto:r-help-bounces@r-
> > project.org] On Behalf Of Shane Carey
> > Sent: Friday, September 27, 2013 4:06 PM
> > To: Sarah Goslee
> > Cc: r-help@r-project.org
> > Subject: Re: [R] R not ploting lines in the correct order
> >
> > Ah ok, Here we go:
> >
> > structure(list(DATE = structure(c(1348477980, 1350386220, 1351114980,
> > 1347388440, 1345650300, 1344558600, 1344955920, 1348489140, 1351169100,
> > 1352297220, 1350471060, 1352303640, 1351797660, 1351772580, 1349213100,
> > 1354275600, 1351257660, 1345728480, 1355914440, 1344552300, 1347442740,
> > 1349954880, 1344874500, 1347274860, 1345546500, 1354269780, 1351271280,
> > 1349268300), class = c("POSIXct", "POSIXt"), tzone = "GMT"),
> > DATA = c(5.61, 5.8, 6.01, 5.65, 5.27, 5.67, 5.66, 5.81, 5.67,
> > 5.46, 5.81, 5.86, 5.7, 5.33, 5.99, 5.7, 6.06, 5.47, 6.42,
> > 6.05, 5.49, 5.45, 5.48, 5.61, 5.96, 5.37, 5.77, 5.81)), .Names =
> > c("DATE",
> > "DATA"), row.names = c(NA, -28L), class = "data.frame")
> >
> > The wrong points are being joined by lines. If I use qplot from the
> > ggplot2
> > library it plots fine, but I want to use plot as it is easier to
> > customise.
>
> Well, it is a matter of taste, ggplots are maybe more complicated but they
> allow you to do fairly broader customisation quite easily if you find how.
>
> Now you shall tell us what is your plotting command.
>
> this can not work as you are plotting X and Y objects
> > > > plot(X$Data,Y$Date,yaxt="n", xaxt="n",type="o")
> > > > lines(X$Data,Y$Date,pch=21, col="blue",type="o")
>
> If I name your data frame to data and change plotting commands to
>
> plot(data$DATA,data$DATE,yaxt="n", xaxt="n",type="o")
> lines(data$DATA,data$DATE,pch=21, col="blue",type="o")
>
> I get some mess due to the fact that DATE is not sorted (and I believe
> that your intention is to have date values on x axis).
>
> so making your data.frame ordered
>
> ooo<-order(data$DATE)
> data.o<-data[ooo,]
> plot(data.o$DATE,data.o$DATA,yaxt="n", xaxt="n",type="o")
> lines(data.o$DATE,data.o$DATA,pch=21, col="blue",type="o")
>
> gives me quite reasonable result.
>
> Regards
> Petr
>
>
> >
> > Thanks again.
> >
> >
> > On Fri, Sep 27, 2013 at 2:36 PM, Sarah Goslee
> > wrote:
> >
> > > If you use dput() correctly, those of us following along via email
> > can
> > > create an exact duplicate of your R object. All you need to do is:
> > > dput(X)
> > > and paste the resulting output into email.
> > >
> > > You see, if I look at your object as you pasted it in, I can't tell
> > if
> > > your Date column is a date format, or character, or factor, or who
> > > knows what, and that may matter for answering your question.
> > >
> > > Also, what are "the wrong points"? What points do you expect to be
> > > connected?
> > >
> > > Sarah
> > >
> > >
> > > On Fri, Sep 27, 2013 at 8:13 AM, Shane Carey 
> > wrote:
> > > > Hi Sarah,
> > > >
> > > > thanks for your reply. Im not sure how to use dput? If I create an
> > > object of
> > > > my data, does that mean you can read it in from your side or
> > something?
> > > >
> > > > Here is my code:
> > > > X
> > > > Data Date
> > > > 5.61 24/09/2012 09:13
> > > > 5.80 16/10/2012 11:17
> > > > 6.01 24/10/2012 21:43
> > > > 5.65 11/09/2012 18:34
> > > > 5.27 22/08/2012 15:45
> > > > 5.67 10/08/2012 00:30
> > > > 5.66 14/08/2012 14:52
> > > > 5.81 24/09/2012 12:19
> > > > 5.67 25/10/2012 12:45
> > > > 5.46 07/11/2012 14:07
> > > > 5.81 17/10/2012 10:51
> > > > 5.86 07/11/2012 15:54
> > > > 5.70 01/11/2012 19:21
> > > > 5.33 01/11/2012 12:23
> > > > 5.99 02/10/2012 21:25
> > > > 5.70 30/11/2012 11:40
> > > > 6.06 26/10/2012 13:21
> > > > 5.47 23/08/2012 13:28
> > > > 6.42 19/12/2012 10:54
> > > > 6.05 09/08/2012 22:45
> > > > 5.49 12/09/2012 09:39
> > > > 5.45 11/10/2012 11:28
> > > > 5.48 13/08/2012 16:15
> > > > 5.61 10/09/2012 11:01
> > > > 5.96 21/08/2012 10:55
> > > > 5.37 30/11/2012 10:03
> > > > 5.77 26/10/2012 17:08
> > > > 5.81 03/10/2012 12:45
> > > > dput(X, "X")
> > > > plot(X$Data,Y$Date,yaxt="n", xaxt="n",type="o")
> > > > lines(X$Data,Y$Date,pch=21, col="blue",type="o")
> > > >
> > > >
> > > > Thanks again
> > > >
> > > >
> > > > On Thu, Sep 26, 2013 at 7:23 PM, Sarah Goslee
> > 
> > > > wrote:
> > > >>
> > > >> Hi Shane,
> > > >>
> > > >> Please use dput() to provide your data, rather than pasting it in
> > so
> > > >> that we can work from the same R object you are. Please also
> > provide
> > > >> the code you're using to make the graph.
> > > >>
> > > >> Sarah
> > > >>
> > > >> On Thu, Sep 26, 2013 at 1:56 PM, Shane Carey 
> > > wrote:
> > > >> > Hi,
> > > >> >
> > > >> > I have a set of x, y points where x represents dates and y
> > actual
> > > >> > values. I
> > > >> > am trying to plot a line graph of the data with points on top,
> > but R
> > > is
> > > >> > 

Re: [R] R not ploting lines in the correct order

2013-09-27 Thread PIKAL Petr
OK

> -Original Message-
> From: r-help-boun...@r-project.org [mailto:r-help-bounces@r-
> project.org] On Behalf Of Shane Carey
> Sent: Friday, September 27, 2013 4:06 PM
> To: Sarah Goslee
> Cc: r-help@r-project.org
> Subject: Re: [R] R not ploting lines in the correct order
> 
> Ah ok, Here we go:
> 
> structure(list(DATE = structure(c(1348477980, 1350386220, 1351114980,
> 1347388440, 1345650300, 1344558600, 1344955920, 1348489140, 1351169100,
> 1352297220, 1350471060, 1352303640, 1351797660, 1351772580, 1349213100,
> 1354275600, 1351257660, 1345728480, 1355914440, 1344552300, 1347442740,
> 1349954880, 1344874500, 1347274860, 1345546500, 1354269780, 1351271280,
> 1349268300), class = c("POSIXct", "POSIXt"), tzone = "GMT"),
> DATA = c(5.61, 5.8, 6.01, 5.65, 5.27, 5.67, 5.66, 5.81, 5.67,
> 5.46, 5.81, 5.86, 5.7, 5.33, 5.99, 5.7, 6.06, 5.47, 6.42,
> 6.05, 5.49, 5.45, 5.48, 5.61, 5.96, 5.37, 5.77, 5.81)), .Names =
> c("DATE",
> "DATA"), row.names = c(NA, -28L), class = "data.frame")
> 
> The wrong points are being joined by lines. If I use qplot from the
> ggplot2
> library it plots fine, but I want to use plot as it is easier to
> customise.

Well, it is a matter of taste, ggplots are maybe more complicated but they 
allow you to do fairly broader customisation quite easily if you find how.

Now you shall tell us what is your plotting command.

this can not work as you are plotting X and Y objects
> > > plot(X$Data,Y$Date,yaxt="n", xaxt="n",type="o")
> > > lines(X$Data,Y$Date,pch=21, col="blue",type="o")

If I name your data frame to data and change plotting commands to 

plot(data$DATA,data$DATE,yaxt="n", xaxt="n",type="o")
lines(data$DATA,data$DATE,pch=21, col="blue",type="o")

I get some mess due to the fact that DATE is not sorted (and I believe that 
your intention is to have date values on x axis).

so making your data.frame ordered

ooo<-order(data$DATE)
data.o<-data[ooo,]
plot(data.o$DATE,data.o$DATA,yaxt="n", xaxt="n",type="o")
lines(data.o$DATE,data.o$DATA,pch=21, col="blue",type="o")

gives me quite reasonable result.

Regards
Petr


> 
> Thanks again.
> 
> 
> On Fri, Sep 27, 2013 at 2:36 PM, Sarah Goslee
> wrote:
> 
> > If you use dput() correctly, those of us following along via email
> can
> > create an exact duplicate of your R object. All you need to do is:
> > dput(X)
> > and paste the resulting output into email.
> >
> > You see, if I look at your object as you pasted it in, I can't tell
> if
> > your Date column is a date format, or character, or factor, or who
> > knows what, and that may matter for answering your question.
> >
> > Also, what are "the wrong points"? What points do you expect to be
> > connected?
> >
> > Sarah
> >
> >
> > On Fri, Sep 27, 2013 at 8:13 AM, Shane Carey 
> wrote:
> > > Hi Sarah,
> > >
> > > thanks for your reply. Im not sure how to use dput? If I create an
> > object of
> > > my data, does that mean you can read it in from your side or
> something?
> > >
> > > Here is my code:
> > > X
> > > Data Date
> > > 5.61 24/09/2012 09:13
> > > 5.80 16/10/2012 11:17
> > > 6.01 24/10/2012 21:43
> > > 5.65 11/09/2012 18:34
> > > 5.27 22/08/2012 15:45
> > > 5.67 10/08/2012 00:30
> > > 5.66 14/08/2012 14:52
> > > 5.81 24/09/2012 12:19
> > > 5.67 25/10/2012 12:45
> > > 5.46 07/11/2012 14:07
> > > 5.81 17/10/2012 10:51
> > > 5.86 07/11/2012 15:54
> > > 5.70 01/11/2012 19:21
> > > 5.33 01/11/2012 12:23
> > > 5.99 02/10/2012 21:25
> > > 5.70 30/11/2012 11:40
> > > 6.06 26/10/2012 13:21
> > > 5.47 23/08/2012 13:28
> > > 6.42 19/12/2012 10:54
> > > 6.05 09/08/2012 22:45
> > > 5.49 12/09/2012 09:39
> > > 5.45 11/10/2012 11:28
> > > 5.48 13/08/2012 16:15
> > > 5.61 10/09/2012 11:01
> > > 5.96 21/08/2012 10:55
> > > 5.37 30/11/2012 10:03
> > > 5.77 26/10/2012 17:08
> > > 5.81 03/10/2012 12:45
> > > dput(X, "X")
> > > plot(X$Data,Y$Date,yaxt="n", xaxt="n",type="o")
> > > lines(X$Data,Y$Date,pch=21, col="blue",type="o")
> > >
> > >
> > > Thanks again
> > >
> > >
> > > On Thu, Sep 26, 2013 at 7:23 PM, Sarah Goslee
> 
> > > wrote:
> > >>
> > >> Hi Shane,
> > >>
> > >> Please use dput() to provide your data, rather than pasting it in
> so
> > >> that we can work from the same R object you are. Please also
> provide
> > >> the code you're using to make the graph.
> > >>
> > >> Sarah
> > >>
> > >> On Thu, Sep 26, 2013 at 1:56 PM, Shane Carey 
> > wrote:
> > >> > Hi,
> > >> >
> > >> > I have a set of x, y points where x represents dates and y
> actual
> > >> > values. I
> > >> > am trying to plot a line graph of the data with points on top,
> but R
> > is
> > >> > connecting the wrong points with lines. Does anyone know how I
> can
> > >> > rectify
> > >> > this. Please see sample below:
> > >> >
> > >> > x=
> > >> >  24/09/2009 09:13  16/10/2009 11:17  24/10/2009 21:43
> 11/09/2009
> > >> > 18:34  22/08/2009
> > >> > 15:45  10/08/2009 00:30  14/08/2009 14:52  24/09/2009 12:19
> > >> > 25/10/2009 12:45  07/11/2009 14:07  17/10/2009 10:51  07/11/2009
> 15:54
> > >

Re: [R] Some issues with operations

2013-09-27 Thread arun
HI Vivek,

I think there is only one row in the whole dataset which fulfills the 
condition.  If you need the dimension intact, use 'drop=FALSE'


 which(rowSums(mat1>0)==ncol(mat1))
#CXCL14 
 # 2349 


#Simplied some codes:

dat1<- 
read.table("FPKM_RZvsRP_expmat2_v3.txt",sep="\t",header=TRUE,stringsAsFactors=FALSE)

dat2<- dat1

dat2[,13:22]<-lapply(list(c(2,3),c(4,7),c(4,8),c(5,7),c(5,8),c(6,7),c(6,8),c(9,12),c(10,12),c(11,12)),function(x)
 {dat2[,x[1]] - dat2[,x[2]]} )
 
colnames(dat2)[13:22]<-gsub("__","_",paste(c("p118",paste(rep("p132",6),c("",1:5),sep="_"),paste(rep("p91",3),c("",1:2),sep="_")),"diff",sep="_"))
mat1<- as.matrix(dat2[,13:22])
row.names(mat1)<- dat2[,1]
 res<-mat1[rowSums(mat1>0)==ncol(mat1),,drop=FALSE]

res
#   p118_diff p132_diff p132_1_diff p132_2_diff p132_3_diff p132_4_diff
#CXCL14  3.606171  1.241455    2.023101    1.413141    2.194787   0.5763301
 #  p132_5_diff p91_diff p91_1_diff p91_2_diff
#CXCL14    1.357977 3.485148   8.938696    6.29492
dim(res)
#[1]  1 10


A.K.


From: Vivek Das 
To: arun  
Sent: Friday, September 27, 2013 5:36 AM
Subject: Some issues with operations



HI Arun,
I am facing some issues with the matrix operation in R. I am having a matrix  
with some genes and their corresponding expression values between samples. I am 
trying to see the the difference in expression values of the columns. Then 
making a matrix which will contain the whole data and its corresponding 
differences. Then am extracting only the difference of the columns I computed 
in a matrix and trying to separate the positive and the negative differences. I 
have worked with this earlier and I have not faced any issue. I have also 
applied it to other samples and they work perfectly fine. But I donot know this 
time its failing. I tried with other matrix I performed earlier and still they 
work. Somewhere here it does not. Can you please let me know where I am getting 
wrong ? I am sending you the code snippet and the matrix so that it makes sense 
to you.

Code:

# to check the transition from RZ to RP - 91 rz,118rz, 132rz1,132rz2 Vs 
91rp1, 91rp3, 91rp4, 118rp3,132rp1, 132rp3, 132rp4

data<-read.table("",sep='\t', header=T)

#calculate differences

p118_diff<-c(as.numeric(data[,2])-as.numeric(data[,3]))
p132_diff<-c(as.numeric(data[,4])-as.numeric(data[,7]))
p132_1_diff<-c(as.numeric(data[,4])-as.numeric(data[,8]))
p132_2_diff<-c(as.numeric(data[,5])-as.numeric(data[,7]))
p132_3_diff<-c(as.numeric(data[,5])-as.numeric(data[,8]))
p132_4_diff<-c(as.numeric(data[,6])-as.numeric(data[,7]))
p132_5_diff<-c(as.numeric(data[,6])-as.numeric(data[,8]))
p91_diff<-c(as.numeric(data[,9])-as.numeric(data[,12]))
p91_1_diff<-c(as.numeric(data[,10])-as.numeric(data[,12]))
p91_2_diff<-c(as.numeric(data[,11])-as.numeric(data[,12]))

diff_m<-cbind(data,p118_diff,p132_diff,p132_1_diff,p132_2_diff,p132_3_diff,p132_4_diff,p132_5_diff,p91_diff,p91_1_diff,p91_2_diff)

##select all the positive differences

mat1<- as.matrix(diff_m[,13:22])
row.names(mat1)<- diff_m[,1]

res1<-mat1[rowSums(mat1>0)==ncol(mat1),]
head(res1)

In the above rest computation it is failing. as it cant give correct dimension 
for res1. I only get one row with 1 columns which should not be the idea case. 
I should get all the positive differences across all samples from the mat1 
matrix. Can you please guide me where I am getting wrong? I am also attaching 
the matrix so that it works for you and you can understand where I am getting 
wrong.


--

Vivek Das
PhD Student in Computational Biology
Giuseppe Testa's Lab
European School of Molecular Medicine
IFOM-IEO Campus
Via Adamello, 16
Milan, Italy

emails: vivek@ieo.eu
            vchris...@yahoo.co.in
            vd4mm...@gmail.com

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] R not ploting lines in the correct order

2013-09-27 Thread Shane Carey
Ah ok, Here we go:

structure(list(DATE = structure(c(1348477980, 1350386220, 1351114980,
1347388440, 1345650300, 1344558600, 1344955920, 1348489140, 1351169100,
1352297220, 1350471060, 1352303640, 1351797660, 1351772580, 1349213100,
1354275600, 1351257660, 1345728480, 1355914440, 1344552300, 1347442740,
1349954880, 1344874500, 1347274860, 1345546500, 1354269780, 1351271280,
1349268300), class = c("POSIXct", "POSIXt"), tzone = "GMT"),
DATA = c(5.61, 5.8, 6.01, 5.65, 5.27, 5.67, 5.66, 5.81, 5.67,
5.46, 5.81, 5.86, 5.7, 5.33, 5.99, 5.7, 6.06, 5.47, 6.42,
6.05, 5.49, 5.45, 5.48, 5.61, 5.96, 5.37, 5.77, 5.81)), .Names =
c("DATE",
"DATA"), row.names = c(NA, -28L), class = "data.frame")

The wrong points are being joined by lines. If I use qplot from the ggplot2
library it plots fine, but I want to use plot as it is easier to customise.

Thanks again.


On Fri, Sep 27, 2013 at 2:36 PM, Sarah Goslee wrote:

> If you use dput() correctly, those of us following along via email can
> create an exact duplicate of your R object. All you need to do is:
> dput(X)
> and paste the resulting output into email.
>
> You see, if I look at your object as you pasted it in, I can't tell if
> your Date column is a date format, or character, or factor, or who
> knows what, and that may matter for answering your question.
>
> Also, what are "the wrong points"? What points do you expect to be
> connected?
>
> Sarah
>
>
> On Fri, Sep 27, 2013 at 8:13 AM, Shane Carey  wrote:
> > Hi Sarah,
> >
> > thanks for your reply. Im not sure how to use dput? If I create an
> object of
> > my data, does that mean you can read it in from your side or something?
> >
> > Here is my code:
> > X
> > Data Date
> > 5.61 24/09/2012 09:13
> > 5.80 16/10/2012 11:17
> > 6.01 24/10/2012 21:43
> > 5.65 11/09/2012 18:34
> > 5.27 22/08/2012 15:45
> > 5.67 10/08/2012 00:30
> > 5.66 14/08/2012 14:52
> > 5.81 24/09/2012 12:19
> > 5.67 25/10/2012 12:45
> > 5.46 07/11/2012 14:07
> > 5.81 17/10/2012 10:51
> > 5.86 07/11/2012 15:54
> > 5.70 01/11/2012 19:21
> > 5.33 01/11/2012 12:23
> > 5.99 02/10/2012 21:25
> > 5.70 30/11/2012 11:40
> > 6.06 26/10/2012 13:21
> > 5.47 23/08/2012 13:28
> > 6.42 19/12/2012 10:54
> > 6.05 09/08/2012 22:45
> > 5.49 12/09/2012 09:39
> > 5.45 11/10/2012 11:28
> > 5.48 13/08/2012 16:15
> > 5.61 10/09/2012 11:01
> > 5.96 21/08/2012 10:55
> > 5.37 30/11/2012 10:03
> > 5.77 26/10/2012 17:08
> > 5.81 03/10/2012 12:45
> > dput(X, "X")
> > plot(X$Data,Y$Date,yaxt="n", xaxt="n",type="o")
> > lines(X$Data,Y$Date,pch=21, col="blue",type="o")
> >
> >
> > Thanks again
> >
> >
> > On Thu, Sep 26, 2013 at 7:23 PM, Sarah Goslee 
> > wrote:
> >>
> >> Hi Shane,
> >>
> >> Please use dput() to provide your data, rather than pasting it in so
> >> that we can work from the same R object you are. Please also provide
> >> the code you're using to make the graph.
> >>
> >> Sarah
> >>
> >> On Thu, Sep 26, 2013 at 1:56 PM, Shane Carey 
> wrote:
> >> > Hi,
> >> >
> >> > I have a set of x, y points where x represents dates and y actual
> >> > values. I
> >> > am trying to plot a line graph of the data with points on top, but R
> is
> >> > connecting the wrong points with lines. Does anyone know how I can
> >> > rectify
> >> > this. Please see sample below:
> >> >
> >> > x=
> >> >  24/09/2009 09:13  16/10/2009 11:17  24/10/2009 21:43  11/09/2009
> >> > 18:34  22/08/2009
> >> > 15:45  10/08/2009 00:30  14/08/2009 14:52  24/09/2009 12:19
> >> > 25/10/2009 12:45  07/11/2009 14:07  17/10/2009 10:51  07/11/2009 15:54
> >> > 01/11/2009 19:21  01/11/2009 12:23  02/10/2009 21:25  30/11/2009 11:40
> >> > 26/10/2009 13:21  23/08/2009 13:28  19/12/2009 10:54  09/08/2009 22:45
> >> >  12/09/2009
> >> > 09:39  11/10/2009 11:28  13/08/2009 16:15  10/09/2009 11:01
>  21/08/2009
> >> > 10:55  30/11/2009 10:03  26/10/2009 17:08  03/10/2009 12:45
> >> >
> >> > y=
> >> >  4.2537264  4.397792  4.5570224  4.284056  3.9959248  4.2992208
> >> > 4.2916384
> >> > 4.4053744  4.2992208  4.1399904  4.4053744  4.4432864  4.321968
> >> > 4.0414192
> >> > 4.5418576  4.321968  4.5949344  4.1475728  4.8679008  4.587352
> >> > 4.1627376
> >> > 4.132408  4.1551552  4.2537264  4.5191104  4.0717488  4.3750448
> >> > 4.4053744
> >> > Thanks
> >> > --
> >> > Shane
> >> >
> >>
> >> --
> >> Sarah Goslee
> >> http://www.functionaldiversity.org
> >
> >
> >
> >
> > --
> > Shane
>



-- 
Shane

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Best and Worst values

2013-09-27 Thread arun





Ira,
obj_name<- load("arun.RData")
Pred1<- get(obj_name[1])
Actual1<- get(obj_name[2])

dat2<- 
data.frame(S1=rep(Pred1[,1],ncol(Pred1)-1),variable=rep(colnames(Pred1)[-1],each=nrow(Pred1)),Predict=unlist(Pred1[,-1],use.names=FALSE),Actual=unlist(Actual1[,-1],use.names=FALSE),stringsAsFactors=FALSE)

dat2New<- dat2[!(is.na(dat2$Predict)|is.na(dat2$Actual)),]
 dat3<- dat2New[order(dat2New$S1,dat2New$Predict),]

library(plyr)

resLow<-ddply(dat3,.(S1),summarize, cbind(head(Predict,5),head(Actual,5)))
resHigh<-ddply(dat3,.(S1),summarize, 
cbind(head(rev(Predict),5),head(rev(Actual),5)))
 
resLow1<-data.frame(Date=resLow[,1],Predict=resLow[,2][,1],Actual=resLow[,2][,2])
 
resHigh1<-data.frame(Date=resHigh[,1],Predict=resHigh[,2][,1],Actual=resHigh[,2][,2])
 resHigh1$id<- 1:nrow(resHigh1)
 resLow1$id<- 1:nrow(resLow1)
resLow2<-resLow1[!resLow1[,2]>=0,]
resHigh2<- resHigh1[resHigh1[,2]>0,]
resFinal<- merge(resLow2,resHigh2,by=c("Date","id"),all=TRUE) 


resNew<- as.data.frame(matrix(0,nrow(resFinal)*2,3))
resNew[,1]<-rep(resFinal$Date,each=2)

###indexing is not that important here.  You can just ?melt() or ?reshape() 
from wide to long format and when you try ddply(), it will automatically 
arrange the data #accordingly. 


indx<-cbind(rep(seq_len(nrow(resFinal)),2),rep(c(5,3),each=250))  ## 5,3 
represents the column numbers Predict in resFinal
indx2<-c(rep(seq(1,100,by=2),each=5),rep(seq(2,100,by=2),each=5))
indx3<- indx[order(indx2),]
resNew[,2]<-as.numeric(resFinal[indx3])

indx1<-cbind(rep(seq_len(nrow(resFinal)),2),rep(c(6,4),each=250)) #6,4 
represent the columns Actual in resFinal
indx4<- indx1[order(indx2),]
resNew[,3]<-as.numeric(resFinal[indx4])
colnames(resNew)<- c("Date","Predict","Actual")


CorRes<-ddply(resNew,.(Date),summarize,Correl=cor(Predict,Actual,use="complete.obs"))

 head(CorRes)
#    Date    Correl
#1 2006-01-03 0.7079585
#2 2006-01-04 0.6537652
#3 2006-01-05 0.6397637
#4 2006-01-06 0.7448979
#5 2006-01-09 0.7325796
#6 2006-01-10 0.6283132




Arun


From: Ira Sharenow 
To: arun  
Sent: Thursday, September 26, 2013 11:22 PM
Subject: Re: Update, September 26, 2013



Arun,


I may want to separate the longs and do a correlation and separate the shorts 
and do a correlation, but the more likely scenario is to have the (possibly) 10 
pairs of values per day all as part of a single correlation.

Thanks.

Ira

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] R not ploting lines in the correct order

2013-09-27 Thread Sarah Goslee
If you use dput() correctly, those of us following along via email can
create an exact duplicate of your R object. All you need to do is:
dput(X)
and paste the resulting output into email.

You see, if I look at your object as you pasted it in, I can't tell if
your Date column is a date format, or character, or factor, or who
knows what, and that may matter for answering your question.

Also, what are "the wrong points"? What points do you expect to be connected?

Sarah


On Fri, Sep 27, 2013 at 8:13 AM, Shane Carey  wrote:
> Hi Sarah,
>
> thanks for your reply. Im not sure how to use dput? If I create an object of
> my data, does that mean you can read it in from your side or something?
>
> Here is my code:
> X
> Data Date
> 5.61 24/09/2012 09:13
> 5.80 16/10/2012 11:17
> 6.01 24/10/2012 21:43
> 5.65 11/09/2012 18:34
> 5.27 22/08/2012 15:45
> 5.67 10/08/2012 00:30
> 5.66 14/08/2012 14:52
> 5.81 24/09/2012 12:19
> 5.67 25/10/2012 12:45
> 5.46 07/11/2012 14:07
> 5.81 17/10/2012 10:51
> 5.86 07/11/2012 15:54
> 5.70 01/11/2012 19:21
> 5.33 01/11/2012 12:23
> 5.99 02/10/2012 21:25
> 5.70 30/11/2012 11:40
> 6.06 26/10/2012 13:21
> 5.47 23/08/2012 13:28
> 6.42 19/12/2012 10:54
> 6.05 09/08/2012 22:45
> 5.49 12/09/2012 09:39
> 5.45 11/10/2012 11:28
> 5.48 13/08/2012 16:15
> 5.61 10/09/2012 11:01
> 5.96 21/08/2012 10:55
> 5.37 30/11/2012 10:03
> 5.77 26/10/2012 17:08
> 5.81 03/10/2012 12:45
> dput(X, "X")
> plot(X$Data,Y$Date,yaxt="n", xaxt="n",type="o")
> lines(X$Data,Y$Date,pch=21, col="blue",type="o")
>
>
> Thanks again
>
>
> On Thu, Sep 26, 2013 at 7:23 PM, Sarah Goslee 
> wrote:
>>
>> Hi Shane,
>>
>> Please use dput() to provide your data, rather than pasting it in so
>> that we can work from the same R object you are. Please also provide
>> the code you're using to make the graph.
>>
>> Sarah
>>
>> On Thu, Sep 26, 2013 at 1:56 PM, Shane Carey  wrote:
>> > Hi,
>> >
>> > I have a set of x, y points where x represents dates and y actual
>> > values. I
>> > am trying to plot a line graph of the data with points on top, but R is
>> > connecting the wrong points with lines. Does anyone know how I can
>> > rectify
>> > this. Please see sample below:
>> >
>> > x=
>> >  24/09/2009 09:13  16/10/2009 11:17  24/10/2009 21:43  11/09/2009
>> > 18:34  22/08/2009
>> > 15:45  10/08/2009 00:30  14/08/2009 14:52  24/09/2009 12:19
>> > 25/10/2009 12:45  07/11/2009 14:07  17/10/2009 10:51  07/11/2009 15:54
>> > 01/11/2009 19:21  01/11/2009 12:23  02/10/2009 21:25  30/11/2009 11:40
>> > 26/10/2009 13:21  23/08/2009 13:28  19/12/2009 10:54  09/08/2009 22:45
>> >  12/09/2009
>> > 09:39  11/10/2009 11:28  13/08/2009 16:15  10/09/2009 11:01  21/08/2009
>> > 10:55  30/11/2009 10:03  26/10/2009 17:08  03/10/2009 12:45
>> >
>> > y=
>> >  4.2537264  4.397792  4.5570224  4.284056  3.9959248  4.2992208
>> > 4.2916384
>> > 4.4053744  4.2992208  4.1399904  4.4053744  4.4432864  4.321968
>> > 4.0414192
>> > 4.5418576  4.321968  4.5949344  4.1475728  4.8679008  4.587352
>> > 4.1627376
>> > 4.132408  4.1551552  4.2537264  4.5191104  4.0717488  4.3750448
>> > 4.4053744
>> > Thanks
>> > --
>> > Shane
>> >
>>
>> --
>> Sarah Goslee
>> http://www.functionaldiversity.org
>
>
>
>
> --
> Shane

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] R not ploting lines in the correct order

2013-09-27 Thread PIKAL Petr
Hm

It seems to me that you want to plot some values from two objects X and Y.

you shall at least show us output of

str(X) and str(Y)

but posting result of

dput(X) and dput(Y)

gives us an opportunity to test what objects you have and what you actually do 
with them.

Just a guess. You think that your x values are dates but they actually are not, 
they only pretend to be.

Petr


> -Original Message-
> From: r-help-boun...@r-project.org [mailto:r-help-bounces@r-
> project.org] On Behalf Of Shane Carey
> Sent: Friday, September 27, 2013 2:14 PM
> To: Sarah Goslee
> Cc: r-help@r-project.org
> Subject: Re: [R] R not ploting lines in the correct order
> 
> Hi Sarah,
> 
> thanks for your reply. Im not sure how to use dput? If I create an
> object
> of my data, does that mean you can read it in from your side or
> something?
> 
> Here is my code:
> X
> Data Date
> 5.61 24/09/2012 09:13
> 5.80 16/10/2012 11:17
> 6.01 24/10/2012 21:43
> 5.65 11/09/2012 18:34
> 5.27 22/08/2012 15:45
> 5.67 10/08/2012 00:30
> 5.66 14/08/2012 14:52
> 5.81 24/09/2012 12:19
> 5.67 25/10/2012 12:45
> 5.46 07/11/2012 14:07
> 5.81 17/10/2012 10:51
> 5.86 07/11/2012 15:54
> 5.70 01/11/2012 19:21
> 5.33 01/11/2012 12:23
> 5.99 02/10/2012 21:25
> 5.70 30/11/2012 11:40
> 6.06 26/10/2012 13:21
> 5.47 23/08/2012 13:28
> 6.42 19/12/2012 10:54
> 6.05 09/08/2012 22:45
> 5.49 12/09/2012 09:39
> 5.45 11/10/2012 11:28
> 5.48 13/08/2012 16:15
> 5.61 10/09/2012 11:01
> 5.96 21/08/2012 10:55
> 5.37 30/11/2012 10:03
> 5.77 26/10/2012 17:08
> 5.81 03/10/2012 12:45
> dput(X, "X")
> plot(X$Data,Y$Date,yaxt="n", xaxt="n",type="o")
> lines(X$Data,Y$Date,pch=21, col="blue",type="o")
> 
> 
> Thanks again
> 
> 
> On Thu, Sep 26, 2013 at 7:23 PM, Sarah Goslee
> wrote:
> 
> > Hi Shane,
> >
> > Please use dput() to provide your data, rather than pasting it in so
> > that we can work from the same R object you are. Please also provide
> > the code you're using to make the graph.
> >
> > Sarah
> >
> > On Thu, Sep 26, 2013 at 1:56 PM, Shane Carey 
> wrote:
> > > Hi,
> > >
> > > I have a set of x, y points where x represents dates and y actual
> > values. I
> > > am trying to plot a line graph of the data with points on top, but
> R is
> > > connecting the wrong points with lines. Does anyone know how I can
> > rectify
> > > this. Please see sample below:
> > >
> > > x=
> > >  24/09/2009 09:13  16/10/2009 11:17  24/10/2009 21:43  11/09/2009
> > > 18:34  22/08/2009
> > > 15:45  10/08/2009 00:30  14/08/2009 14:52  24/09/2009 12:19
> > > 25/10/2009 12:45  07/11/2009 14:07  17/10/2009 10:51  07/11/2009
> 15:54
> > > 01/11/2009 19:21  01/11/2009 12:23  02/10/2009 21:25  30/11/2009
> 11:40
> > > 26/10/2009 13:21  23/08/2009 13:28  19/12/2009 10:54  09/08/2009
> 22:45
> > >  12/09/2009
> > > 09:39  11/10/2009 11:28  13/08/2009 16:15  10/09/2009 11:01
> 21/08/2009
> > > 10:55  30/11/2009 10:03  26/10/2009 17:08  03/10/2009 12:45
> > >
> > > y=
> > >  4.2537264  4.397792  4.5570224  4.284056  3.9959248  4.2992208
> >  4.2916384
> > > 4.4053744  4.2992208  4.1399904  4.4053744  4.4432864  4.321968
> >  4.0414192
> > > 4.5418576  4.321968  4.5949344  4.1475728  4.8679008  4.587352
> 4.1627376
> > > 4.132408  4.1551552  4.2537264  4.5191104  4.0717488  4.3750448
> >  4.4053744
> > > Thanks
> > > --
> > > Shane
> > >
> >
> > --
> > Sarah Goslee
> > http://www.functionaldiversity.org
> >
> 
> 
> 
> --
> Shane
> 
>   [[alternative HTML version deleted]]
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-
> guide.html
> and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Compare species presence and absence between sites

2013-09-27 Thread arun
Just to add:

If you wanted the difference of every combination of rows:
set.seed(248)
 mat1<- 
matrix(sample(0:1,5*100,replace=TRUE),ncol=100,dimnames=list(LETTERS[1:5],paste0("D",sprintf("%03d",1:100)))
 )
 dat<-expand.grid(LETTERS[1:5],LETTERS[1:5],stringsAsFactors=FALSE)
dat1<-dat[!paste0(dat[,1],dat[,2]) %in% paste0(LETTERS[1:5],LETTERS[1:5]),]
 lst1<- lapply(seq_len(nrow(dat1)),function(i) {x<-mat1[unlist(dat1[i,]),]; 
which(different(x[1,],x[2,]))}) #using Rui's function
names(lst1)<- paste(dat1[,1],dat1[,2],sep="_")


A.K.



- Original Message -
From: Rui Barradas 
To: Elaine Kuo 
Cc: "r-help@r-project.org" 
Sent: Friday, September 27, 2013 7:39 AM
Subject: Re: [R] Compare species presence and absence between sites

Hello,

Something like this?


different <- function(x, y) x == 1 & y == 0

set.seed(7054)
mat <- matrix(sample(0:1, 500, TRUE), nrow = 5)
rownames(mat) <- LETTERS[1:5]
colnames(mat) <- sprintf("D%03d", 1:100)

different(mat["B",], mat["E",])



Hope this helps,

Rui Barradas

Em 27-09-2013 11:48, Elaine Kuo escreveu:
> Dear List,
>
>
>
> I want to compare the presence and absence of bird species based on the
> sites in a matrix.
>
> The matrix has 5 rows for Island A, B, C, D, and E.
>
> It has 100 columns for bird species D001-D100.
>
> In each cell of the matrix,
>
> the presence-absence of bird species will be recorded as 1 or 0.
>
> (For example, if species D001 is found on Island D,
>
> the matrix cell of species D001 and Island D will be 1.)
>
>
>
> Now I want to know the different bird species between Island B and E.
>
> In other words, I would like to find out bird species present (1) on Island
> B but absent (0)on island E, and vice versa (absent (0) on Island B but
> present (1)on island E).
>
>
>
> Please kindly advise how to code the purpose above.
>
> Thank you in advance.
>
>
>
> Elaine
>
>     [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Locating inefficient code

2013-09-27 Thread arun
Hi,
Please use ?dput()
dat1<- structure(list(Proto = c("tcp", "tcp", "tcp", "tcp", "tcp", "tcp"
), `Recv-Q` = c(0L, 0L, 0L, 0L, 0L, 0L), `Send-Q` = c(0L, 0L, 
0L, 0L, 0L, 0L), `Local-Address` = c("172.20.100.2:60255", 
"172.20.100.2:60247", 
":::172.20.100.2:80", ":::172.20.100.2:80", ":::172.20.100.2:80", 
":::172.20.100.2:80"), `Foreign-Address` = c("172.20.100.3:8209", 
"172.20.100.3:8209", ":::10.1.5.7:3185", ":::10.5.1.3:3189", 
":::10.5.5.7:3445", ":::10.3.29.3:2671"), State = c("ESTABLISHED", 
"ESTABLISHED", "TIME_WAIT", "TIME_WAIT", "TIME_WAIT", "TIME_WAIT"
)), .Names = c("Proto", "Recv-Q", "Send-Q", "Local-Address", 
"Foreign-Address", "State"), class = "data.frame", row.names = c(NA, 
-6L))

library(stringr)
dat1[,4:5]<-lapply(dat1[,4:5],function(x) str_replace(x,"^\\D+",""))
dat1
#  Proto Recv-Q Send-Q  Local-Address   Foreign-Address   State
#1   tcp  0  0 172.20.100.2:60255 172.20.100.3:8209 ESTABLISHED
#2   tcp  0  0 172.20.100.2:60247 172.20.100.3:8209 ESTABLISHED
##3   tcp  0  0    172.20.100.2:80 10.1.5.7:3185   TIME_WAIT
#4   tcp  0  0    172.20.100.2:80 10.5.1.3:3189   TIME_WAIT
#5   tcp  0  0    172.20.100.2:80 10.5.5.7:3445   TIME_WAIT
#6   tcp  0  0    172.20.100.2:80    10.3.29.3:2671   TIME_WAIT

A.K.




- Original Message -
From: "mohan.radhakrish...@polarisft.com" 
To: r-help@r-project.org
Cc: 
Sent: Friday, September 27, 2013 3:42 AM
Subject: [R] Locating inefficient code

Hi,

          I have been using R for a few months and I have this working 
code. Don't seen any problem but this takes a long time. So if I have 
about 3 rows it takes a few minutes. If I have 10 it does not seem 
to complete.

Original Data:

Proto Recv-Q Send-Q Local-Address               Foreign-Address  State  
tcp        0            0                    172.20.100.2:60255 
172.20.100.3:8209           ESTABLISHED 
tcp        0         0                    172.20.100.2:60247 
172.20.100.3:8209           ESTABLISHED 
tcp        0         0                     :::172.20.100.2:80 
:::10.1.5.7:3185        TIME_WAIT 
tcp        0        0                    :::172.20.100.2:80 
:::10.5.1.3:3189        TIME_WAIT 
tcp        0        0                     :::172.20.100.2:80 
:::10.5.5.7:3445        TIME_WAIT 
tcp        0        0                    :::172.20.100.2:80 
:::10.3.29.3:2671       TIME_WAIT 

Parsed Data:

tcp        0            0                    172.20.100.2:60255 
172.20.100.3:8209           ESTABLISHED 
tcp        0         0                    172.20.100.2:60247 
172.20.100.3:8209           ESTABLISHED 

Here I am just splitting at colons and getting IP's and ports. That is 
all. Can this code improved ?

data <- read.table("D:\\Log 
Analysis\\26-9-2013\\concurrentusage-node1",sep="",header=T,stringsAsFactors=FALSE,
 
fill=TRUE)
var <- c("Foreign.Address")
data[,var] <- sapply(data[,var],function(x) 
ifelse(length(unlist(str_split(x,":")))==5,unlist(str_split(x,":"))[4],unlist(str_split(x,":"))[1]))
var <- c("Local.Address")
data[,var] <- sapply(data[,var],function(x) 
ifelse(length(unlist(str_split(x,":")))==5,paste(unlist(str_split(x,":"))[4],":",unlist(str_split(x,":"))[5]),
paste(unlist(str_split(x,":"))[1],":",unlist(str_split(x,":"))[2])))

Thanks,
Mohan


This e-Mail may contain proprietary and confidential information and is sent 
for the intended recipient(s) only.  If by an addressing or transmission error 
this mail has been misdirected to you, you are requested to delete this mail 
immediately. You are also hereby notified that any use, any form of 
reproduction, dissemination, copying, disclosure, modification, distribution 
and/or publication of this e-mail message, contents or its attachment other 
than by its intended recipient/s is strictly prohibited.

Visit us at http://www.polarisFT.com

    [[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Space between x-axis ticks

2013-09-27 Thread Jim Lemon

On 09/27/2013 09:22 PM, mohan.radhakrish...@polarisft.com wrote:

Hi Jim,

Yes. The attached graph has less values. When there are more the values
are too close even though after the beginning and ending tick there is
enough space to evenly distribute the ticks.
Is there a parameter to specifcy the space between the ticks. I used
'space' in boxplots.



Hi Mohan,
The space between the ticks is determined by the number of ticks and the 
length of the x axis:


 = /

So, if you make the x axis longer by increasing the width of the plot, 
there will be more space for more tick labels. You can increase the 
number of lines that "staxlab" will use to display labels, but more than 
three lines is usually too difficult to read. you can also try rotating 
the labels (see the "srt" argument in staxlab) rather than staggering them.


Jim

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] R not ploting lines in the correct order

2013-09-27 Thread Shane Carey
Hi Sarah,

thanks for your reply. Im not sure how to use dput? If I create an object
of my data, does that mean you can read it in from your side or something?

Here is my code:
X
Data Date
5.61 24/09/2012 09:13
5.80 16/10/2012 11:17
6.01 24/10/2012 21:43
5.65 11/09/2012 18:34
5.27 22/08/2012 15:45
5.67 10/08/2012 00:30
5.66 14/08/2012 14:52
5.81 24/09/2012 12:19
5.67 25/10/2012 12:45
5.46 07/11/2012 14:07
5.81 17/10/2012 10:51
5.86 07/11/2012 15:54
5.70 01/11/2012 19:21
5.33 01/11/2012 12:23
5.99 02/10/2012 21:25
5.70 30/11/2012 11:40
6.06 26/10/2012 13:21
5.47 23/08/2012 13:28
6.42 19/12/2012 10:54
6.05 09/08/2012 22:45
5.49 12/09/2012 09:39
5.45 11/10/2012 11:28
5.48 13/08/2012 16:15
5.61 10/09/2012 11:01
5.96 21/08/2012 10:55
5.37 30/11/2012 10:03
5.77 26/10/2012 17:08
5.81 03/10/2012 12:45
dput(X, "X")
plot(X$Data,Y$Date,yaxt="n", xaxt="n",type="o")
lines(X$Data,Y$Date,pch=21, col="blue",type="o")


Thanks again


On Thu, Sep 26, 2013 at 7:23 PM, Sarah Goslee wrote:

> Hi Shane,
>
> Please use dput() to provide your data, rather than pasting it in so
> that we can work from the same R object you are. Please also provide
> the code you're using to make the graph.
>
> Sarah
>
> On Thu, Sep 26, 2013 at 1:56 PM, Shane Carey  wrote:
> > Hi,
> >
> > I have a set of x, y points where x represents dates and y actual
> values. I
> > am trying to plot a line graph of the data with points on top, but R is
> > connecting the wrong points with lines. Does anyone know how I can
> rectify
> > this. Please see sample below:
> >
> > x=
> >  24/09/2009 09:13  16/10/2009 11:17  24/10/2009 21:43  11/09/2009
> > 18:34  22/08/2009
> > 15:45  10/08/2009 00:30  14/08/2009 14:52  24/09/2009 12:19
> > 25/10/2009 12:45  07/11/2009 14:07  17/10/2009 10:51  07/11/2009 15:54
> > 01/11/2009 19:21  01/11/2009 12:23  02/10/2009 21:25  30/11/2009 11:40
> > 26/10/2009 13:21  23/08/2009 13:28  19/12/2009 10:54  09/08/2009 22:45
> >  12/09/2009
> > 09:39  11/10/2009 11:28  13/08/2009 16:15  10/09/2009 11:01  21/08/2009
> > 10:55  30/11/2009 10:03  26/10/2009 17:08  03/10/2009 12:45
> >
> > y=
> >  4.2537264  4.397792  4.5570224  4.284056  3.9959248  4.2992208
>  4.2916384
> > 4.4053744  4.2992208  4.1399904  4.4053744  4.4432864  4.321968
>  4.0414192
> > 4.5418576  4.321968  4.5949344  4.1475728  4.8679008  4.587352  4.1627376
> > 4.132408  4.1551552  4.2537264  4.5191104  4.0717488  4.3750448
>  4.4053744
> > Thanks
> > --
> > Shane
> >
>
> --
> Sarah Goslee
> http://www.functionaldiversity.org
>



-- 
Shane

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Compare species presence and absence between sites

2013-09-27 Thread Rui Barradas

Hello,

Something like this?


different <- function(x, y) x == 1 & y == 0

set.seed(7054)
mat <- matrix(sample(0:1, 500, TRUE), nrow = 5)
rownames(mat) <- LETTERS[1:5]
colnames(mat) <- sprintf("D%03d", 1:100)

different(mat["B",], mat["E",])



Hope this helps,

Rui Barradas

Em 27-09-2013 11:48, Elaine Kuo escreveu:

Dear List,



I want to compare the presence and absence of bird species based on the
sites in a matrix.

The matrix has 5 rows for Island A, B, C, D, and E.

It has 100 columns for bird species D001-D100.

In each cell of the matrix,

the presence-absence of bird species will be recorded as 1 or 0.

(For example, if species D001 is found on Island D,

the matrix cell of species D001 and Island D will be 1.)



Now I want to know the different bird species between Island B and E.

In other words, I would like to find out bird species present (1) on Island
B but absent (0)on island E, and vice versa (absent (0) on Island B but
present (1)on island E).



Please kindly advise how to code the purpose above.

Thank you in advance.



Elaine

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.



__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Space between x-axis ticks

2013-09-27 Thread mohan . radhakrishnan
Hi Jim,

Yes. The attached graph has less values. When there are more the values 
are too close even though after the beginning and ending tick there is 
enough space to evenly distribute the ticks.
Is there a parameter to specifcy the space between the ticks. I used 
'space' in boxplots.


Thanks,
Mohan



From:   Jim Lemon 
To: mohan.radhakrish...@polarisft.com
Cc: r-help@r-project.org
Date:   09/27/2013 03:10 PM
Subject:Re: [R] Space between x-axis ticks



On 09/27/2013 06:13 PM, mohan.radhakrish...@polarisft.com wrote:
> Hi Jim
> 1. I use a bigger font using 'cex' but that worsens because tick marks
> are close
> 2. A wider png is also insufficient.
>
> The first tick is slightly away from the origin. I should be able to
> move it closer and then stagger the ticks. What is the 'staxlab' line
> that will help ? I used to look at the help page of 'staxlab' but
> there are less examples. Are there better references ?
>
Odd. If you do what I told you, you get the attached plot. It works the 
same for a PNG image.

Jim

[attachment "mk.pdf" deleted by Mohan Radhakrishnan/BSC31/polarisFT] 



This e-Mail may contain proprietary and confidential information and is sent 
for the intended recipient(s) only.  If by an addressing or transmission error 
this mail has been misdirected to you, you are requested to delete this mail 
immediately. You are also hereby notified that any use, any form of 
reproduction, dissemination, copying, disclosure, modification, distribution 
and/or publication of this e-mail message, contents or its attachment other 
than by its intended recipient/s is strictly prohibited.

Visit us at http://www.polarisFT.com

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] min(NA,"bla") != min("bla", NA)

2013-09-27 Thread Duncan Murdoch

On 13-09-27 6:00 AM, Magnus Thor Torfason wrote:

Thanks for putting together such a quick fix! Unfortunately the policy
for the system that I'm working on doesn't allow unreleased versions, so
I'll have to work around this for a little bit longer. But I'll ask my
sysadmins to install 3.0.3 as soon as it gets released.



As a workaround, it looked to me as though it would always be safe to 
use the single argument version, i.e. the fact that min(c("bla", NA)) 
got it right was not just a fluke.  It's a little bit less efficient 
than using two arguments, but probably not to the extent that you'd notice.


Duncan Murdoch




Best,
Magnus

On 9/27/2013 1:38 AM, Duncan Murdoch wrote:

Nice catch.  The good news is that min() works in the C locale; the bad
news is that max() doesn't.  But both work after today's patch.

Duncan Murdoch


__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.



__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Compare species presence and absence between sites

2013-09-27 Thread Elaine Kuo
Dear List,



I want to compare the presence and absence of bird species based on the
sites in a matrix.

The matrix has 5 rows for Island A, B, C, D, and E.

It has 100 columns for bird species D001-D100.

In each cell of the matrix,

the presence-absence of bird species will be recorded as 1 or 0.

(For example, if species D001 is found on Island D,

the matrix cell of species D001 and Island D will be 1.)



Now I want to know the different bird species between Island B and E.

In other words, I would like to find out bird species present (1) on Island
B but absent (0)on island E, and vice versa (absent (0) on Island B but
present (1)on island E).



Please kindly advise how to code the purpose above.

Thank you in advance.



Elaine

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] min(NA,"bla") != min("bla", NA)

2013-09-27 Thread Magnus Thor Torfason
Thanks for putting together such a quick fix! Unfortunately the policy 
for the system that I'm working on doesn't allow unreleased versions, so 
I'll have to work around this for a little bit longer. But I'll ask my 
sysadmins to install 3.0.3 as soon as it gets released.


Best,
Magnus

On 9/27/2013 1:38 AM, Duncan Murdoch wrote:

Nice catch.  The good news is that min() works in the C locale; the bad
news is that max() doesn't.  But both work after today's patch.

Duncan Murdoch


__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Space between x-axis ticks

2013-09-27 Thread Jim Lemon

On 09/27/2013 06:13 PM, mohan.radhakrish...@polarisft.com wrote:

Hi Jim
1. I use a bigger font using 'cex' but that worsens because tick marks
are close
2. A wider png is also insufficient.

The first tick is slightly away from the origin. I should be able to
move it closer and then stagger the ticks. What is the 'staxlab' line
that will help ? I used to look at the help page of 'staxlab' but
there are less examples. Are there better references ?

Odd. If you do what I told you, you get the attached plot. It works the 
same for a PNG image.


Jim



mk.pdf
Description: Adobe PDF document
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Locating inefficient code

2013-09-27 Thread jim holtman
Is this what you want?  Please use dput when providing data.  Should
be faster using regular expressions:

> x <-  read.table(text = "Proto Recv-Q Send-Q Local-Address   
> Foreign-Address  State
+  tcp00172.20.100.2:60255
172.20.100.3:8209   ESTABLISHED
+  tcp0 0172.20.100.2:60247
172.20.100.3:8209   ESTABLISHED
+  tcp0 0 :::172.20.100.2:80
:::10.1.5.7:3185TIME_WAIT
+  tcp00:::172.20.100.2:80
:::10.5.1.3:3189TIME_WAIT
+  tcp00 :::172.20.100.2:80
:::10.5.5.7:3445TIME_WAIT
+  tcp00:::172.20.100.2:80
:::10.3.29.3:2671   TIME_WAIT"
+ , as.is = TRUE
+ , header = TRUE
+ , check.names = FALSE
+ )
> x  # before
  Proto Recv-Q Send-Q  Local-Address   Foreign-Address   State
1   tcp  0  0 172.20.100.2:60255 172.20.100.3:8209 ESTABLISHED
2   tcp  0  0 172.20.100.2:60247 172.20.100.3:8209 ESTABLISHED
3   tcp  0  0 :::172.20.100.2:80  :::10.1.5.7:3185   TIME_WAIT
4   tcp  0  0 :::172.20.100.2:80  :::10.5.1.3:3189   TIME_WAIT
5   tcp  0  0 :::172.20.100.2:80  :::10.5.5.7:3445   TIME_WAIT
6   tcp  0  0 :::172.20.100.2:80 :::10.3.29.3:2671   TIME_WAIT
> for (i in c("Local-Address", "Foreign-Address")){
+ x[[i]] <- sub("[^0-9]*(.*)", "\\1", x[[i]])  # ignore upto first digit
+ }
> x  # after
  Proto Recv-Q Send-Q  Local-Address   Foreign-Address   State
1   tcp  0  0 172.20.100.2:60255 172.20.100.3:8209 ESTABLISHED
2   tcp  0  0 172.20.100.2:60247 172.20.100.3:8209 ESTABLISHED
3   tcp  0  0172.20.100.2:80 10.1.5.7:3185   TIME_WAIT
4   tcp  0  0172.20.100.2:80 10.5.1.3:3189   TIME_WAIT
5   tcp  0  0172.20.100.2:80 10.5.5.7:3445   TIME_WAIT
6   tcp  0  0172.20.100.2:8010.3.29.3:2671   TIME_WAIT
>

Jim Holtman
Data Munger Guru

What is the problem that you are trying to solve?
Tell me what you want to do, not how you want to do it.


On Fri, Sep 27, 2013 at 3:12 AM,   wrote:
> Hi,
>
>   I have been using R for a few months and I have this working
> code. Don't seen any problem but this takes a long time. So if I have
> about 3 rows it takes a few minutes. If I have 10 it does not seem
> to complete.
>
> Original Data:
>
> Proto Recv-Q Send-Q Local-Address   Foreign-Address  State
> tcp00172.20.100.2:60255
> 172.20.100.3:8209   ESTABLISHED
> tcp0 0172.20.100.2:60247
> 172.20.100.3:8209   ESTABLISHED
> tcp0 0 :::172.20.100.2:80
> :::10.1.5.7:3185TIME_WAIT
> tcp00:::172.20.100.2:80
> :::10.5.1.3:3189TIME_WAIT
> tcp00 :::172.20.100.2:80
> :::10.5.5.7:3445TIME_WAIT
> tcp00:::172.20.100.2:80
> :::10.3.29.3:2671   TIME_WAIT
>
> Parsed Data:
>
> tcp00172.20.100.2:60255
> 172.20.100.3:8209   ESTABLISHED
> tcp0 0172.20.100.2:60247
> 172.20.100.3:8209   ESTABLISHED
>
> Here I am just splitting at colons and getting IP's and ports. That is
> all. Can this code improved ?
>
> data <- read.table("D:\\Log
> Analysis\\26-9-2013\\concurrentusage-node1",sep="",header=T,stringsAsFactors=FALSE,
> fill=TRUE)
> var <- c("Foreign.Address")
> data[,var] <- sapply(data[,var],function(x)
> ifelse(length(unlist(str_split(x,":")))==5,unlist(str_split(x,":"))[4],unlist(str_split(x,":"))[1]))
> var <- c("Local.Address")
> data[,var] <- sapply(data[,var],function(x)
> ifelse(length(unlist(str_split(x,":")))==5,paste(unlist(str_split(x,":"))[4],":",unlist(str_split(x,":"))[5]),
>  paste(unlist(str_split(x,":"))[1],":",unlist(str_split(x,":"))[2])))
>
> Thanks,
> Mohan
>
>
> This e-Mail may contain proprietary and confidential information and is sent 
> for the intended recipient(s) only.  If by an addressing or transmission 
> error this mail has been misdirected to you, you are requested to delete this 
> mail immediately. You are also hereby notified that any use, any form of 
> reproduction, dissemination, copying, disclosure, modification, distribution 
> and/or publication of this e-mail message, contents or its attachment other 
> than by its intended recipient/s is strictly prohibited.
>
> Visit us at http://www.polarisFT.com
>
> [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide htt

Re: [R] Space between x-axis ticks

2013-09-27 Thread mohan . radhakrishnan
Hi Jim
 1. I use a bigger font using 'cex' but that worsens 
because tick marks are close
 2. A wider png is also insufficient.

The first tick is slightly away from the origin. I should be able to move 
it closer and then stagger the ticks. What is the 'staxlab' line that will 
help ? I used to look at the help page of 'staxlab' but
there are less examples. Are there better references ?

I know this.

staxlab(var),labels=as.character(var),nlines=3,srt=90)

Thanks.



From:   Jim Lemon 
To: mohan.radhakrish...@polarisft.com
Cc: r-help@r-project.org
Date:   09/27/2013 01:37 PM
Subject:Re: [R] Space between x-axis ticks



On 09/27/2013 05:15 PM, mohan.radhakrish...@polarisft.com wrote:
> ...
>I am trying to clearly show the values in the x-axis in the
> attached graph. The tick marks are too close and the labels are blurred.
>...

Hi Mohan,
If the tick marks are too close together, you can increase the width of 
the graphic device.

If the labels are blurred, use a larger font (cex=), stagger them 
(staxlab) or try a graphic device like postscript or pdf.

Jim




This e-Mail may contain proprietary and confidential information and is sent 
for the intended recipient(s) only.  If by an addressing or transmission error 
this mail has been misdirected to you, you are requested to delete this mail 
immediately. You are also hereby notified that any use, any form of 
reproduction, dissemination, copying, disclosure, modification, distribution 
and/or publication of this e-mail message, contents or its attachment other 
than by its intended recipient/s is strictly prohibited.

Visit us at http://www.polarisFT.com

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Space between x-axis ticks

2013-09-27 Thread Jim Lemon

On 09/27/2013 05:15 PM, mohan.radhakrish...@polarisft.com wrote:

...
   I am trying to clearly show the values in the x-axis in the
attached graph. The tick marks are too close and the labels are blurred.
...


Hi Mohan,
If the tick marks are too close together, you can increase the width of 
the graphic device.


If the labels are blurred, use a larger font (cex=), stagger them 
(staxlab) or try a graphic device like postscript or pdf.


Jim

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Space between x-axis ticks

2013-09-27 Thread mohan . radhakrishnan
I attached a graph and it is not allowed. So the data is here.

Var1 Freq
1 10.1.17.10  205
2 10.1.17.15  216
3 10.1.17.17   79
4 10.1.17.23   76
5 10.1.17.24  209
6  10.1.17.5  244
7  10.1.17.6  178
8  10.1.17.7  165
9  10.1.17.8  146
10 10.1.17.9   90
1110.1.17.99  174
12   10.1.19.100  196

Thanks.



From:   mohan.radhakrish...@polarisft.com
To: r-help@r-project.org
Date:   09/25/2013 12:41 PM
Subject:[R] Space between x-axis ticks
Sent by:r-help-boun...@r-project.org



Hi,

  I am trying to clearly show the values in the x-axis in the 
attached graph. The tick marks are too close and the labels are blurred. 


plot(as.numeric(data$Var1),data$Freq,ylim=c(0,700),col="green",type="o",ylab="Number
 

of connections",las=2,lwd=2.5,xaxt="n",xlab="IP")

axis(1,at=data$Var1,labels=data$Var1,las = 2,cex.axis=0.7,las=2)
title("Estimation of concurrent connections",cex.main=1.8,line=1)



Thanks,
Mohan


This e-Mail may contain proprietary and confidential information and is 
sent for the intended recipient(s) only.  If by an addressing or 
transmission error this mail has been misdirected to you, you are 
requested to delete this mail immediately. You are also hereby notified 
that any use, any form of reproduction, dissemination, copying, 
disclosure, modification, distribution and/or publication of this e-mail 
message, contents or its attachment other than by its intended recipient/s 
is strictly prohibited.

Visit us at http://www.polarisFT.com
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide 
http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.




This e-Mail may contain proprietary and confidential information and is sent 
for the intended recipient(s) only.  If by an addressing or transmission error 
this mail has been misdirected to you, you are requested to delete this mail 
immediately. You are also hereby notified that any use, any form of 
reproduction, dissemination, copying, disclosure, modification, distribution 
and/or publication of this e-mail message, contents or its attachment other 
than by its intended recipient/s is strictly prohibited.

Visit us at http://www.polarisFT.com

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Locating inefficient code

2013-09-27 Thread mohan . radhakrishnan
Hi,

  I have been using R for a few months and I have this working 
code. Don't seen any problem but this takes a long time. So if I have 
about 3 rows it takes a few minutes. If I have 10 it does not seem 
to complete.

Original Data:

Proto Recv-Q Send-Q Local-Address   Foreign-Address  State  
tcp00172.20.100.2:60255 
172.20.100.3:8209   ESTABLISHED 
tcp0 0172.20.100.2:60247 
172.20.100.3:8209   ESTABLISHED 
tcp0 0 :::172.20.100.2:80 
:::10.1.5.7:3185TIME_WAIT 
tcp00:::172.20.100.2:80 
:::10.5.1.3:3189TIME_WAIT 
tcp00 :::172.20.100.2:80 
:::10.5.5.7:3445TIME_WAIT 
tcp00:::172.20.100.2:80 
:::10.3.29.3:2671   TIME_WAIT 

Parsed Data:

tcp00172.20.100.2:60255 
172.20.100.3:8209   ESTABLISHED 
tcp0 0172.20.100.2:60247 
172.20.100.3:8209   ESTABLISHED 

Here I am just splitting at colons and getting IP's and ports. That is 
all. Can this code improved ?

data <- read.table("D:\\Log 
Analysis\\26-9-2013\\concurrentusage-node1",sep="",header=T,stringsAsFactors=FALSE,
 
fill=TRUE)
var <- c("Foreign.Address")
data[,var] <- sapply(data[,var],function(x) 
ifelse(length(unlist(str_split(x,":")))==5,unlist(str_split(x,":"))[4],unlist(str_split(x,":"))[1]))
var <- c("Local.Address")
data[,var] <- sapply(data[,var],function(x) 
ifelse(length(unlist(str_split(x,":")))==5,paste(unlist(str_split(x,":"))[4],":",unlist(str_split(x,":"))[5]),
 paste(unlist(str_split(x,":"))[1],":",unlist(str_split(x,":"))[2])))

Thanks,
Mohan


This e-Mail may contain proprietary and confidential information and is sent 
for the intended recipient(s) only.  If by an addressing or transmission error 
this mail has been misdirected to you, you are requested to delete this mail 
immediately. You are also hereby notified that any use, any form of 
reproduction, dissemination, copying, disclosure, modification, distribution 
and/or publication of this e-mail message, contents or its attachment other 
than by its intended recipient/s is strictly prohibited.

Visit us at http://www.polarisFT.com

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.