Re: [R] IP-Address

2009-06-01 Thread edwin

wow =P


Thank you guys. I will use the hb2 , because it is the fastest one.

Eddie

> wow! :)
>
> vQ
>
> Henrik Bengtsson wrote:
> > library(gsubfn)
> > library(gtools)
> > library(rbenchmark)
> >
> > n <- 1
> > df <- data.frame(
> >   a = rnorm(n),
> >   b = rnorm(n),
> >   c = rnorm(n),
> >   ip = replicate(n, paste(sample(255, 4), collapse='.'), simplify=TRUE)
> > )
> >
> > res <- benchmark(columns=c('test', 'elapsed'), replications=10,
> > order=NULL, peda = {
> > connection <- textConnection(as.character(df$ip))
> > o <- do.call(order, read.table(connection, sep='.'))
> > close(connection)
> > df[o, ]
> >   },
> >
> >   peda2 = {
> > connection <- textConnection(as.character(df$ip))
> > dfT <- read.table(connection, sep='.', colClasses=rep("integer",
> > 4), quote="", na.strings=NULL, blank.lines.skip=FALSE)
> > close(connection)
> > o <- do.call(order, dfT)
> > df[o, ]
> >   },
> >
> >   hb = {
> > ip <- strsplit(as.character(df$ip), split=".", fixed=TRUE)
> > ip <- unlist(ip, use.names=FALSE)
> > ip <- as.integer(ip)
> > dim(ip) <- c(4, nrow(df))
> > ip <- 256^3*ip[1,] + 256^2*ip[2,] + 256*ip[3,] + ip[4,]
> > o <- order(ip)
> > df[o, ]
> >   },
> >
> >   hb2 = {
> > ip <- strsplit(as.character(df$ip), split=".", fixed=TRUE)
> > ip <- unlist(ip, use.names=FALSE)
> > ip <- as.integer(ip);
> > dim(ip) <- c(4, nrow(df))
> > o <- sort.list(ip[4,], method="radix", na.last=TRUE)
> > for (kk in 3:1) {
> >   o <- o[sort.list(ip[kk,o], method="radix", na.last=TRUE)]
> > }
> > df[o, ]
> >   }
> > )
> >
> > print(res)
> >
> >test elapsed
> > 1  peda4.12
> > 2 peda24.08
> > 3hb0.28
> > 4   hb20.25
>
> __
> 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] IP-Address

2009-06-01 Thread edwin

Maybe you can make a package for something like this. (IP sort,etc). Like in 
Perl, there is a module called Sort::Key::IPv4
I think, not only me has the same problem for sorting e.g IP?


Eddie
> Not really, just the old saying that any piece of code can be made
> twice as fast (which often holds true recursively). /Henrik
>
> On Sun, May 31, 2009 at 1:58 PM, Wacek Kusnierczyk
>
>  wrote:
> > wow! :)
> >
> > vQ
> >
> > Henrik Bengtsson wrote:
> >> library(gsubfn)
> >> library(gtools)
> >> library(rbenchmark)
> >>
> >> n <- 1
> >> df <- data.frame(
> >>   a = rnorm(n),
> >>   b = rnorm(n),
> >>   c = rnorm(n),
> >>   ip = replicate(n, paste(sample(255, 4), collapse='.'), simplify=TRUE)
> >> )
> >>
> >> res <- benchmark(columns=c('test', 'elapsed'), replications=10,
> >> order=NULL, peda = {
> >> connection <- textConnection(as.character(df$ip))
> >> o <- do.call(order, read.table(connection, sep='.'))
> >> close(connection)
> >> df[o, ]
> >>   },
> >>
> >>   peda2 = {
> >> connection <- textConnection(as.character(df$ip))
> >> dfT <- read.table(connection, sep='.', colClasses=rep("integer",
> >> 4), quote="", na.strings=NULL, blank.lines.skip=FALSE)
> >> close(connection)
> >> o <- do.call(order, dfT)
> >> df[o, ]
> >>   },
> >>
> >>   hb = {
> >> ip <- strsplit(as.character(df$ip), split=".", fixed=TRUE)
> >> ip <- unlist(ip, use.names=FALSE)
> >> ip <- as.integer(ip)
> >> dim(ip) <- c(4, nrow(df))
> >> ip <- 256^3*ip[1,] + 256^2*ip[2,] + 256*ip[3,] + ip[4,]
> >> o <- order(ip)
> >> df[o, ]
> >>   },
> >>
> >>   hb2 = {
> >> ip <- strsplit(as.character(df$ip), split=".", fixed=TRUE)
> >> ip <- unlist(ip, use.names=FALSE)
> >> ip <- as.integer(ip);
> >> dim(ip) <- c(4, nrow(df))
> >> o <- sort.list(ip[4,], method="radix", na.last=TRUE)
> >> for (kk in 3:1) {
> >>   o <- o[sort.list(ip[kk,o], method="radix", na.last=TRUE)]
> >> }
> >> df[o, ]
> >>   }
> >> )
> >>
> >> print(res)
> >>
> >>test elapsed
> >> 1  peda4.12
> >> 2 peda24.08
> >> 3hb0.28
> >> 4   hb20.25
> >
> > __
> > 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] IP-Address

2009-06-04 Thread edwin
Thank you Peter,

This solved the problem.


> edw...@web.de wrote:
> > Hi,
> >
> >
> > Unfortunately, they can't handle NA. Any suggestion? Some row for Ip
> > don't have ip address. This cause an error/ wrong result.
>
> A quick fix could be to substitute "..." or "0.0.0.0" for the "NA"
> entries. (Use something like
>
> ipch <- as.character(df$ip)
> ipch[is.na(df$ip)] <- "..."
> connection <- textConnection(ipch)
>
> )
>
> > Eddie
> >
> >> library(gsubfn)
> >> library(gtools)
> >> library(rbenchmark)
> >>
> >> n <- 1
> >> df <- data.frame(
> >> a = rnorm(n),
> >> b = rnorm(n),
> >> c = rnorm(n),
> >> ip = replicate(n, paste(sample(255, 4), collapse='.'), simplify=TRUE)
> >> )
> >>
> >> res <- benchmark(columns=c('test', 'elapsed'), replications=10,
> >
> > order=NULL,
> >
> >> peda = {
> >> connection <- textConnection(as.character(df$ip))
> >> o <- do.call(order, read.table(connection, sep='.'))
> >> close(connection)
> >> df[o, ]
> >> },
> >>
> >> peda2 = {
> >> connection <- textConnection(as.character(df$ip))
> >> dfT <- read.table(connection, sep='.', colClasses=rep("integer",
> >> 4), quote="", na.strings=NULL, blank.lines.skip=FALSE)
> >> close(connection)
> >> o <- do.call(order, dfT)
> >> df[o, ]
> >> },
> >>
> >> hb = {
> >> ip <- strsplit(as.character(df$ip), split=".", fixed=TRUE)
> >> ip <- unlist(ip, use.names=FALSE)
> >> ip <- as.integer(ip)
> >> dim(ip) <- c(4, nrow(df))
> >> ip <- 256^3*ip[1,] + 256^2*ip[2,] + 256*ip[3,] + ip[4,]
> >> o <- order(ip)
> >> df[o, ]
> >> },
> >>
> >> hb2 = {
> >> ip <- strsplit(as.character(df$ip), split=".", fixed=TRUE)
> >> ip <- unlist(ip, use.names=FALSE)
> >> ip <- as.integer(ip);
> >> dim(ip) <- c(4, nrow(df))
> >> o <- sort.list(ip[4,], method="radix", na.last=TRUE)
> >> for (kk in 3:1) {
> >> o <- o[sort.list(ip[kk,o], method="radix", na.last=TRUE)]
> >> }
> >> df[o, ]
> >> }
> >> )
> >>
> >> print(res)
> >>
> >> test elapsed
> >> 1 peda 4.12
> >> 2 peda2 4.08
> >> 3 hb 0.28
> >> 4 hb2 0.25
> >>
> >>
> >> On Sun, May 31, 2009 at 12:42 AM, Wacek Kusnierczyk
> >>
> >>  wrote:
> >> > edwin Sendjaja wrote:
> >> >> Hi VQ,
> >> >>
> >> >> Thank you. It works like charm. But I think Peter's code is faster.
> >
> > What
> >
> >> >> is the difference?
> >> >
> >> > i think peter's code is more r-elegant, though less generic.  here's a
> >> > quick test, with not so surprising results.  gsubfn is implemented in
> >> > r, not c, and it is painfully slow in this test. i also added gabor's
> >> > suggestion.
> >> >
> >> >library(gsubfn)
> >> >library(gtools)
> >> >library(rbenchmark)
> >> >
> >> >n = 1000
> >> >df = data.frame(
> >> >   a=rnorm(n),
> >> >   b = rnorm(n),
> >> >   c = rnorm(n),
> >> >   ip = replicate(n, paste(sample(255, 4), collapse='.'),
> >> > simplify=TRUE))
> >> >benchmark(columns=c('test', 'elapsed'), replications=10,
> >> > order=NULL, peda={
> >> >  connection = textConnection(as.character(df$ip))
> >> >  o = do.call(order, read.table(connection, sep='.'))
> >> >  close(connection)
> >> >  df[o, ] },
> >> >   waku=df[order(gsubfn(perl=TRUE,
> >> >  '[0-9]+',
> >> >  ~ sprintf('%03d', as.integer(x)),
> >> >  as.character(df$ip))), ],
> >> >   gagr=df[mixedorder(df$ip), ] )
> >> >
> >> ># peda 0.070
> >> ># waku 7.070
> >> ># gagr 4.710
> >> >
> >> >
> >> > vQ
> >> >
> >> > __
> >> > 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] IP-Address

2009-06-17 Thread edwin
Hi all,


Sorry, David has just told my that it was a mistake in my example (Thanks 
David). I had a wrong idea.
 

The right idea is: make a ip range, when the number increament without an gap 
(and with maximum number: 255, see example down).
 


In case my initial example would be:
 


> 162.131.58.1
 > 162.131.58.2
 > 162.131.58.3
 > 162.131.58.4
 > 162.131.58.5
 > 162.131.58.6
 The Range is: 162.131.58.1 - 162.131.58.6
 


> 162.132.58.20
 162.132.58.20 (no range)
 

> 162.252.20.21
 162.252.20.21 (no range)
 

> 162.254.20.22
 162.254.20.22 (no range)
 

> 163.253.7.23
 163.253.7.23 (no range)
 

> 163.253.20.25
 163.253.20.25 (no range)
 

> 161.138.45.226
 161.138.45.226 (no range)
 

Another example:
 >162.131.58.1
 >162.131.58.2
 >162.131.58.3
 >162.131.58.4
 >162.131.58.5
 >162.131.58.6
 
  (here alll ips from 162.131.58.7 until 162.131.58.253, I just don't write 
it all down=))
 
 >162.131.58.254
 >162.131.58.255 (hier: the max ist 255)
 >162.131.59.1 (attention: instead 58, now 59)
 >162.131.59.2
 >162.131.59.3
 The range for those ips are: 
 162.131.58.1-162.131.59-3 
 



I hope this example helps. Any suggestion?
 



Kind regards,
 

Eddie



> Hi Peter,
>
>
> I hope you could help. I am stuck with this. The last problem I have is:
>
> I have table like:
>
> id rank color status ip
> 138 29746 yellow yes 162.131.58.1
> 138 29746 yellow  yes  162.131.58.2
> 138 29746 yellow yes  162.131.58.3
> 138 29746 yellow yes  162.131.58.4
> 138 29746 yellow yes 162.131.58.5
> 138 29746 yellow yes  162.131.58.6
> 138 29746 yellow  yes 162.132.58.20
> 138 29746 yellow yes  162.252.20.21
> 138 29746 yellow yes  162.254.20.22
> 138 29746 yellow yes  163.253.7.23
> 138 29746 yellow yes  163.253.20.25
> 138 29746 yellow yes  161.138.45.226
>
> How can i make this to a range:
>
> 138 29746 yellow yes 162.131.58.1-162.131.58.6
> 138 29746 yellow  yes 162.132.58.20-163.253.7.23
> 138 29746 yellow yes  162.252.20.21-162.254.20.22
> 138 29746 yellow yes  163.253.20.25-161.138.45.226
>
>
>
> Kind regards,
>
> Eddie
>
> > edw...@web.de wrote:
> > > Hi,
> > >
> > >
> > > Unfortunately, they can't handle NA. Any suggestion? Some row for Ip
> > > don't have ip address. This cause an error/ wrong result.
> >
> > A quick fix could be to substitute "..." or "0.0.0.0" for the "NA"
> > entries. (Use something like
> >
> > ipch <- as.character(df$ip)
> > ipch[is.na(df$ip)] <- "..."
> > connection <- textConnection(ipch)
> >
> > )
> >
> > > Eddie
> > >
> > >> library(gsubfn)
> > >> library(gtools)
> > >> library(rbenchmark)
> > >>
> > >> n <- 1
> > >> df <- data.frame(
> > >> a = rnorm(n),
> > >> b = rnorm(n),
> > >> c = rnorm(n),
> > >> ip = replicate(n, paste(sample(255, 4), collapse='.'), simplify=TRUE)
> > >> )
> > >>
> > >> res <- benchmark(columns=c('test', 'elapsed'), replications=10,
> > >
> > > order=NULL,
> > >
> > >> peda = {
> > >> connection <- textConnection(as.character(df$ip))
> > >> o <- do.call(order, read.table(connection, sep='.'))
> > >> close(connection)
> > >> df[o, ]
> > >> },
> > >>
> > >> peda2 = {
> > >> connection <- textConnection(as.character(df$ip))
> > >> dfT <- read.table(connection, sep='.', colClasses=rep("integer",
> > >> 4), quote="", na.strings=NULL, blank.lines.skip=FALSE)
> > >> close(connection)
> > >> o <- do.call(order, dfT)
> > >> df[o, ]
> > >> },
> > >>
> > >> hb = {
> > >> ip <- strsplit(as.character(df$ip), split=".", fixed=TRUE)
> > >> ip <- unlist(ip, use.names=FALSE)
> > >> ip <- as.integer(ip)
> > >> dim(ip) <- c(4, nrow(df))
> > >> ip <- 256^3*ip[1,] + 256^2*ip[2,] + 256*ip[3,] + ip[4,]
> > >> o <- order(ip)
> > >> df[o, ]
> > >> },
> > >>
> > >> hb2 = {
> > >> ip <- strsplit(as.character(df$ip), split=".", fixed=TRUE)
> > >> ip <- unlist(ip, use.names=FALSE)
> > >> ip <- as.integer(ip);
> > >> dim(ip) <- c(4, nrow(df))
> > >> o <- sort.list(ip[4,], method="radix", na.last=TRUE)
> &g

Re: [R] I cannot get species scores to plot with site scores in MDS when I use a distance matrix as input. Problems with NA's?

2011-12-01 Thread Edwin
Dear Gavin,
Thanks a lot for your reply. I am still not sure if your suggestion can help
me or not because I have got different types of errors while trying it. I
have tried my best to troubleshoot them and made some progress, but I have
reached a dead end (I don’t know how to go on). Below I am copping my TinnR
script. It contains not only the R script but also the errors returned in
the R console. I apologize that the script is still not really reproducible
but I just do not know how to create a sample data frame for it. Thanks
again for your help.  Edwin.
##Load required packages##
library(vegan)
library(MASS)
library (FD)
library(dummies)
##Load full table of species traits and taxonomic data##
AllTraits<-read.delim("SpeciesTraitsFullTbl.txt",header=T)
##Edit data##
row.names(AllTraits)<-AllTraits$species.code
TraitsNMDS<-AllTraits[,c(8:12,14:18,23,25,30)]
##Check variable class using function "allClass" from
http://gettinggeneticsdone.blogspot.com/2010   
/08/quickly-find-class-of-dataframe-vectors.html##
allClass <- function(x) {unlist(lapply(unclass(x),class))} 
allClass(TraitsNMDS)
##Change variables to fulfill requirements for gowdis() function##
  #Define ordinal variables#
  TraitsNMDS$leaf.type<-ordered(TraitsNMDS$leaf.type, levels =
c("simple", "pinnate", "bipinnate"))
  TraitsNMDS$dispersal.rank<-ordered(TraitsNMDS$dispersal.rank, levels =
c("s_disp","m_disp","l_disp"))
# 0, wascores) &&
any(comm < 0)) { :   missing value where TRUE/FALSE needed'##
  #Set autotransform, noshare and wascores to FALSE (even if TRUE is
desired) to see if problems is with metaMDS function#
  WrapTest2<-metaMDS(TraitsNMDS, distfun = wrapper, x=TraitsNMDS, asym.bin =
"heterospory", ord= "podani", autotransform =FALSE, noshare = FALSE,
wascores = FALSE)
  #Returned error: 'Error in FUN(X[[1L]], ...) : only defined on a data
frame with all numeric variables'#
  #transform factors to dummies and numeric#
  TraitsNMDSCompleteDumm<-dummy.data.frame(TraitsNMDSComplete,
c("leaf.type","dispersal.rank"))
 
TraitsNMDSCompleteDumm$leaf.typesimple<-as.numeric(TraitsNMDSCompleteDumm$leaf.typesimple)
 
TraitsNMDSCompleteDumm$leaf.typepinnate<-as.numeric(TraitsNMDSCompleteDumm$leaf.typepinnate)
 
TraitsNMDSCompleteDumm$leaf.typebipinnate<-as.numeric(TraitsNMDSCompleteDumm$leaf.typebipinnate)
 
TraitsNMDSCompleteDumm$dispersal.ranks_disp<-as.numeric(TraitsNMDSCompleteDumm$dispersal.ranks_disp)
 
TraitsNMDSCompleteDumm$dispersal.rankm_disp<-as.numeric(TraitsNMDSCompleteDumm$dispersal.rankm_disp)
 
TraitsNMDSCompleteDumm$dispersal.rankl_disp<-as.numeric(TraitsNMDSCompleteDumm$dispersal.rankl_disp)
  
##Re-test wrapping function##
WrapTest3<-metaMDS(TraitsNMDSCompleteDumm, distfun = wrapper,
x=TraitsNMDSCompleteDumm,asym.bin ="heterospory", ord = "podani")
  #The function runs but returns an error related to the gowdis() function
after the transformation of the data is done:  
  #'Square root transformation Wisconsin double standardization. Error in
gowdis(x, ...) : w needs to be a numeric vector of length = number of
variables in x'
 # But testing the wrapper alone does work!#
DistMatrixWrapper<-wrapper(x=TraitsNMDSCompleteDumm,asym.bin =
"heterospory", ord = "podani")
class(DistMatrixWrapper)
[1] "dist"
 # I do not know why the error is produced


--
View this message in context: 
http://r.789695.n4.nabble.com/I-cannot-get-species-scores-to-plot-with-site-scores-in-MDS-when-I-use-a-distance-matrix-as-input-Pr-tp4103699p4127949.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.


Re: [R] Differences between SPSS and R on probit analysis

2017-06-22 Thread Edwin Burgess
Hi Bianca,


I hope you’ve solved your problem with SPSS and R probit analysis, but if you 
haven’t, I have your solution:

Based on the output you’ve given, I see that your residual deviance is 
under-dispersed (that the ratio of residual deviance to residual deviance df 
does is less than 1). However, you’ve told R to treat your dispersion parameter 
as 1 (you did this by using the ‘family = binomial’ argument). Instead, if you 
use ‘family=quasibinomial’ you allow the dispersion parameter to be estimated. 
This changes how the variance, SE, etc are calculated. Modeling it this way is 
akin to the SPSS method, and thus produces nearly-identical results. You may 
still see very, very minor differences in chi square goodness of fit, and 95% 
CI of the doses/concentrations, etc. but this is due to differences in rounding 
under the hood of the software.


Hope this helps!

 
Edwin R. Burgess IV, Ph.D.



[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] Embed fonts in an R graph

2015-07-10 Thread Edwin Sun
Hello all,

I cannot embed a common font type into an R graph. I did it successfully in
December 2014 with the previous R version. However, with R 3.2.1 in July
2015, the following sample codes do not work anymore.

pdf(file = "c:/testA.pdf", family = "serif")
plot(x = 1:10, y = rnorm(10))
dev.off()
embedFonts(file = "c:/testA.pdf", outfile = "c:/testB.pdf")

As a result, both testA.pdf and testB.pdf cannot embed the fonts into the
graph. Specifically, Adobe Acrobt reveals that "Times-Roman" is substituted
by "TimesNewRomanPSMT", and "ZapfDingbats" is substituted by "AdobePiStd". 

Any help is greatly appreciated.

Edwin

<http://r.789695.n4.nabble.com/file/n4709707/Capture.png> 




--
View this message in context: 
http://r.789695.n4.nabble.com/Embed-fonts-in-an-R-graph-tp4709707.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] GARCH estimation with exogenous variables in the mean equation

2010-04-09 Thread Edwin Sun

Hello,

I have the similar issue in estimating a GARCH model with exogenous
variables in the mean equation. Currently, to my understanding, the garch
function in tseries package can handle univariate model, and garchFit in
fGarch can handle ARMA specification. 

I wonder if there is any R function that can handle exogenous variables in
estimating GARCH?

Thank you a lot.


Edwin
-- 
View this message in context: 
http://n4.nabble.com/another-GARCH-problem-tp859307p1819640.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] ggplot legend for multiple time series

2009-12-01 Thread Edwin Sun

Hello All,

I am trying to create a legend for a black-white graph. The package I use is
ggplot2. It can add colors to the legend key but not line types. Can you
please help?

# example from Wickman (2009, ggplot2 – elegant graphics for data analysis,
page 109)

library(ggplot2)
huron <- data.frame(year=1875:1972, level=LakeHuron)
ggplot(huron, aes(year)) +
geom_line(aes(y=level+5, colour="above")) +
geom_line(aes(y=level-5, colour="below")) +
scale_colour_manual("Direction", c("above"="black", "below"="black"))

Thanks,


Edwin

Changyou Sun, Ph.D.
Associate Professor
Natural Resource Policy & Economics
Box 9681, Department of Forestry
Mississippi State University
Mississippi State, MS 39762

#363 Thompson Hall
(662) 325 7271 (ph), 325 8726 (fax)
c...@cfr.msstate.edu
www.cfr.msstate.edu/forestry
-- 
View this message in context: 
http://n4.nabble.com/ggplot-legend-for-multiple-time-series-tp932430p932430.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.


Re: [R] ggplot legend for multiple time series

2009-12-01 Thread Edwin Sun

Hello - Thank you so much for the help. It works perfectly. I guess that as
many have pointed out, ggplot is a great package but there is a lack of
documentation and examples. 

Edwin Sun


baptiste auguie-5 wrote:
> 
> Hi,
> 
> I don't understand why you used scale_manual_colour if you want only
> black lines. To have different line types in the legend you can map
> the linetype to the data,
> 
> 
> huron <- data.frame(year=1875:1972, level=LakeHuron)
> 
> ggplot(huron, aes(year)) +
>geom_line(aes(y=level+5, linetype="above")) +
>geom_line(aes(y=level-5, linetype="below")) +
>scale_linetype_manual("offset", c(1, 2))
> 
> HTH,
> 
> baptiste
> 2009/12/1 Edwin Sun :
>>
>> Hello All,
>>
>> I am trying to create a legend for a black-white graph. The package I use
>> is
>> ggplot2. It can add colors to the legend key but not line types. Can you
>> please help?
>>
>> # example from Wickman (2009, ggplot2 – elegant graphics for data
>> analysis,
>> page 109)
>>
>> library(ggplot2)
>> huron <- data.frame(year=1875:1972, level=LakeHuron)
>> ggplot(huron, aes(year)) +
>>    geom_line(aes(y=level+5, colour="above")) +
>>    geom_line(aes(y=level-5, colour="below")) +
>>    scale_colour_manual("Direction", c("above"="black", "below"="black"))
>>
>> Thanks,
>>
>>
>> Edwin
>>
>> Changyou Sun, Ph.D.
>> Associate Professor
>> Natural Resource Policy & Economics
>> Box 9681, Department of Forestry
>> Mississippi State University
>> Mississippi State, MS 39762
>>
>> #363 Thompson Hall
>> (662) 325 7271 (ph), 325 8726 (fax)
>> c...@cfr.msstate.edu
>> www.cfr.msstate.edu/forestry
>> --
>> View this message in context:
>> http://n4.nabble.com/ggplot-legend-for-multiple-time-series-tp932430p932430.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.
> 
> 

-- 
View this message in context: 
http://n4.nabble.com/ggplot-legend-for-multiple-time-series-tp932430p932491.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] IP-Address

2009-05-28 Thread edwin Sendjaja

Hi,

Is there any way to sort a tabel with a colum with IP-address?

table:

id rank color status ip
138 29746 yellow no 162.131.58.26
138 29746 red  yes  162.131.58.16
138 29746 blue yes  162.131.58.10
138 29746 red no  162.131.58.17
138 29746 yellow no 162.131.58.14
138 29746 red no  162.131.58.13
138 29746 yellow  no 162.132.58.15
139 29746 green no  162.252.20.69
140 29746 red yes  162.254.20.71
141 29746 yellow no  163.253.7.153
142 31804 green yes  163.253.20.114
144 32360 black yes  161.138.45.226



Unfortunately, order doesn't work as I want.

I found an half solusion from John:

mysort <- function(x){
  sort.helper <- function(x){
prefix <- strsplit(x, "[0-9]")
prefix <- sapply(prefix, "[", 1)
prefix[is.na(prefix)] <- ""
suffix <- strsplit(x, "[^0-9]")
suffix <- as.numeric(sapply(suffix, "[", 2))
suffix[is.na(suffix)] <- -Inf
remainder <- sub("[^0-9]+", "", x)
remainder <- sub("[0-9]+", "", remainder)
if (all (remainder == "")) list(prefix, suffix)
else c(list(prefix, suffix), Recall(remainder))
}
  ord <- do.call("order", sort.helper(x))
  x[ord]
   } 


mysort (data$ip)  captured only the ip-adresse. How can I capture the whole 
table and sorted?(ID rank color status ip)



Thank you in advance.

eddie



_


[[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] IP-Address

2009-05-30 Thread edwin Sendjaja

Hi Allan,



Thank you for your reply. I have more than 4 Rows. I don't believe than
it's a good solution, if I need to write down all of the values. I have
about 200 Rows. Do you have any other solution?. Is there any package
that I can use?





Edwin 



> Date: Fri, 29 May 2009 09:59:40 +0100
> From: all...@cybaea.com
> To: edwin_0...@msn.com
> CC: r-help@r-project.org
> Subject: Re: [R] IP-Address
> 
> IP addresses are very (very!) difficult to parse and sort correctly 
> because there are all sorts of supported formats.  Try to use something 
> like PostgreSQL instead: it is already implemented there.  But if you 
> are sure all your data is of the n.n.n.n form, then something along the 
> lines of the following should basically work (I have chosen some more 
> interesting IP addresses for this):
> 
> 
> a <- data.frame(cbind(id=c(138,138,138,138),
>   rank=c(29746,29746,29746,29746),
>   color=c("yellow","red","blue","red"),
>   status=c("no","yes","yes","no"),
>   
> ip=c("162.131.58.26","2.131.58.16","2.2.58.10","162.131.58.17")))
> a
> #id  rank  color statusip
> # 1 138 29746 yellow no 162.131.58.26
> # 2 138 29746redyes   2.131.58.16
> # 3 138 29746   blueyes 2.2.58.10
> # 4 138 29746red no 162.131.58.17
> x <- matrix(unlist(lapply(strsplit(as.character(a$ip), ".", fixed=TRUE), 
> as.integer)),
> ncol=4, byrow=TRUE)
> a[order(x[,1],x[,2],x[,3],x[,4]),]
> #id  rank  color statusip
> # 3 138 29746   blueyes 2.2.58.10
> # 2 138 29746redyes   2.131.58.16
> # 4 138 29746red no 162.131.58.17
> # 1 138 29746 yellow no 162.131.58.26
> 
> 
> Getting rid of the conversions including the matrix(unlist) combo is 
> left as an exercise (it's too hot here)
> 
> Allan.
> 
> edwin Sendjaja wrote:
> > Hi,
> >
> > Is there any way to sort a tabel with a colum with IP-address?
> >
> > table:
> >
> > id rank color status ip
> > 138 29746 yellow no 162.131.58.26
> > 138 29746 red  yes  162.131.58.16
> > 138 29746 blue yes  162.131.58.10
> > 138 29746 red no  162.131.58.17
> > 138 29746 yellow no 162.131.58.14
> > 138 29746 red no  162.131.58.13
> > 138 29746 yellow  no 162.132.58.15
> > 139 29746 green no  162.252.20.69
> > 140 29746 red yes  162.254.20.71
> > 141 29746 yellow no  163.253.7.153
> > 142 31804 green yes  163.253.20.114
> > 144 32360 black yes  161.138.45.226
> > 
> >
> >
> > Unfortunately, order doesn't work as I want.
> >
> > I found an half solusion from John:
> >
> > mysort <- function(x){
> >   sort.helper <- function(x){
> > prefix <- strsplit(x, "[0-9]")
> > prefix <- sapply(prefix, "[", 1)
> > prefix[is.na(prefix)] <- ""
> > suffix <- strsplit(x, "[^0-9]")
> > suffix <- as.numeric(sapply(suffix, "[", 2))
> > suffix[is.na(suffix)] <- -Inf
> > remainder <- sub("[^0-9]+", "", x)
> > remainder <- sub("[0-9]+", "", remainder)
> > if (all (remainder == "")) list(prefix, suffix)
> > else c(list(prefix, suffix), Recall(remainder))
> > }
> >   ord <- do.call("order", sort.helper(x))
> >   x[ord]
> >} 
> >
> >
> > mysort (data$ip)  captured only the ip-adresse. How can I capture the whole 
> > table and sorted?(ID rank color status ip)
> >
> >
> >
> > Thank you in advance.
> >
> > eddie
> >
> >
> >
> > _
> >
> >
> > [[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.
> >   

_
[[elided Hotmail spam]]
[[elided Hotmail spam]]
[[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] IP-Address

2009-05-30 Thread edwin Sendjaja

Hi Peter,



This works as I expected. Thank you very much.





Eddie

> Date: Fri, 29 May 2009 11:15:37 +0200
> From: p.dalga...@biostat.ku.dk
> To: all...@cybaea.com
> CC: r-help@r-project.org
> Subject: Re: [R] IP-Address
> 
> Allan Engelhardt wrote:
> > IP addresses are very (very!) difficult to parse and sort correctly
> > because there are all sorts of supported formats.  Try to use something
> > like PostgreSQL instead: it is already implemented there.  But if you
> > are sure all your data is of the n.n.n.n form, then something along the
> > lines of the following should basically work (I have chosen some more
> > interesting IP addresses for this):
> > 
> > 
> > a <- data.frame(cbind(id=c(138,138,138,138),
> >  rank=c(29746,29746,29746,29746),
> >  color=c("yellow","red","blue","red"),
> >  status=c("no","yes","yes","no"),
> > 
> > ip=c("162.131.58.26","2.131.58.16","2.2.58.10","162.131.58.17")))
> > a
> > #id  rank  color statusip
> > # 1 138 29746 yellow no 162.131.58.26
> > # 2 138 29746redyes   2.131.58.16
> > # 3 138 29746   blueyes 2.2.58.10
> > # 4 138 29746red no 162.131.58.17
> > x <- matrix(unlist(lapply(strsplit(as.character(a$ip), ".", fixed=TRUE),
> > as.integer)),
> >ncol=4, byrow=TRUE)
> > a[order(x[,1],x[,2],x[,3],x[,4]),]
> > #id  rank  color statusip
> > # 3 138 29746   blueyes 2.2.58.10
> > # 2 138 29746redyes   2.131.58.16
> > # 4 138 29746red no 162.131.58.17
> > # 1 138 29746 yellow no 162.131.58.26
> > 
> > 
> > Getting rid of the conversions including the matrix(unlist) combo is
> > left as an exercise (it's too hot here)
> 
> Here's one way:
> 
> con <- textConnection(as.character(a$ip))
> o <- do.call(order,read.table(con,sep="."))
> close(con)
> a[o,]
> 
> 
> -- 
>O__   Peter Dalgaard Øster Farimagsgade 5, Entr.B
>   c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K
>  (*) \(*) -- University of Copenhagen   Denmark  Ph:  (+45) 35327918
> ~~ - (p.dalga...@biostat.ku.dk)  FAX: (+45) 35327907
> 
> __
> 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.

_

[[elided Hotmail spam]]
[[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] IP-Address

2009-05-30 Thread edwin Sendjaja

Hi VQ,

Thank you. It works like charm. But I think Peter's code is faster. What is the 
difference? 


Eddie




> Date: Fri, 29 May 2009 11:44:15 +0200
> From: waclaw.marcin.kusnierc...@idi.ntnu.no
> To: p.dalga...@biostat.ku.dk
> CC: r-help@r-project.org
> Subject: Re: [R] IP-Address
> 
> Peter Dalgaard wrote:
> > Allan Engelhardt wrote:
> >   
> >> IP addresses are very (very!) difficult to parse and sort correctly
> >> because there are all sorts of supported formats.  Try to use something
> >> like PostgreSQL instead: it is already implemented there.  But if you
> >> are sure all your data is of the n.n.n.n form, then something along the
> >> lines of the following should basically work (I have chosen some more
> >> interesting IP addresses for this):
> >>
> >>
> >> a <- data.frame(cbind(id=c(138,138,138,138),
> >>  rank=c(29746,29746,29746,29746),
> >>  color=c("yellow","red","blue","red"),
> >>  status=c("no","yes","yes","no"),
> >> 
> >> ip=c("162.131.58.26","2.131.58.16","2.2.58.10","162.131.58.17")))
> >> a
> >> #id  rank  color statusip
> >> # 1 138 29746 yellow no 162.131.58.26
> >> # 2 138 29746redyes   2.131.58.16
> >> # 3 138 29746   blueyes 2.2.58.10
> >> # 4 138 29746red no 162.131.58.17
> >> x <- matrix(unlist(lapply(strsplit(as.character(a$ip), ".", fixed=TRUE),
> >> as.integer)),
> >>ncol=4, byrow=TRUE)
> >> a[order(x[,1],x[,2],x[,3],x[,4]),]
> >> #id  rank  color statusip
> >> # 3 138 29746   blueyes 2.2.58.10
> >> # 2 138 29746redyes   2.131.58.16
> >> # 4 138 29746red no 162.131.58.17
> >> # 1 138 29746 yellow no 162.131.58.26
> >>
> >>
> >> Getting rid of the conversions including the matrix(unlist) combo is
> >> left as an exercise (it's too hot here)
> >> 
> >
> > Here's one way:
> >
> > con <- textConnection(as.character(a$ip))
> > o <- do.call(order,read.table(con,sep="."))
> > close(con)
> > a[o,]
> >
> >   
> 
> here's another:
> 
> library(gsubfn)
> a[order(gsubfn(
> '[0-9]+',
> ~ sprintf('%03d', as.integer(x)),
> as.character(a$ip))),]
> 
> vQ
> 
> __
> 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.

_

--> Für Fotos hier abdrücken <-
[[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] help with ggplot2 -- ggpoint function missing?

2009-04-02 Thread Edwin Chen
Thanks, that helped! I didn't realize there was another version of the book.

On Wed, Apr 1, 2009 at 2:51 PM, Tobias Verbeke <
tobias.verb...@openanalytics.be> wrote:

> Hi,
>
>  I'm trying to follow the ggplot introduction here:
>> http://had.co.nz/ggplot/ggplot-introduction.pdf
>>
>> I've installed ggplot2 with install.packages("ggplot2", dep=T)
>> but when I try to run
>> print(ggpoint(p, list(colour = sex)))
>> I get an error:
>> Error in print(ggpoint(p, list(colour = sex))) :  could not find function
>> "ggpoint"
>>
>> What is the problem? Has the function been renamed in the ggplot ->
>> ggplot2
>> transition?
>>
>
> ggplot2 has seen many improvements and still is under active
> development. Rather than find out what ggpoint was about
> and what happened to it, you might want to discover the
> current version using the following book as an introduction:
>
> http://had.co.nz/ggplot2/book/
>
> There also is a targeted e-mail list whose archives
> may be instructive
>
> http://groups.google.com/group/ggplot2
>
> HTH,
> Tobias
>
>

[[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] navigation panel with help

2010-01-28 Thread Edwin Sun

All,

I installed the lastest version of R 2.10.1. On the help page for a specific
function, it turns out that the vertical navigation panel on the left does
not appear anymore. For example, 

?lm

The help page from this command is a page without navigation panel (which I
prefer to use). I notice there is an index link at the bottom of the page.
By the way, I did not make any change on my browser.

Is this a change for this version? Thank you for your help.

Edwin Sun
-- 
View this message in context: 
http://n4.nabble.com/navigation-panel-with-help-tp1395663p1395663.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.


Re: [R] ggplot2: How to change font of labels in geom_text

2010-07-12 Thread Edwin Sun

I have the same problem and I wonder if there is any answer from the
community. Thanks.
-- 
View this message in context: 
http://r.789695.n4.nabble.com/ggplot2-How-to-change-font-of-labels-in-geom-text-tp991579p2286671.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] Multiple CPU HowTo in Linux?

2010-09-14 Thread Edwin Groot
Hello all,
I upgraded my R workstation, and to my dismay, only one core appears to
be used during intensive computation of a bioconductor function.
What I have now is two dual-core Xeon 5160 CPUs and 10 GB RAM. When I
fully load it, top reports about 25% user, 75% idle and 0.98 short-term
load.
The archives gave nothing helpful besides mention of snow. I thought of
posting to HPC, but this system is fairly modest WRT processing power.
Any pointers of where to start?
---
#Not running anything at the moment
> sessionInfo()
R version 2.11.1 (2010-05-31) 
x86_64-pc-linux-gnu 

locale:
 [1] LC_CTYPE=en_GB.UTF-8   LC_NUMERIC=C  
 [3] LC_TIME=en_GB.UTF-8LC_COLLATE=en_GB.UTF-8
 [5] LC_MONETARY=C  LC_MESSAGES=en_GB.UTF-8   
 [7] LC_PAPER=en_GB.UTF-8   LC_NAME=C 
 [9] LC_ADDRESS=C   LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_GB.UTF-8 LC_IDENTIFICATION=C   

attached base packages:
[1] stats graphics  grDevices utils datasets  methods   base


loaded via a namespace (and not attached):
[1] tools_2.11.1
---
$ uname -a
Linux laux29 2.6.26-2-amd64 #1 SMP Sun Jun 20 20:16:30 UTC 2010 x86_64
GNU/Linux
---
Thanks for your help,
Edwin
-- 
Dr. Edwin Groot, postdoctoral associate
AG Laux
Institut fuer Biologie III
Schaenzlestr. 1
79104 Freiburg, Deutschland
+49 761-2032945

__
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] Multiple CPU HowTo in Linux?

2010-09-14 Thread Edwin Groot
Hello Cedrick,
Ah, yes, that looks like it would apply to my situation. I was
previously reading on snow, which is tailored for clusters, rather than
a single desktop computer.
Anyone with experience adapting multicore to an R-script?
I have to admit I know little about parallel processing,
multiprocessing and cluster processing.

Edwin

On Tue, 14 Sep 2010 10:15:42 -0400
 "Johnson, Cedrick W."  wrote:
>   ?multicore perhaps
> 
> On 09/14/2010 10:01 AM, Edwin Groot wrote:
> > Hello all,
> > I upgraded my R workstation, and to my dismay, only one core
> appears to
> > be used during intensive computation of a bioconductor function.
> > What I have now is two dual-core Xeon 5160 CPUs and 10 GB RAM. When
> I
> > fully load it, top reports about 25% user, 75% idle and 0.98
> short-term
> > load.
> > The archives gave nothing helpful besides mention of snow. I
> thought of
> > posting to HPC, but this system is fairly modest WRT processing
> power.
> > Any pointers of where to start?
> > ---
> > #Not running anything at the moment
> >> sessionInfo()
> > R version 2.11.1 (2010-05-31)
> > x86_64-pc-linux-gnu
> >
> > locale:
> >   [1] LC_CTYPE=en_GB.UTF-8   LC_NUMERIC=C
> >   [3] LC_TIME=en_GB.UTF-8LC_COLLATE=en_GB.UTF-8
> >   [5] LC_MONETARY=C  LC_MESSAGES=en_GB.UTF-8
> >   [7] LC_PAPER=en_GB.UTF-8   LC_NAME=C
> >   [9] LC_ADDRESS=C   LC_TELEPHONE=C
> > [11] LC_MEASUREMENT=en_GB.UTF-8 LC_IDENTIFICATION=C
> >
> > attached base packages:
> > [1] stats graphics  grDevices utils datasets  methods
>   base
> >
> >
> > loaded via a namespace (and not attached):
> > [1] tools_2.11.1
> > ---
> > $ uname -a
> > Linux laux29 2.6.26-2-amd64 #1 SMP Sun Jun 20 20:16:30 UTC 2010
> x86_64
> > GNU/Linux
> > ---
> > Thanks for your help,
> > Edwin
> 
> __
> 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.

Dr. Edwin Groot, postdoctoral associate
AG Laux
Institut fuer Biologie III
Schaenzlestr. 1
79104 Freiburg, Deutschland
+49 761-2032945

__
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] Multiple CPU HowTo in Linux?

2010-09-15 Thread Edwin Groot
Hello all,
Thanks for your input, and helping to clear things up on where to go.
I will try out the multicore package and see if there are further
bottlenecks. It looks like some loops might need special treatment with
parallelization.
I have been pampered with the excellent walk-through vignettes of the
packages I have used so far. The HPC package guides lacked something in
the practical aspects of their usage.
lapply <- mclapply at the beginning of my script? Well, I never would
have thought of such a thing. Thanks!

I might be back on the list when I run out of physical RAM ;-)

Edwin
-- 
On Tue, 14 Sep 2010 12:11:17 -0700
 Martin Morgan  wrote:
> On 09/14/2010 08:36 AM, Christian Raschke wrote:
> > Edwin,
> > 
> > I'm not sure what you mean by "adapting"; other than installing
> > multicore, there is nothing else to set up. How and whether you
> could
> > then parallelise your code strongly depends on the specific problem
> you
> > are facing.
> > 
> > What have done in the past was to look at the source of the
> functions
> > from whatever package I was using that produced the bottleneck. If
> what
> > is taking the longest time is actually embarrassingly parallel,
> > mclapply() from package multicore can help. In the simplest case
> you
> > could simply replace lapply() in the with an appropriate
> mclapply().
> > Check out ?mclapply. But then again you might have to get a little
> more
> > creative, depending on exactly what in the code is taking so long
> to
> > run. If your problem is inherently sequential then even multicore
> won't
> > help.
> > 
> > Christian
> > 
> > On 09/14/2010 09:35 AM, Edwin Groot wrote:
> >> Hello Cedrick,
> >> Ah, yes, that looks like it would apply to my situation. I was
> >> previously reading on snow, which is tailored for clusters, rather
> than
> >> a single desktop computer.
> >> Anyone with experience adapting multicore to an R-script?
> >> I have to admit I know little about parallel processing,
> >> multiprocessing and cluster processing.
> >>
> >> Edwin
> >>
> >> On Tue, 14 Sep 2010 10:15:42 -0400
> >>   "Johnson, Cedrick W."  wrote:
> >>   
> >>>?multicore perhaps
> >>>
> >>> On 09/14/2010 10:01 AM, Edwin Groot wrote:
> >>> 
> >>>> Hello all,
> >>>> I upgraded my R workstation, and to my dismay, only one core
> >>>>
> >>> appears to
> >>> 
> >>>> be used during intensive computation of a bioconductor function.
> 
> Hi Edwin -- Since you have a Bioconductor package,  you might ask on
> the
> Bioconductor list, as the authors of some computationally intensive
> tasks have provided facilities for relatively transparent use of,
> e.g.,
> multicore or Rmpi. In ShortRead, for instance, loading multicore is
> enough to distribute some tasks across cores, and the srapply
> function
> can help (or not; things might be as easy as lapply <- mclapply at
> the
> top of your script) with your own lapply-like code.
> 
> http://bioconductor.org/help/mailing-list/
> 
> Martin
> >>>> What I have now is two dual-core Xeon 5160 CPUs and 10 GB RAM.
> When
> >>>>
> >>> I
> >>> 
> >>>> fully load it, top reports about 25% user, 75% idle and 0.98
> >>>>
> >>> short-term
> >>> 
> >>>> load.
> >>>> The archives gave nothing helpful besides mention of snow. I
> >>>>
> >>> thought of
> >>> 
> >>>> posting to HPC, but this system is fairly modest WRT processing
> >>>>
> >>> power.
> >>> 
> >>>> Any pointers of where to start?
> >>>> ---
> >>>> #Not running anything at the moment
> >>>>   
> >>>>> sessionInfo()
> >>>>>  
> >>>> R version 2.11.1 (2010-05-31)
> >>>> x86_64-pc-linux-gnu
> >>>>
> >>>> locale:
> >>>>[1] LC_CTYPE=en_GB.UTF-8   LC_NUMERIC=C
> >>>>[3] LC_TIME=en_GB.UTF-8LC_COLLATE=en_GB.UTF-8
> >>>>[5] LC_MONETARY=C  LC_MESSAGES=en_GB.UTF-8
> >>>>[7] LC_PAPER=en_GB.UTF-8   LC_NAME=C
> >>>>[9] LC_ADDRESS=C   LC_TELEPHONE=C
> >>>> [11] LC_MEASUREMENT=en

Re: [R] Tal Galili wants to stay in touch on LinkedIn

2010-09-20 Thread Edwin Groot
Tal:
Invite everyone on R-Help, why not?
Please check your contact e-mail address!

Edwin
-- 
On Mon, 20 Sep 2010 02:14:17 -0700 (PDT)
 Tal Galili via LinkedIn  wrote:
> LinkedIn
> Tal Galili requested to add you as a connection on
> LinkedIn:
> --
> 
> Arnaud,
> 
> I'd like to add you to my professional network on LinkedIn.
> 
> - Tal Galili
> 
> Accept invitation from Tal Galili
>
http://www.linkedin.com/e/qi2mhu-geb4djy7-3w/qlt6CtWzi7sEoE_As_C0_wMfEZD2c-gGLFL6LO/blk/I2346598611_2/1BpC5vrmRLoRZcjkkZt5YCpnlOt3RApnhMpmdzgmhxrSNBszYOnP4NdzwVdjoQcP99bTxmq5tnjTkNbP4PcP4OdjsUdz4LrCBxbOYWrSlI/EML_comm_afe/
> 
> View invitation from Tal Galili
>
http://www.linkedin.com/e/qi2mhu-geb4djy7-3w/qlt6CtWzi7sEoE_As_C0_wMfEZD2c-gGLFL6LO/blk/I2346598611_2/39vcj4Se3ARdzgPcAALqnpPbOYWrSlI/svi/
> 
> --
> 
> DID YOU KNOW that LinkedIn can find the answers to your most
> difficult questions? Post those vexing questions on LinkedIn Answers
> to tap into the knowledge of the world's foremost business experts: 
> http://www.linkedin.com/e/qi2mhu-geb4djy7-3w/ask/inv-23/
> 
>  
> -- 
> (c) 2010, LinkedIn Corporation
>   [[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.

Dr. Edwin Groot, postdoctoral associate
AG Laux
Institut fuer Biologie III
Schaenzlestr. 1
79104 Freiburg, Deutschland
+49 761-2032945

__
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] store matrix in an arrary

2010-09-27 Thread Edwin Groot
On Mon, 27 Sep 2010 11:12:26 +0100
 wesley mathew  wrote:
> Dear All
> 
> I want to store matrix in an array
> Suppose  s<-array(0,4)
> for(i in 1:4)
> s[i] <- read_matrix(a,2,2)
> But the error - number of items to replace is not a multiple of
> replacement
> length.
> Can you suggest me any alternative method for storing a matrix in an
> array.
> Thanks In advance.
> Kind Regards
> Wesley C Mathew
> 

Wesley,
I don't know what your read_matrix() function is doing.
What you made is a 1-dimensional array of 4 elements. If your
read_matrix() function returns more than one element per call, that is
the source of your error message. It means you tried to store something
in s[] that goes beyond its dimensions.

Edwin
> __
> 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.
-- 
Dr. Edwin Groot, postdoctoral associate
AG Laux
Institut fuer Biologie III
Schaenzlestr. 1
79104 Freiburg, Deutschland
+49 761-2032945

__
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] dnorm and qnorm

2010-11-12 Thread Edwin Sun

Hello all,

I have a question about basic statistics.  Given a PDF value of 0.328161,
how can I find out the value of -0.625 in R? It is like reversing the dnorm
function but I do not know how to do it in R. 

> pdf.xb <- dnorm(-0.625) 

> pdf.xb 
[1] 0.328161

> qnorm(pdf.xb)
[1] -0.444997

> pnorm(pdf.xb)
[1] 0.628605

Many thanks,


Edwin


-- 
View this message in context: 
http://r.789695.n4.nabble.com/dnorm-and-qnorm-tp3040427p3040427.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.


Re: [R] dnorm and qnorm

2010-11-14 Thread Edwin Sun

Thank you all for the great help. I think the optimize function and approach
solves my problem well. 

Edwin Sun
-- 
View this message in context: 
http://r.789695.n4.nabble.com/dnorm-and-qnorm-tp3040427p3041962.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] how to update my own function

2010-11-23 Thread Edwin Sun

Hello all,

I wrote a function with many arguments. Then I need to call it many times
with changes on some arguments only. Is there any way to write a function or
have a method to "update" it, like the relationship between lm() and
update()?

Many thanks,

Edwin Sun


This is the sample code.

> test <- function(y, z) { 
+   x <- y +1
+   w <- z * 2
+   result <- list(x=x, w=w)
+   class(result) <- "ego"
+   return(result)
+ }

> me <- test(y=3, z=4); me
$x
[1] 4

$w
[1] 8

attr(,"class")
[1] "ego"

> update(me, y=5)
Error in update.default(me, y = 5) : need an object with call component

-- 
View this message in context: 
http://r.789695.n4.nabble.com/how-to-update-my-own-function-tp3056256p3056256.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.


Re: [R] how to update my own function

2010-11-23 Thread Edwin Sun

Thank you all the reply. The use of sys.call() as suggested by Ducan works
pretty well. This is good as the outputs from my function are large. The use
of apply family functions as suggested by Erik is good for small amounts of
outputs. 

Edwin Sun
-- 
View this message in context: 
http://r.789695.n4.nabble.com/how-to-update-my-own-function-tp3056256p3056301.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.


Re: [R] Help Please!!!!!!!!!

2010-11-29 Thread Edwin Groot
On Sun, 28 Nov 2010 21:29:08 -0800
 Melissa Waldman  wrote:
> Hi,
> 
> I have been working with Program R for my stats class and I keep
> coming upon
> the same error, I have read so many sites about inputting data from a
> text
> file into R and I'm using the data to do a correspondence analysis.
>  I feel
> like I have read everything and it is still not explaining why the
> error
> message keeps coming up, I have used the exact examples I have seen
> in
> articles and the same error keeps popping up: Error in sum(N) :
> invalid
> 'type' (character) of argument
> 
> I have spent so long trying to figure this out without
> success,
> I am sure it has to do with the fact that my rows have names in them.
>  I
> have attached the text file I have been using and if you have any
> ideas as
> to how I can get R to plot the data using correspondence analysis
> with the
> column and row names that would be really helpful!  Or if you could
> pass
> this email to someone who may know how to help me, that would be much
> appreciated.
> 
> Thank you,
> Melissa Waldman
> 
> my email: melissawald...@gmail.com

Hello Melissa,
First of all, you need a descriptive subject, such as, "Cannot read
tabular data in R". R-help is a high-volume (100 to 200 messages per
day) and each person that can help you is a specialist in one or
another area.
Secondly, please include in your mail an excerpt of the relevant code
you used that read the data in and produced the error.

>From looking at your text file, I would delete the white space before
None, save the file, and use the following function to read your data
into a data.frame:

read.delim("smokedata.txt")

This assumes you used a tab character between each field.

HTH, Edwin
-- 
Dr. Edwin Groot, postdoctoral associate
AG Laux
Institut fuer Biologie III
Schaenzlestr. 1
79104 Freiburg, Deutschland
+49 761-2032945

__
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] how to control ticks

2010-12-21 Thread Edwin Groot
On Tue, 21 Dec 2010 18:06:52 +0530
 Yogesh Tiwari  wrote:
> Hi,
> I want 12 ticks at axis 1 and want to write Jan-Dec on each.
> 
> something like:
> 
> axis(1, at=1:12,
> labels=c('J','F','M','A','M','J','J','A','S','O','N','D'))
> 
> I could omit default ticks but now how to control ticks.
> 

Dear Yogesh,
I spray my clothing with "No-Bite", and that controls ticks quite well.

:-)
Edwin

> plot(file$time, file$ch4*1000, ylim=c(1500,1700), xaxt='n', xlab= NA,
> ylab=NA,col="blue",yaxs="i",lwd=2, pch=10, type="b")#
> 
> axis(1, at=1:12,
> labels=c('J','F','M','A','M','J','J','A','S','O','N','D'))
> 
> BUT above is not working, and there is no error as well.
> 
> Pls help,
> 
> Regards,
> Yogesh
> 
>   [[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.

Dr. Edwin Groot, postdoctoral associate
AG Laux
Institut fuer Biologie III
Schaenzlestr. 1
79104 Freiburg, Deutschland
+49 761-2032945

__
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] How to Plot Two Curves Into One Page

2011-02-02 Thread Edwin Groot
On Tue, 1 Feb 2011 14:20:51 +0900
 Gundala Viswanath  wrote:
> I have a R script that contain these lines for plotting:
> 
> plot(foo,lwd=2,lty=3,col="red", main="");
> plot(bar,lwd=2,lty=3,col="blue");
> legend(0.6,0.6,c('Default','Probabilistic'),
> col=c('red','blue'),lwd=3);
> 
> 
> But it generate 1 file (Rplot.pdf) with two pages. Each page for 1
> plot.
> Is there a way I can put them together in to one page?
> 
> - G.V.
> 

Hello Gundala,
If these are fairly simple plots (i.e. curve, points, bar, step) you
can arrange your data as columns in a matrix and use matplot().

matplot(vectorOfxValues, FooBarAsMatrix, lwd=2, lty=3, col=c("red",
"blue"))
legend(0.6,0.6,c('Default','Probabilistic'), col=c('red','blue'),lwd=3)

Regards,
Edwin
-- 
Dr. Edwin Groot, postdoctoral associate
AG Laux
Institut fuer Biologie III
Schaenzlestr. 1
79104 Freiburg, Deutschland
+49 761-2032945

__
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] undefined S4 class in parallel computing at snowfall

2012-06-28 Thread Edwin Sun
Dear All,

I have a question of how to export S4 class specification to
clusters/workers in parallel computing. The package I used is snowfall. The
problem is reproducible as follows. Any hint is greatly appreciated.

Edwin Sun

=== begin ===
library(snowfall)
sfInit(parallel = TRUE, cpus = 2)
setClass("catt", representation(aa = "numeric"))
setClass("dogg", representation(bb = 'character', cc = "catt"))
f1 <- function(y1) { new('catt', aa = y1 + 1) }
f3 <- function(y2, y3) { new('dogg', bb=c(y2, 'GA'), cc = f1(y3)) }
dat <- 1:5
f1(dat)
f3('NY', dat) 
sapply(c("state1", 'state2', 'state3'), f3, dat) 
sfExportAll()
sfClusterEval(ls())
sfSapply(c("s1", 's2', 's3'), f3, dat) 
sfStop() 

# sfSapply generates the following error
#Error in checkForRemoteErrors(val) : 
#  2 nodes produced errors; first error: "dogg" is not a defined class
=== end =

--
View this message in context: 
http://r.789695.n4.nabble.com/undefined-S4-class-in-parallel-computing-at-snowfall-tp4634757.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] read.xls question

2012-07-11 Thread Tsay, Edwin
Hello,

 I've been using: tmp.df = read.xls(filename, stringsAsFactors = FALSE) to 
read in my files. Even though I get the "There were 50 or more warnings" thing, 
for the most part most of the data is read in correctly. However, there are a 
few select rows where there are values but they are being read in as NA. I copy 
and pasted those rows to their own individual xls file and when I tried to read 
in that sheet, it worked fine. This makes me wonder if it has something to do 
with the way that the cells are formatted, but I've checked the individual cell 
formats and they are all indeed the same.
Another strange thing that happens is something like the following. Say you 
have the following cash flows: NA NA NA NA 16000 0 0 0 0 0 0 90 70 0 0 
0 0 0 0 0 -200. It won't read anything until the 70 and after.
 Finally, it actually looks like for ALL rows, the first few columns are 
being read in as NA even though some of them have values (while others are read 
in correctly as NA)

Any help would be great!

Thank you

THIS MESSAGE AND ANY ATTACHMENTS ARE CONFIDENTIAL, PROPRIETARY, AND MAY BE 
PRIVILEGED.  If this message was misdirected, BlackRock, Inc. and its 
subsidiaries, ("BlackRock") does not waive any confidentiality or privilege.  
If you are not the intended recipient, please notify us immediately and destroy 
the message without disclosing its contents to anyone.  Any distribution, use 
or copying of this e-mail or the information it contains by other than an 
intended recipient is unauthorized.  The views and opinions expressed in this 
e-mail message are the author's own and may not reflect the views and opinions 
of BlackRock, unless the author is authorized by BlackRock to express such 
views or opinions on its behalf.  All email sent to or from this address is 
subject to electronic storage and review by BlackRock.  Although BlackRock 
operates anti-virus programs, it does not accept responsibility for any damage 
whatsoever caused by viruses being passed.


   
[[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] Piecewise distribution function estimation with Generalized Pareto for tail

2011-07-06 Thread Edwin Sun
Hello all,

I am trying to estimate the cumulative distribution function for a single
stock return time series. A piecewise estimation is composed of three parts:
parametric generalized Pareto (GP) for the lower tail (10% of the
observation), non-parametric kernel-smoothed interior (80% of the
observations), and GP for the upper tail (10%). I wonder if anyone has clue
about this in R.

The software of Matlab has a function called 'paretotails' in the
Econometrics Toolbox to do the estimation. On this site, a couple of old
messages were related but no clear answers were given.

Thank you,

Edwin Sun

--
View this message in context: 
http://r.789695.n4.nabble.com/Piecewise-distribution-function-estimation-with-Generalized-Pareto-for-tail-tp3649961p3649961.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] strange problem with strptime and date variable

2011-07-18 Thread Edwin Sun
Hello all,

I am manipulating a large database with 70,000 records. "strptime" generates
a date variable but R treats some of the values as NA. I attach a simple
example below.

I have spent hours on this problem. Any hint would be greatly appreciated.

Many thanks,

Edwin Sun

# ===start of sample code =

> x <- c("2005-04-02 19:03:00", "2005-04-03 02:00:00", "2005-04-03
> 14:25:00")
 
> y <- strptime(x, format="%Y-%m-%d %H:%M:%S")
 
> x; y; str(x); str(y)
[1] "2005-04-02 19:03:00" "2005-04-03 02:00:00" "2005-04-03 14:25:00"
[1] "2005-04-02 19:03:00" "2005-04-03 02:00:00" "2005-04-03 14:25:00"
 chr [1:3] "2005-04-02 19:03:00" "2005-04-03 02:00:00" ...
 POSIXlt[1:3], format: "2005-04-02 19:03:00" "2005-04-03 02:00:00" ...

> is.na(y)
[1] FALSE  TRUE FALSE

> difftime(y[2], y[1], units="mins")
Time difference of NA mins
 
> difftime(y[3], y[1], units="mins")
Time difference of 1102 mins
 
> sessionInfo()
R version 2.13.1 (2011-07-08)
Platform: i386-pc-mingw32/i386 (32-bit)

locale:
[1] LC_COLLATE=English_United States.1252 
[2] LC_CTYPE=English_United States.1252   
[3] LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C  
[5] LC_TIME=English_United States.1252

attached base packages:
[1] grDevices datasets  splines   graphics  stats tcltk utils
[8] methods   base 

other attached packages:
[1] svSocket_0.9-51 TinnR_1.0.3 R2HTML_2.2  Hmisc_3.8-3
[5] survival_2.36-9

loaded via a namespace (and not attached):
[1] cluster_1.14.0  grid_2.13.1 lattice_0.19-30 svMisc_0.9-61  
[5] tools_2.13.1   

# My computer is 64 bit / Microsoft Window 7; R 2.13.1 (32 bit)

# === end of sample code 




--
View this message in context: 
http://r.789695.n4.nabble.com/strange-problem-with-strptime-and-date-variable-tp3677178p3677178.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.


Re: [R] strange problem with strptime and date variable

2011-07-18 Thread Edwin Sun
David - Thanks very much. That is a great hint. I believe that is the
solution.

Edwin Sun

--
View this message in context: 
http://r.789695.n4.nabble.com/strange-problem-with-strptime-and-date-variable-tp3677178p3677205.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 R plots

2011-10-12 Thread Jonathan Edwin
Hi all,

Mind my ignorance and complete newbiness, but I am very new to R and am
currently learning it through my stats course at university.
My question is regarding adding titles to plots. I'll post the code below,
and then explain my issue:

> hist(gender$HeartRate)
> title(Histogram: HeartRate distribution for Temperature Data)

So what R has done, is paste over the title I entered above over the generic
title that was already there. Does anyone know how to remove the old title
so that only the one I want shows? Also help with editting the X and Y axis
titles would be great!

Cheers,
Jonathan
--

[[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] trying to superimpose a line plot onto a histogram

2008-07-05 Thread Edwin Lei
Hello,

I'm trying to superimpose a line plot onto a histogram but I'm not having
any luck. I've attached the dataset. What I did was:

> hist(data,freq=F)

Now I'm trying to superimpose the following points with a line connecting
them onto the histogram:

 xy
100  0.535665393824959
200  0.212744329736556
300  0.0844933242968584
400  0.0335572838043417
500  0.0133275771274986
600  0.00529316714442912
700  0.0021022289461042
800  0.000834919136549392
900  0.000331595645597124
1000 0.000131696193518099
1100 5.2304327929049e-05
1200 2.07731343406939e-05

Basically, the x values correspond to the break points in the histogram.
Next I used the command

> points(x,y,type="l")

But for some reason, the line plot is shifted to the right and doesn't line
up with the histogram.

Thanks for the help!

Edwin Lei


data.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] trying to superimpose a line plot onto a histogram

2008-07-05 Thread Edwin Lei
Thanks for the quick response. But the points I'm trying to superimpose
isn't exactly the density of the data. Is there any other way to do it?

 

From: milton ruser [mailto:[EMAIL PROTECTED] 
Sent: July 5, 2008 6:56 AM
To: Edwin Lei
Cc: r-help@r-project.org
Subject: Re: [R] trying to superimpose a line plot onto a histogram

 

How about the answer by Demitris?

 

Regards a lot,

 

miltinho



From: Dimitris Rizopoulos <[EMAIL PROTECTED]>
Date: Jun 16, 2008 4:05 AM
Subject: Re: [R] Superimposing Line over Histogram in Density Plot
To: Gundala Viswanath <[EMAIL PROTECTED]>
Cc: [EMAIL PROTECTED]

try something like this:

x <- rnorm(200)
hist(x, col = "blue", freq = FALSE)
lines(density(x), col = "red", lwd = 2)




 

On 7/5/08, Edwin Lei <[EMAIL PROTECTED]> wrote: 

Hello,

I'm trying to superimpose a line plot onto a histogram but I'm not having
any luck. I've attached the dataset. What I did was:

> hist(data,freq=F)

Now I'm trying to superimpose the following points with a line connecting
them onto the histogram:

xy
100  0.535665393824959
200  0.212744329736556
300  0.0844933242968584
400  0.0335572838043417
500  0.0133275771274986
600  0.00529316714442912
700  0.0021022289461042
800  0.000834919136549392
900  0.000331595645597124
1000 0.000131696193518099
1100 5.2304327929049e-05
1200 2.07731343406939e-05

Basically, the x values correspond to the break points in the histogram.
Next I used the command

> points(x,y,type="l")

But for some reason, the line plot is shifted to the right and doesn't line
up with the histogram.

Thanks for the help!

Edwin Lei

__
R-help@r-project.org mailing list

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] trying to superimpose a line plot onto a histogram

2008-07-05 Thread Edwin Lei
I tried that, but for some reason the scale is wrong? So the density doesn't 
show up on the histogram.  Also, I'd prefer not to use the density because I 
don't want the line plot to begin at a value of 0. I'm trying to emulate an 
exponential decay.

Thanks for the help.

> -Original Message-
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
> Sent: July 5, 2008 8:43 PM
> To: Edwin Lei
> Subject: Re: [R] trying to superimpose a line plot onto a histogram
> 
> 
> hi: you can do the same thing as below but just replace density(x) with
> whatever you want to plot ?
> 
> 
> On Sat, Jul 5, 2008 at  4:29 PM, Edwin Lei wrote:
> 
> > Thanks for the quick response. But the points I'm trying to
> > superimpose
> > isn't exactly the density of the data. Is there any other way to do
> > it?
> >
> >
> > From: milton ruser [mailto:[EMAIL PROTECTED] Sent: July 5, 2008
> > 6:56 AM
> > To: Edwin Lei
> > Cc: r-help@r-project.org
> > Subject: Re: [R] trying to superimpose a line plot onto a histogram
> >
> >
> > How about the answer by Demitris?
> >
> >
> > Regards a lot,
> >
> >
> > miltinho
> >
> > 
> >
> > From: Dimitris Rizopoulos <[EMAIL PROTECTED]>
> > Date: Jun 16, 2008 4:05 AM
> > Subject: Re: [R] Superimposing Line over Histogram in Density Plot
> > To: Gundala Viswanath <[EMAIL PROTECTED]>
> > Cc: [EMAIL PROTECTED]
> >
> > try something like this:
> >
> > x <- rnorm(200)
> > hist(x, col = "blue", freq = FALSE)
> > lines(density(x), col = "red", lwd = 2)
> >
> >
> >
> >
> >
> > On 7/5/08, Edwin Lei <[EMAIL PROTECTED]> wrote:
> > Hello,
> >
> > I'm trying to superimpose a line plot onto a histogram but I'm not
> > having
> > any luck. I've attached the dataset. What I did was:
> >
> >> hist(data,freq=F)
> >
> > Now I'm trying to superimpose the following points with a line
> > connecting
> > them onto the histogram:
> >
> > xy
> > 100  0.535665393824959
> > 200  0.212744329736556
> > 300  0.0844933242968584
> > 400  0.0335572838043417
> > 500  0.0133275771274986
> > 600  0.00529316714442912
> > 700  0.0021022289461042
> > 800  0.000834919136549392
> > 900  0.000331595645597124
> > 1000 0.000131696193518099
> > 1100 5.2304327929049e-05
> > 1200 2.07731343406939e-05
> >
> > Basically, the x values correspond to the break points in the
> > histogram.
> > Next I used the command
> >
> >> points(x,y,type="l")
> >
> > But for some reason, the line plot is shifted to the right and
> doesn't
> > line
> > up with the histogram.
> >
> > Thanks for the help!
> >
> > Edwin Lei
> >
> > __
> > R-help@r-project.org mailing list
> >
> > 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.

__
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] trying to superimpose a line plot onto a histogram

2008-07-06 Thread Edwin Lei
Okay I've included a picture of the plot I've been getting with the commands:

> hist(data,freq=F)
> lines(Y~X)

Basically I want the line circled in red to overlap the histogram because that 
line is supposed to represent the exponential decay nature of the histogram.

Thanks!

> -Original Message-
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
> Sent: July 5, 2008 10:22 PM
> To: Edwin Lei
> Subject: RE: [R] trying to superimpose a line plot onto a histogram
> 
>   i'm no R expert but if you send EXACTLY what you want to do to the
> list, i bet someone can help. if not tomorrow, then i bet some
> one wil respond on monday.
> 
> 
> 
> On Sun, Jul 6, 2008 at  1:07 AM, Edwin Lei wrote:
> 
> > I tried that, but for some reason the scale is wrong? So the density
> > doesn't show up on the histogram.  Also, I'd prefer not to use the
> > density because I don't want the line plot to begin at a value of 0.
> > I'm trying to emulate an exponential decay.
> >
> > Thanks for the help.
> >
> >> -Original Message-
> >> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
> >> Sent: July 5, 2008 8:43 PM
> >> To: Edwin Lei
> >> Subject: Re: [R] trying to superimpose a line plot onto a histogram
> >>
> >>
> >> hi: you can do the same thing as below but just replace density(x)
> >> with
> >> whatever you want to plot ?
> >>
> >>
> >> On Sat, Jul 5, 2008 at  4:29 PM, Edwin Lei wrote:
> >>
> >>> Thanks for the quick response. But the points I'm trying to
> >>> superimpose
> >>> isn't exactly the density of the data. Is there any other way to do
> >>> it?
> >>>
> >>>
> >>> From: milton ruser [mailto:[EMAIL PROTECTED] Sent: July 5,
> >>> 2008
> >>> 6:56 AM
> >>> To: Edwin Lei
> >>> Cc: r-help@r-project.org
> >>> Subject: Re: [R] trying to superimpose a line plot onto a histogram
> >>>
> >>>
> >>> How about the answer by Demitris?
> >>>
> >>>
> >>> Regards a lot,
> >>>
> >>>
> >>> miltinho
> >>>
> >>> 
> >>>
> >>> From: Dimitris Rizopoulos <[EMAIL PROTECTED]>
> >>> Date: Jun 16, 2008 4:05 AM
> >>> Subject: Re: [R] Superimposing Line over Histogram in Density Plot
> >>> To: Gundala Viswanath <[EMAIL PROTECTED]>
> >>> Cc: [EMAIL PROTECTED]
> >>>
> >>> try something like this:
> >>>
> >>> x <- rnorm(200)
> >>> hist(x, col = "blue", freq = FALSE)
> >>> lines(density(x), col = "red", lwd = 2)
> >>>
> >>>
> >>>
> >>>
> >>>
> >>> On 7/5/08, Edwin Lei <[EMAIL PROTECTED]> wrote:
> >>> Hello,
> >>>
> >>> I'm trying to superimpose a line plot onto a histogram but I'm not
> >>> having
> >>> any luck. I've attached the dataset. What I did was:
> >>>
> >>>> hist(data,freq=F)
> >>>
> >>> Now I'm trying to superimpose the following points with a line
> >>> connecting
> >>> them onto the histogram:
> >>>
> >>> xy
> >>> 100  0.535665393824959
> >>> 200  0.212744329736556
> >>> 300  0.0844933242968584
> >>> 400  0.0335572838043417
> >>> 500  0.0133275771274986
> >>> 600  0.00529316714442912
> >>> 700  0.0021022289461042
> >>> 800  0.000834919136549392
> >>> 900  0.000331595645597124
> >>> 1000 0.000131696193518099
> >>> 1100 5.2304327929049e-05
> >>> 1200 2.07731343406939e-05
> >>>
> >>> Basically, the x values correspond to the break points in the
> >>> histogram.
> >>> Next I used the command
> >>>
> >>>> points(x,y,type="l")
> >>>
> >>> But for some reason, the line plot is shifted to the right and
> >> doesn't
> >>> line
> >>> up with the histogram.
> >>>
> >>> Thanks for the help!
> >>>
> >>> Edwin Lei
> >>>
> >>> __
> >>> R-help@r-project.org mailing list
> >>>
> >>> 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.
__
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] Hex Decimal Convert

2008-04-06 Thread Edwin Sendjaja
Hello,

I have a data with hexdecimal. But GNU R convert it to strange number. How
can I get that hexdecimal showing in the R-table?

---


-- My Data-Table:
  Sender_ID Receiver_ID   Other_ID
6565  0x47780439   0x   0x   0

---


 R-Table:

6565 1199047737   0  0   0



Kind Regards,

Edwin

__
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] Hex Decimal Convert

2008-04-06 Thread Edwin Sendjaja
Hello,

I have a data with hexdecimal. But GNU R convert it to strange number. How can 
I get that hexdecimal showing in the R-table?


-
My Data-Table:
  Sender_ID Receiver_ID   Other_ID
6565  0x47780439   0x   0x   0


R-Table:

6565 1199047737   0  0   0




Kind Regards,

Edwin

__
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] Hex Decimal Convert

2008-04-06 Thread Edwin Sendjaja

Dear John, 

Thank you.

Is there any possibility to get original stored number printed.

Because i have another coloum like:

Protocol
"TCP"


This is gonna cause probleme (as you notice before).

I dont really understand what you mean with a list. i am new with R. 

Thanks,

Edwin


Am Sonntag, 6. April 2008 21:38:19 schrieb John Fox:
> Dear Edwin,
>
> There's a distinction between the way in which a number is stored
> internally and the way in which it's printed. R is reading the hex
> numbers correctly but is printing them in decimal. You can assign the
> class "hexmode" to the vector containing the data and then it will
>
> print in hex:
> > data <- c(6565, 0x47780439, 0x, 0x, 0)
> > data
>
> [1]   6565 1199047737  0  0  0
>
> > class(data) <- "hexmode"
> > data
>
> [1] "19a5" "47780439" "" "" ""
>
> Notice that the whole vector is printed in hex. If you don't want that,
> then you could put the data into a list with some members of class
> "hexmode" and others not.
>
> I hope this helps,
>  John
>
>
>
> On Sun, 6 Apr 2008 20:52:20 +0100
>
>  Edwin Sendjaja <[EMAIL PROTECTED]> wrote:
> > Hello,
> >
> > I have a data with hexdecimal. But GNU R convert it to strange
> > number. How can
> > I get that hexdecimal showing in the R-table?
>
> ---
>--
>
> > My Data-Table:
> >   Sender_ID Receiver_ID   Other_ID
> > 6565  0x47780439   0x   0x   0
>
> ---
>-
>
> > R-Table:
> >
> > 6565 1199047737   0  0   0
> >
> >
> >
> >
> > Kind Regards,
> >
> > Edwin
> >
> > __
> > 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.
>
> 
> John Fox, Professor
> Department of Sociology
> McMaster University
> Hamilton, Ontario, Canada
> http://socserv.mcmaster.ca/jfox/
>
> __
> 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] Hex Decimal Convert

2008-04-07 Thread Edwin Sendjaja

Dear John,

Am Montag, 7. April 2008 01:43:07 schrieb John Fox:
> Dear Edwin,
>
> On Mon, 7 Apr 2008 01:14:35 +0100
>
>  Edwin Sendjaja <[EMAIL PROTECTED]> wrote:
> > Dear John,
> >
> > Thank you.
> >
> > Is there any possibility to get original stored number printed.
>
> R is a programming language, so you could in principle read an input
> line as character data, break it into its components, and output each
> component in whatever format you wished. That would require some work.
> There might be a simpler approach, but I'm not aware of it.
>

Do you have any guide with similar example?(links or website)?because i can 
imagine what you mean. I have also the same idea. But I dont know how to do 
it.

> > Because i have another coloum like:
> >
> > Protocol
> > "TCP"
>
> The previous example that you send consisted entirely of numeric data
> and had only one line. Assuming that there are several lines, you could
> read the data into a data frame via read.table() and exercise some
> control over how each column is read. See ?read.table. You could then
> deal separately with the columns.
>
> > This is gonna cause probleme (as you notice before).
>
> I'm afraid that I didn't notice since there was no character data in
> your previous example.
>

I meant, you told me before that the whole vector will be printed in hex. 


> > I dont really understand what you mean with a list. i am new with R.
>
> It's probably unreasonable to expect to be able to use a programming
> language without reading something about it. One place to start is with
> the introductory manual distributed with R, which discusses lists in
> Section 6.1. Alternatively, you could read one of a number of books on
> R; many are listed at <http://www.r-project.org/doc/bib/R-books.html>.
>
> Regards,
>  John
>
> > Thanks,
> >
> > Edwin
> >
> > Am Sonntag, 6. April 2008 21:38:19 schrieb John Fox:
> > > Dear Edwin,
> > >
> > > There's a distinction between the way in which a number is stored
> > > internally and the way in which it's printed. R is reading the hex
> > > numbers correctly but is printing them in decimal. You can assign
> >
> > the
> >
> > > class "hexmode" to the vector containing the data and then it will
> > >
> > > print in hex:
> > > > data <- c(6565, 0x47780439, 0x, 0x, 0)
> > > > data
> > >
> > > [1]   6565 1199047737  0  0  0
> > >
> > > > class(data) <- "hexmode"
> > > > data
> > >
> > > [1] "19a5" "47780439" "" "" ""
> > >
> > > Notice that the whole vector is printed in hex. If you don't want
> >
> > that,
> >
> > > then you could put the data into a list with some members of class
> > > "hexmode" and others not.
> > >
> > > I hope this helps,
> > >  John
> > >
> > >
> > >
> > > On Sun, 6 Apr 2008 20:52:20 +0100
> > >
> > >  Edwin Sendjaja <[EMAIL PROTECTED]> wrote:
> > > > Hello,
> > > >
> > > > I have a data with hexdecimal. But GNU R convert it to strange
> > > > number. How can
> > > > I get that hexdecimal showing in the R-table?
>
> ---
>
> > >--
> > >
> > > > My Data-Table:
> > > >   Sender_ID Receiver_ID   Other_ID
> > > > 6565  0x47780439   0x   0x   0
>
> ---
>
> > >-
> > >
> > > > R-Table:
> > > >
> > > > 6565 1199047737   0  0   0
> > > >
> > > >
> > > >
> > > >
> > > > Kind Regards,
> > > >
> > > > Edwin
> > > >
> > > > __
> > > > 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.
> >
> > > 
> > > John Fox, Professor
>

[R] Legend position outside

2008-04-11 Thread Edwin Sendjaja
Hello,

Is it possible to get the legend box outside the graphic?


Kind regards,

Edwin

__
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] Legend position outside

2008-04-11 Thread Edwin Sendjaja
Hello,

Is it possible to get the legend box outside the graphic?


Kind regards,

Edwin

__
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] Legend position outside

2008-04-11 Thread Edwin Sendjaja
Hello Gred,

I try to read R-Reference, but I cant understand it.

What does par (xpd=NA)? and par('usr')) mean? Thank you.






Kind regards,

Edwin 



Am Freitag, 11. April 2008 19:19:24 schrieben Sie:
> Yes, here is one way:
> > plot(1:10, pch=1:2)
> > par(xpd=NA)
> > tmp.u <- par('usr')
> > legend(tmp.u[1], tmp.u[4], xjust=0, yjust=0, c('a','b'), pch=1:2)
>
> You will probably want to increase the margins for a real case.  See
> ?par and the 'xpd' entry for details on the clipping and ?legend for
> more details on creating the legend.
>
> Hope this helps,

__
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] Mapping file-Legend- from 2 Files/Tables

2008-04-11 Thread Edwin Sendjaja
Hello,

I have got 2  Tables from different files:

Table 1 (lets say file: Salesman.data)


  | ID  | User_ID
---
1| 1   |   4
2| 2   |   6
3| 3   |   7
4| 4   |   2
5| 5   |   3



Table2 (file: Employee.data)
--


  | User_ID  | Name
--
1|   1  |   Donna
2|   2  |   John
3|   3  |   Michael
4|   4  |   Wolf
5|   5  |   Tim
6|   6  |   Edward
7|   7  |   Shaun



What i want do is:


I want to map the table 2 into table 1.
instead of User_ID I want to use the name of the person which is related to 
the User_ID.



The legend should look like this

 _
 |LEGEND   |
 |-|
 |   -2- John   |
 |   -3- Michael  |
 |   -4- Wolf   |
 |   -6-Edward|
 |   -7-   Shaun  |
  --


Does anyone know how I can create such a mapping legend?
Is there any good command to do this?

I've tried using "replace" but this is not a good solution. because it 
replaces only 1 values.


Kind Regards, 

Edwin Sendjaja

__
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] Mapping file-Legend- from 2 Files/Tables

2008-04-12 Thread Edwin Sendjaja

Does anyone know how to solve this. I am so desperate. 

I'd be terribly grateful for any help.


Am Samstag, 12. April 2008 05:19:16 schrieb Edwin Sendjaja:
> Hello,
>
> I have got 2  Tables from different files:
>
> Table 1 (lets say file: Salesman.data)
> 
>
>   | ID  | User_ID
>
> ---
> 1| 1   |   4
> 2| 2   |   6
> 3| 3   |   7
> 4| 4   |   2
> 5| 5   |   3
>
>
> 
> Table2 (file: Employee.data)
> --
>
>   | User_ID  | Name
>
> --
> 1|   1  |   Donna
> 2|   2  |   John
> 3|   3  |   Michael
> 4|   4  |   Wolf
> 5|   5  |   Tim
> 6|   6  |   Edward
> 7|   7  |   Shaun
>
>
>
> What i want do is:
>
>
> I want to map the table 2 into table 1.
> instead of User_ID I want to use the name of the person which is related to
> the User_ID.
>
>
>
> The legend should look like this
>
>  _
>
>  |LEGEND   |
>  |-|
>  |   -2- John   |
>  |   -3- Michael  |
>  |   -4- Wolf   |
>  |   -6-Edward|
>  |   -7-   Shaun  |
>
>   --
>
>
> Does anyone know how I can create such a mapping legend?
> Is there any good command to do this?
>
> I've tried using "replace" but this is not a good solution. because it
> replaces only 1 values.
>
>
> Kind Regards,
>
> Edwin Sendjaja
>
> __
> 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] Mapping file-Legend- from 2 Files/Tables

2008-04-13 Thread Edwin Sendjaja
Hello,


Because no one has answered this. I presume that no one knows the soluition.




Fortunately, I found the solution:

Keyword: merge()
--
table1<-read.table("Salesman.data")
table2<-read.table("Employee.data")

data<-merge(table1, table2, by.x="User_ID", by.y="User_ID")  


result<-data$Name (for example)

Thank you.



Kind Regards,


Edwin Sendjaja 

Am Samstag, 12. April 2008 19:40:03 schrieb Edwin Sendjaja:
> Does anyone know how to solve this. I am so desperate.
>
> I'd be terribly grateful for any help.
>
> Am Samstag, 12. April 2008 05:19:16 schrieb Edwin Sendjaja:
> > Hello,
> >
> > I have got 2  Tables from different files:
> >
> > Table 1 (lets say file: Salesman.data)
> > 
> >
> >   | ID  | User_ID
> >
> > ---
> > 1| 1   |   4
> > 2| 2   |   6
> > 3| 3   |   7
> > 4| 4   |   2
> > 5| 5   |   3
> >
> >
> > 
> > Table2 (file: Employee.data)
> > --
> >
> >   | User_ID  | Name
> >
> > --
> > 1|   1  |   Donna
> > 2|   2  |   John
> > 3|   3  |   Michael
> > 4|   4  |   Wolf
> > 5|   5  |   Tim
> > 6|   6  |   Edward
> > 7|   7  |   Shaun
> >
> >
> >
> > What i want do is:
> >
> >
> > I want to map the table 2 into table 1.
> > instead of User_ID I want to use the name of the person which is related
> > to the User_ID.
> >
> >
> >
> > The legend should look like this
> >
> >  _
> >
> >  |LEGEND   |
> >  |-|
> >  |   -2- John   |
> >  |   -3- Michael  |
> >  |   -4- Wolf   |
> >  |   -6-Edward|
> >  |   -7-   Shaun  |
> >
> >   --
> >
> >
> > Does anyone know how I can create such a mapping legend?
> > Is there any good command to do this?
> >
> > I've tried using "replace" but this is not a good solution. because it
> > replaces only 1 values.
> >
> >
> > Kind Regards,
> >
> > Edwin Sendjaja
> >
> > __
> > 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] Merging daily and weekly data

2008-04-14 Thread Edwin Sendjaja

Hi Oystein,


Maybe this is what you are looking for:


Keyword: merge()
--
table1<-read.table("daily.data")
table2<-read.table("weekly.data")


(maybe you need to create a new common coloumn for daily and weekly data set.   
For example: year_week)

data<-merge(table1, table2, by.x="year_week", by.y="year_week")  


data




I hope it helps,

Edwin Sendjaja

Am Montag, 14. April 2008 11:09:12 schrieb Øystein Myrland:
> Dear R-help group,
>
> I have a dataset with daily closing prices from a stock exchange
> (consecutive 5 trading days) from a firm trading a specific commodity. The
> date variable looks like:
>
> quote_date
> 20080411
>
> With the format; mmdd.
>
> Moreover, I have another data set with a (average) weekly price of the
> underlying commodity. The date variables in this dataset are only year and
> a week number.
>
> I would like to calculate a common date number or ID based on week number
> that enables me to merge these two datasets, so that it looks like this:
>
> quote_dateyearweekweek.price
> 20080407  200815  27.45
> 20080408  200815  27.45
> 20080409  200815  27.45
> 20080410  200815  27.45
> 20080411  200815  27.45
>
> The weekly price is constant for the 5 trading days in the daily file. Any
> good suggestions on how to do this?
>
> All the best,
> Oystein
>
> __
> 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] 3-D-Plot

2008-04-16 Thread Edwin Sendjaja
Hello,

I've got some problems. I hope someone can help me.

First question:
I am trying to get grid on scatterplot3d (from scatterplot3d package). It 
seems that scatterplot3d draw on grip on X and Z side. Is it possible to get 
Grid on the whole Box?

Second question:
Is it possible to use the standard package drawing 3d-plot(without 
scatterplot3d) ?because now I have already 2d-plot. I just want to add the 
z-axis.

Third question:
What is the best 3d-plot? it seems that scatterplot3 doesn't support anything( 
like turning the box vertically. I think, angle parameter just turn the box  
horisontally. I might wrong with this.


Thank a lot in advance

Edwin

__
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] 3-D-Plot

2008-04-17 Thread Edwin Sendjaja

Hi Uwe,

Thanks for your answer.

What is the different between rgl and scatterplot3d? I dont need a graphik 
like vulcano. I just need 3D-"dot"-plot.


Am Donnerstag, 17. April 2008 09:03:17 schrieb Uwe Ligges:
> Edwin Sendjaja wrote:
> > Hello,
> >
> > I've got some problems. I hope someone can help me.
> >
> > First question:
> > I am trying to get grid on scatterplot3d (from scatterplot3d package). It
> > seems that scatterplot3d draw on grip on X and Z side. Is it possible to
> > get Grid on the whole Box?
>
> At least there is no build in function to do it.
>
> > Second question:
> > Is it possible to use the standard package drawing 3d-plot(without
> > scatterplot3d) ?because now I have already 2d-plot. I just want to add
> > the z-axis.
>
> See, for example, ?cloud in package "lattice", ?plot3d in package "rgl",
>
> > Third question:
> > What is the best 3d-plot? it seems that scatterplot3 doesn't support
> > anything( like turning the box vertically. I think, angle parameter just
> > turn the box horisontally. I might wrong with this.
>
> You are right.
>
> Best wishes,
> Uwe
>
> > Thank a lot in advance
> >
> > Edwin
> >
> > __
> > 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] 3-D-Plot

2008-04-17 Thread Edwin Sendjaja

Hi Uwe,

I decided to use scatterplot3d, because it looks better.
I have some questions:

Is it possible to get 1 axis( for example: z-axis) not as numeric, but as 
character.

Because I have date set like this:

x=relative Time: 0,3 ms; 0,5ms, etc
y=Delay:10 ms, 20 ms, etc
z= Host: cnn.com, heise.de,etc

If no, can you tell me little how to modify the code to get this. Thank you.

another question:

How can I change the width line of the axis (x,y,z). The default line is for 
me too thin.


Thank you in advance,


Edwin Sendjaja 

Am Donnerstag, 17. April 2008 14:43:39 schrieb Uwe Ligges:
> Edwin Sendjaja wrote:
> > Hi Uwe,
> >
> > Thanks for your answer.
> >
> > What is the different between rgl and scatterplot3d? I dont need a
> > graphik like vulcano. I just need 3D-"dot"-plot.
>
> Sure, rgl can do it as well.
> Difference is that scatterplot3d is based on R's standard devices while
> rgl is based on an OpenGL device. Hence rgl is much more flexible and
> can rotate things and easily draws nice transparent forms, but
> scatterplot3d is nice for printing to 2D in different formats at the end.
>
> Uwe
>
> > Am Donnerstag, 17. April 2008 09:03:17 schrieb Uwe Ligges:
> >> Edwin Sendjaja wrote:
> >>> Hello,
> >>>
> >>> I've got some problems. I hope someone can help me.
> >>>
> >>> First question:
> >>> I am trying to get grid on scatterplot3d (from scatterplot3d package).
> >>> It seems that scatterplot3d draw on grip on X and Z side. Is it
> >>> possible to get Grid on the whole Box?
> >>
> >> At least there is no build in function to do it.
> >>
> >>> Second question:
> >>> Is it possible to use the standard package drawing 3d-plot(without
> >>> scatterplot3d) ?because now I have already 2d-plot. I just want to add
> >>> the z-axis.
> >>
> >> See, for example, ?cloud in package "lattice", ?plot3d in package "rgl",
> >>
> >>> Third question:
> >>> What is the best 3d-plot? it seems that scatterplot3 doesn't support
> >>> anything( like turning the box vertically. I think, angle parameter
> >>> just turn the box horisontally. I might wrong with this.
> >>
> >> You are right.
> >>
> >> Best wishes,
> >> Uwe
> >>
> >>> Thank a lot in advance
> >>>
> >>> Edwin
> >>>
> >>> __
> >>> 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.
>
> __
> 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] Bug in Merge?

2008-04-18 Thread Edwin Sendjaja
Hello,


I find strange number in my merge data set.

My first coloumn consist row numbers.

---
my.data:


AbsTime   RelTime PE_IDEvent  Delay

4238   1208514343.812086107.153637  4   EKA  51620

##
Host.data:


 ID   Host

4   4vicky.planetlab.ntua.gr



data<-read.table("my.data")
mapping<-read.table("Host.data")

mergeXY <- merge(data,mapping, by.x="PE_ID", by.y="ID")


If I merge these data then i get:

"PE_ID" "AbsTime" "RelTime" "Ereignis"  "Delay" "Host"
"2" 4 1208514343.81209 107.153637 "EndpointKeepAlive" " 
51620 "vicky.planetlab.ntua.gr"


---

The first problem:

Why is the row number "2" now? Where does this nummber come from?

I think, there is a conflict between my row number from data and mapping (4238 
and 4).

The second problem:

Why is my AbsTime: 1208514343.81209? It was 1208514343.812086. It is 1 digit 
less. how can I avoid this?



I hope someone could answer this.



Thank you in advance,



Edwin

__
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] Large Dataset

2009-01-06 Thread Edwin Sendjaja
Hi alI,

I  have a 3.1 GB Dataset ( with  11 coloumns and lots data in int and string). 
If I use read.table; it takes very long. It seems that my RAM is not big 
enough (overload) I have 3.2 RAM and  7GB SWAP, 64 Bit Ubuntu.

Is there a best sultion to read a large data R? I have seen, that people 
suggest to use bigmemory package, ff. But it seems very complicated.  I dont 
know how to start with that packages.

i have tried to use bigmemory. But I got some kind of errors.  Then I gave up.


can someone give me an simple example how ot use ff or bigmemory?or maybe re 
better sollution?



Thank you in advance,


Edwin

__
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] Large Dataset

2009-01-06 Thread Edwin Sendjaja
Hi Simon,

Thank for your reply. 
I have read ?Memory but I dont understand how to use. I am not sure if that 
can solve my problem. Can you tell me more detail?

Thanks,

Edwin

> type
>
> ?memory
>
> into R and that will explain what to do...
>
> S
> - Original Message -
> From: "Edwin Sendjaja" 
> To: 
> Sent: Tuesday, January 06, 2009 11:41 AM
> Subject: [R] Large Dataset
>
> > Hi alI,
> >
> > I  have a 3.1 GB Dataset ( with  11 coloumns and lots data in int and
> > string).
> > If I use read.table; it takes very long. It seems that my RAM is not big
> > enough (overload) I have 3.2 RAM and  7GB SWAP, 64 Bit Ubuntu.
> >
> > Is there a best sultion to read a large data R? I have seen, that people
> > suggest to use bigmemory package, ff. But it seems very complicated.  I
> > dont
> > know how to start with that packages.
> >
> > i have tried to use bigmemory. But I got some kind of errors.  Then I
> > gave up.
> >
> >
> > can someone give me an simple example how ot use ff or bigmemory?or maybe
> > re
> > better sollution?
> >
> >
> >
> > Thank you in advance,
> >
> >
> > Edwin
> >
> > __
> > 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] Large Dataset

2009-01-06 Thread Edwin Sendjaja
I think he meant:
?Memory

edwin


>   When I do it on a Mac installation I get:
>
> Help for the topic "memory" was not found.
>
> Is that a Linux-specific function? Or perhaps you meant to type:
>
> ?Memory
>
> Which does produce useful information.
>
> --
> David Winsemius
>
>  > sessionInfo()
>
> R version 2.8.0 Patched (2008-11-14 r46932)
> i386-apple-darwin9.5.0
>
> locale:
> en_US.UTF-8/en_US.UTF-8/C/C/en_US.UTF-8/en_US.UTF-8
>
> attached base packages:
> [1] grid  stats graphics  grDevices utils datasets
> methods   base
>
> other attached packages:
> [1] vcd_1.2-1colorspace_1.0-0 MASS_7.2-45  rattle_2.4.0
>
> loaded via a namespace (and not attached):
> [1] tools_2.8.0
>
> On Jan 6, 2009, at 6:43 AM, Simon Pickett wrote:
> > type
> >
> > ?memory
> >
> > into R and that will explain what to do...
> >
> > S
> > - Original Message - From: "Edwin Sendjaja" 
> > To: 
> > Sent: Tuesday, January 06, 2009 11:41 AM
> > Subject: [R] Large Dataset
> >
> >> Hi alI,
> >>
> >> I  have a 3.1 GB Dataset ( with  11 coloumns and lots data in int
> >> and string).
> >> If I use read.table; it takes very long. It seems that my RAM is
> >> not big
> >> enough (overload) I have 3.2 RAM and  7GB SWAP, 64 Bit Ubuntu.
> >>
> >> Is there a best sultion to read a large data R? I have seen, that
> >> people
> >> suggest to use bigmemory package, ff. But it seems very
> >> complicated.  I dont
> >> know how to start with that packages.
> >>
> >> i have tried to use bigmemory. But I got some kind of errors.  Then
> >> I gave up.
> >>
> >>
> >> can someone give me an simple example how ot use ff or bigmemory?or
> >> maybe re
> >> better sollution?
> >>
> >>
> >>
> >> Thank you in advance,
> >>
> >>
> >> Edwin
> >>
> >> __
> >> 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] Large Dataset

2009-01-06 Thread Edwin Sendjaja
Hi Simon,

My RAM is only 3.2 GB (actually it should be 4 GB, but my Motherboard doesnt 
support it.

R use almost of all my RAM and half of my swap. I think memory.limit will not 
solve my problem.  It seems that I need  RAM.

Unfortunately, I can't buy more RAM.

Why R is slow reading big data set?


Edwin

> Only a couple of weeks ago I had to deal with this.
>
> adjust the memory limit as follows, although you might not want 4000, that
> is quite high
>
> memory.limit(size = 4000)
>
> Simon.
>
> ----- Original Message -
> From: "Edwin Sendjaja" 
> To: "Simon Pickett" 
> Cc: 
> Sent: Tuesday, January 06, 2009 12:24 PM
> Subject: Re: [R] Large Dataset
>
> > Hi Simon,
> >
> > Thank for your reply.
> > I have read ?Memory but I dont understand how to use. I am not sure if
> > that
> > can solve my problem. Can you tell me more detail?
> >
> > Thanks,
> >
> > Edwin
> >
> >> type
> >>
> >> ?memory
> >>
> >> into R and that will explain what to do...
> >>
> >> S
> >> - Original Message -
> >> From: "Edwin Sendjaja" 
> >> To: 
> >> Sent: Tuesday, January 06, 2009 11:41 AM
> >> Subject: [R] Large Dataset
> >>
> >> > Hi alI,
> >> >
> >> > I  have a 3.1 GB Dataset ( with  11 coloumns and lots data in int and
> >> > string).
> >> > If I use read.table; it takes very long. It seems that my RAM is not
> >> > big
> >> > enough (overload) I have 3.2 RAM and  7GB SWAP, 64 Bit Ubuntu.
> >> >
> >> > Is there a best sultion to read a large data R? I have seen, that
> >> > people
> >> > suggest to use bigmemory package, ff. But it seems very complicated. 
> >> > I dont
> >> > know how to start with that packages.
> >> >
> >> > i have tried to use bigmemory. But I got some kind of errors.  Then I
> >> > gave up.
> >> >
> >> >
> >> > can someone give me an simple example how ot use ff or bigmemory?or
> >> > maybe
> >> > re
> >> > better sollution?
> >> >
> >> >
> >> >
> >> > Thank you in advance,
> >> >
> >> >
> >> > Edwin
> >> >
> >> > __
> >> > 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] Large Dataset

2009-01-06 Thread Edwin Sendjaja
Hi Simons,

Is SAS more powerfull than R? 

Well, I think I cannot afford to buy SAS.

actually, my computer isn't  really slow. I think 4GB RAM is big enough for 
personal PC.  I am just wondering, why R running so slow with these specs to 
handling 3 GB data set. What if the data set were 1 TB?mmm..


Edwin

> Hi,
>
> I am not very knowledgeable about this kind of stuff but my guess is that
> if you have a fairly slow computer and massive data sets there isnt alot
> you can do except get a better computer, buy more RAM or use something like
> SAS instead?
>
> Hopefully someone else will chip in Edwin, best of luck.
>
> Simon.
>
>
> - Original Message -
> From: "Edwin Sendjaja" 
> To: "Simon Pickett" 
> Cc: 
> Sent: Tuesday, January 06, 2009 2:53 PM
> Subject: Re: [R] Large Dataset
>
> > Hi Simon,
> >
> > My RAM is only 3.2 GB (actually it should be 4 GB, but my Motherboard
> > doesnt
> > support it.
> >
> > R use almost of all my RAM and half of my swap. I think memory.limit will
> > not
> > solve my problem.  It seems that I need  RAM.
> >
> > Unfortunately, I can't buy more RAM.
> >
> > Why R is slow reading big data set?
> >
> >
> > Edwin
> >
> >> Only a couple of weeks ago I had to deal with this.
> >>
> >> adjust the memory limit as follows, although you might not want 4000,
> >> that
> >> is quite high
> >>
> >> memory.limit(size = 4000)
> >>
> >> Simon.
> >>
> >> - Original Message -
> >> From: "Edwin Sendjaja" 
> >> To: "Simon Pickett" 
> >> Cc: 
> >> Sent: Tuesday, January 06, 2009 12:24 PM
> >> Subject: Re: [R] Large Dataset
> >>
> >> > Hi Simon,
> >> >
> >> > Thank for your reply.
> >> > I have read ?Memory but I dont understand how to use. I am not sure if
> >> > that
> >> > can solve my problem. Can you tell me more detail?
> >> >
> >> > Thanks,
> >> >
> >> > Edwin
> >> >
> >> >> type
> >> >>
> >> >> ?memory
> >> >>
> >> >> into R and that will explain what to do...
> >> >>
> >> >> S
> >> >> - Original Message -
> >> >> From: "Edwin Sendjaja" 
> >> >> To: 
> >> >> Sent: Tuesday, January 06, 2009 11:41 AM
> >> >> Subject: [R] Large Dataset
> >> >>
> >> >> > Hi alI,
> >> >> >
> >> >> > I  have a 3.1 GB Dataset ( with  11 coloumns and lots data in int
> >> >> > and
> >> >> > string).
> >> >> > If I use read.table; it takes very long. It seems that my RAM is
> >> >> > not big
> >> >> > enough (overload) I have 3.2 RAM and  7GB SWAP, 64 Bit Ubuntu.
> >> >> >
> >> >> > Is there a best sultion to read a large data R? I have seen, that
> >> >> > people
> >> >> > suggest to use bigmemory package, ff. But it seems very
> >> >> > complicated. I dont
> >> >> > know how to start with that packages.
> >> >> >
> >> >> > i have tried to use bigmemory. But I got some kind of errors.  Then
> >> >> > I
> >> >> > gave up.
> >> >> >
> >> >> >
> >> >> > can someone give me an simple example how ot use ff or bigmemory?or
> >> >> > maybe
> >> >> > re
> >> >> > better sollution?
> >> >> >
> >> >> >
> >> >> >
> >> >> > Thank you in advance,
> >> >> >
> >> >> >
> >> >> > Edwin
> >> >> >
> >> >> > __
> >> >> > 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] Large Dataset

2009-01-06 Thread Edwin Sendjaja
Hi Ben,

Using colClasses doensnt improve the performace much. 

With the data, I will calculate the mean, min, max, and standard deviance.

I have also failed to import the data in a Mysql Database. I dont have much 
knowledge in Mysql.

Edwin



> Edwin Sendjaja  web.de> writes:
> > Hi Simon,
> >
> > My RAM is only 3.2 GB (actually it should be 4 GB, but my Motherboard
> > doesnt support it.
> >
> > R use almost of all my RAM and half of my swap. I think memory.limit will
> > not solve my problem.  It seems that I need  RAM.
> >
> > Unfortunately, I can't buy more RAM.
> >
> > Why R is slow reading big data set?
> >
> > Edwin
>
>   Start with FAQ 7.28 ,
> http://cran.r-project.org/doc/FAQ/R-FAQ.html#Why-is-read_002etable_0028_002
>9-so-inefficient_003f
>
>   However, I think you're going to have much bigger problems
> if you have a 3.1G data set and a total of 3.2G of RAM: what do
> you expect to be able to do with this data set once you've read
> it in?  Have you considered storing it in a database and accessing
> just the bits you need at any one time?
>
>   Ben Bolker
>
> __
> 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] Large Dataset

2009-01-06 Thread Edwin Sendjaja
Bellow, you  can see the R data. 

But this stucks even in first line (read.table..). 

I dont know how to calculate this and write the result into a new table.


Edwin





data <- read.table("test.data")

data <- subset(data, (data$Zusatz!="60") & (data$Zusatz!="0"))



 list(EndpointKeepAliveTimeOutIntervalLimit,"", PE_ID,"", Registrar, Region, 
RelTime)))
split.data <- with(data, split(Zusatz, 
list(EndpointKeepAliveTimeOutIntervalLimit, PE_ID, Run)))

#Find the min, max and std dev for each element in the resulting list
mins <- sapply(split.data, min)
maxs <- sapply(split.data, max)
devs <- sapply(split.data, sd)
mean <- sapply(split.data, mean)


name.list <- strsplit(names(split.data), "\\.")

endpointkeepalivetimeoutintervallimit <- as.numeric(sapply(name.list, 
function(x) x[[1]]))
pe_id <- sapply(name.list, function(x) x[[2]])
run <- sapply(name.list, function(x) x[[3]])

#Now construct a new data frame from these values
output <-
data.frame(EndpointKeepAliveTimeOutIntervalLimit=endpointkeepalivetimeoutintervallimit,
 
PE_ID=pe_id, Run=run, Min=mins, Max=maxs, Standardabweichung=devs, Mean=mean)


output <- subset(output, (output$Min !="Inf"))
output_sort<-sort(output$EndpointKeepAliveTimeOutIntervalLimit)

output<-output[order(output$EndpointKeepAliveTimeOutIntervalLimit, 
partial=order(output$PE_ID)),]
rownames(output) <- seq(length=nrow(output))


write.table(output,file=Sys.getenv("filepdf"), quote = FALSE)





> For the mean, min, max and standard deviance (deviation I suppose) you
> don't need to store all data in the memory, you can calculate them
> incrementally. Read the file line by line (if it is a text file).
>
> G.
>
> On Tue, Jan 6, 2009 at 6:10 PM, Edwin Sendjaja  wrote:
> > Hi Ben,
> >
> > Using colClasses doensnt improve the performace much.
> >
> > With the data, I will calculate the mean, min, max, and standard
> > deviance.
> >
> > I have also failed to import the data in a Mysql Database. I dont have
> > much knowledge in Mysql.
> >
> > Edwin
> >
> >> Edwin Sendjaja  web.de> writes:
> >> > Hi Simon,
> >> >
> >> > My RAM is only 3.2 GB (actually it should be 4 GB, but my Motherboard
> >> > doesnt support it.
> >> >
> >> > R use almost of all my RAM and half of my swap. I think memory.limit
> >> > will not solve my problem.  It seems that I need  RAM.
> >> >
> >> > Unfortunately, I can't buy more RAM.
> >> >
> >> > Why R is slow reading big data set?
> >> >
> >> > Edwin
> >>
> >>   Start with FAQ 7.28 ,
> >> http://cran.r-project.org/doc/FAQ/R-FAQ.html#Why-is-read_002etable_0028_
> >>002 9-so-inefficient_003f
> >>
> >>   However, I think you're going to have much bigger problems
> >> if you have a 3.1G data set and a total of 3.2G of RAM: what do
> >> you expect to be able to do with this data set once you've read
> >> it in?  Have you considered storing it in a database and accessing
> >> just the bits you need at any one time?
> >>
> >>   Ben Bolker
> >>
> >> __
> >> 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.


[R] Package

2009-01-14 Thread Edwin Wibisono
Hello, My name is edwin, I come from Indonesia, Can you help me,
I want package  which is contain lqs and lmsreg.
I need fast...

Can you help me to create
bootstrap regression

??
Thx

Edwin

[[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] Project Robust & Linier Regresssion

2009-01-15 Thread Edwin Wibisono
Hello, I'm EDWIN, I create (make) GUI, with call many function
but I don't know why when I call function I can't. if without function, Yes
I can..

can you help me ? can you make this, become true with full code?
Can you help me to
create data.entry with interface
LM  - BETA1.HAT - BETA2.HAT SD.BETA1.HAT HAT SD.BETA2.HAT  RLM  - BETA1.HAT
- BETA2.HAT SD.BETA1.HAT HAT SD.BETA2.HAT
2
10   value
100


Thx
Edwwin
library(boot)
library(bootstrap)
library(MASS)   # MASS berisi tools untuk fitting robust regression 
library(tcltk)
library(stats)   
library(rpanel)


#
ambil<-function() {
data <- read.csv("F:/data.csv") 
plot<-plot(data[,2],data[,3], xlab="Euro",ylab="Rupiah",main="Plot Euro, dan 
Rupiah")
 }

data <- read.csv("F:/data.csv") 
x <- data[,2]
y <- data[,3]

#
function seluruhlinier(){
plot(x, y)
fred <- lm(y ~ x)
curve(predict(fred, data.frame(x = x)), add = TRUE)
beta1.hat <- coefficients(fred)[1]
beta2.hat <- coefficients(fred)[2]
n <- length(x)

beta1.star <- double(nboot)
beta2.star <- double(nboot)
for (i in 1:nboot) {
k.star <- sample(n, replace = TRUE)
x.star <- x[k.star]
y.star <- y[k.star]
sally <- lm(y.star ~ x.star )
curve(predict(sally, data.frame(x.star = x)),
add = TRUE, col = "plum")
beta1.star[i] <- coefficients(sally)[1]
beta2.star[i] <- coefficients(sally)[2]
}
points(x, y, pch = 16)
curve(predict(fred, data.frame(x = x)),
   add = TRUE, lwd = 2)
data.frame (beta1.hat,sd(beta1.star),beta2.hat,sd(beta2.star),beta2.hat / 
sd(beta2.star))
}

#

function seluruhrobust(){
plot(x, y)
fred <- rlm(y ~ x)
curve(predict(fred, data.frame(x = x)), add = TRUE)
beta1.hat <- coefficients(fred)[1]
beta2.hat <- coefficients(fred)[2]
n <- length(x)

beta1.star <- double(nboot)
beta2.star <- double(nboot)
for (i in 1:nboot) {
k.star <- sample(n, replace = TRUE)
x.star <- x[k.star]
y.star <- y[k.star]
sally <- rlm(y.star ~ x.star )
curve(predict(sally, data.frame(x.star = x)),
add = TRUE, col = "plum")
beta1.star[i] <- coefficients(sally)[1]
beta2.star[i] <- coefficients(sally)[2]
}
points(x, y, pch = 16)
curve(predict(fred, data.frame(x = x)),
   add = TRUE, lwd = 2)
data.frame (beta1.hat,sd(beta1.star),beta2.hat,sd(beta2.star),beta2.hat / 
sd(beta2.star))
}

#
function linier2(){
nboot <- 2
seluruhlinier()
}
#

function linier30(){
nboot <- 30
seluruhlinier()
}
###
function linier100(){
nboot <- 100
seluruhlinier()
}


function robust2(){
nboot <- 2
seluruhrobust()
}
#

function linier30(){
nboot <- 30
seluruhrobust()
}
###
function linier100(){
nboot <- 100
seluruhrobust()
}
###

hitungan<-function()
{
#data.entry(y_hat_linier,y_hat_robust,Residual_linier,Residual_robust)
}






kesimpulan<-function()
{
m4 <- tktoplevel()
tkwm.geometry(m4, "+0+0")
tkpack(fr <- tkframe(m4), side = "top")
tkwm.title(m4, "Kesimpulan")
tkpack(tklabel(fr, text = "Semakin besar bootstrap, semakin besar nilai beta1*, 
dan beta2*, Beta1 topi dan Beta topi2 akan tetap sama jika diulang terus 
menerus", width = "120"), side = "left")

tkpack(fr <- tkframe(m4), side = "top")
tkpack(tkbutton(m4, text = "OK", command = function() tkdestroy(m4)),
side = "right")
}


linier<-function ()
 {
m2 <- tktoplevel()
tkwm.geometry(m2, "+0+0")
tkpack(fr <- tkframe(m2), side = "top")
tkwm.title(m2, "Regresi Linier")
tkpack(tklabel(fr, text = "OUTPUT", width = "50"), side = "left")
tkpack(tkbutton(m2, text = "Regresi Linier B = 2",command=linier2), side = 
"left") 
tkpack(tkbutton(m2, text = "Regresi Linier B = 30",command=linier30), side = 
"left")
tkpack(tkbutton(m2, text = "Regresi Li

[R] My Problem

2009-01-17 Thread Edwin Wibisono
Hello, My name is Edwin, I come from INDONESIA
I have problem

I creating function then I have many calculation
like this
xx<-function(){
a<-sd()
b<-beta1.hat
c<-beta2.hat
data.entry(a,b,c)
}

then
i have function too, almost same


yy<-function(){
d<-sd()
e<-beta1.hat
f<-beta2.hat
data.entry(d,e,f)
}

I have 6 function almost same
then
my problem is
I can't  view output of all data.entry  of 6function


I want this

Iteration   beta1.hat  beta2.hat  sd
10   abc
100 d ef
1000g   h i
1  jk l

Can you help me ?
Thx

[[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] Regression

2009-01-29 Thread Edwin Wibisono
Hello, I have problem
I have a, and b in regression
then I can't plot x,y with (and) a, b lines

can you help me ?

thx

[[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] Is there simple code for this simple financial time series task?

2008-02-19 Thread Edwin Hoyle
My code below makes a data frame with columns for
date, time, and price.  Time on each date runs from 1
to 4.

I'd like to add a new column "ts$closingprice", which
would have the closing price for that date.  To find
the closing price, I'd like to take the price in the
row having the greatest time value for each date. 
Then I'd like to fill that closing price into the
$closingprice column for all other rows having the
same date.

--This appears to be such an easy task, yet is there a
simple way to do it that doesn't require a lot of
cleverness?

dates<-c(1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4)
times<-c(1,2,3,4)
prices<-c(14,15,16,15,15.5,16,14,13,13,11,12,13,14,15,16,15)
ts<-matrix(nrow=16,ncol=3)
ts[,1]<-dates;ts[,2]<-times;ts[,3]<-prices;ts
ts<-as.data.frame(ts);
names(ts)<-c("dates","times","prices");ts

  dates times prices
1  1 1   14.0
2  1 2   15.0
3  1 3   16.0
4  1 4   15.0
5  2 1   15.5
6  2 2   16.0
7  2 3   14.0
8  2 4   13.0
9  3 1   13.0
10 3 2   11.0
11 3 3   12.0
12 3 4   13.0
13 4 1   14.0
14 4 2   15.0
15 4 3   16.0
16 4 4   15.0


  

Never miss a thing.  Make Yahoo your home page.

__
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] Creating Tabel for Mean, Deviance

2008-12-03 Thread Edwin Sendjaja
Hi,

Can someone help me how to create a table for Min, Max, Mean, Deviance.

I have input data like this:

Person Age Child
1  517   2
2  517   0  
3  517   1  
4  5202 
5  520   3  
6  710   1
7  721   4  
8  721   5  
9  721   1


Now i want to create a table for the Min, Max, Deviance, and Mean. from the 
Child Value.

It should  look like this:

  Person  Age Min Max Mean Deviance 

1  517  0  1  0.61  0.62
2  518  1  2 1.61   1.62
3  519  1  4  1.61  2.62
4  520  2  4 2.63   1.42
5  521  1  5  2.61  0.22
6  717  0  1 0.61   0.52
7  718  1 2 1.610.72
8  719  1  4  1.61  0.82
9  720 1 4 2.63 0.12



-


what i can do is only manually:

data<- read.table("test.data")

Min(data$Child), Max(data$Child), Mean(data$Child), Deviance(data$Child)

I only know how to calculate. But i dont know how to buiild the tabell like 
this.


I would appreciate if someone can help me. Thanks in advance.

__
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] Creating Tabel for Mean, Deviance

2008-12-04 Thread Edwin Sendjaja
Hi,

Thank you Stefan, 

I think, this package will do what I want.

Edwin

> Edwin Sendjaja schrieb:
> > Hi,
> >
> > Can someone help me how to create a table for Min, Max, Mean, Deviance.
>
> Try the summaryBy function of the doBy package. The package has an
> excellent vignette (=documentation).
>
> hth
> Stefan

__
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 calculate words in column?

2008-12-06 Thread Edwin Sendjaja
Hi,

I have a table for an 1 week exam result for many classes in school, like 
this:

   Day   Class_ID  TestResult
1   Monday1  Paper Passed 
2   Tuesday1  Oral   Passed
3   Friday   1  Paper  Passed
4   Monday3  Paper Passed
5   Sunday 3  Oral   Passed
6   Monday3  Paper Passed
6   Sunday 3  Paper Passed

How can I sum the Word "Passed" from Result column ( for earch Class_ID and 
each Test), so i can get this following table:


 Class_ID  Test  Passed_Count  
1 1Paper   2 
2 1Oral 1
3 3Oral 1
4 3Paper   3


Passed_Count column is just the Value, how many people passed the exam. In the 
tabell, they are 2 people passed the paper test (Result=Passed).


I hope someone can help me, Or maybe there is an example that i can see.


Thank you in advance

__
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] Shell Bash with R

2007-10-31 Thread Edwin Sendjaja
Hello,

I try to write a bash skript and I want to use the variables from my
bash skript into R. Ist that possible?


My bash skript creates  lots of  *.data files. I want forward these
files directly into R (in x.data.bz2), so that R creates a few data
automatically also in PDF.


For example:

bash created files: hello.data , world.data
how R created these files in pdf? 
please look my plot.R



My plot.R:



source("plotter.R")

data <- loadResults("X.data.bz2")

plotColorMode<- cmColor
plotHideLegend   <- FALSE
plotLegendSizeFactor <- 0.8
plotOwnOutput<- FALSE
plotFontFamily   <- "Helvetica"
plotFontPointsize<- 22
plotWidth<- 10
plotHeight   <- 10
plotConfidence   <- 0.95


mainTitle <- "Deregistrations by Timeout"

xSet <- data$Steps[1]
xTitle <- "Steps"

ySet <- data$Time[s]
yTitle <- "Time]"

zSet <- data$Region
zTitle <- "Region{R}"

vSet <- c()
vTitle <- ""
wSet <- c()
wTitle <- ""


xAxisTicks <- getUsefulTicks(xSet)   # Set to c() for automatic
setting
yAxisTicks <- getUsefulTicks(ySet)   # Set to c() for automatic
setting


pdf("X.data.pdf")
plotstd3(mainTitle,
 xTitle, yTitle, zTitle,
 xSet, ySet, zSet,
 vSet, wSet, vTitle, wTitle,
 xAxisTicks=xAxisTicks,
 yAxisTicks=yAxisTicks,
     type="l",
 colorMode=plotColorMode,
 hideLegend=FALSE,
 legendPos=c(1,1))
dev.off()



Thank you

Edwin

[[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] Rcpp cpp11 and R CMD build

2015-06-24 Thread Edwin van Leeuwen
Hi all,

I've just started using Rcpp and am trying to get cpp11 support working. As
suggested I added [[Rcpp:plugins(cpp11)]] to my source file and a test
function:
// [[Rcpp::export]]
int useCpp11() {
  auto x = 10;
  return x;
}

This works fine when using:
sourceCpp(filename)
from R, but I would like to be able to compile the package from the command
line.
R CMD build mypackage
fails with the following error:
R CMD build ../fluEvidenceSynthesis
* checking for file ‘../fluEvidenceSynthesis/DESCRIPTION’ ... OK
* preparing ‘fluEvidenceSynthesis’:
* checking DESCRIPTION meta-information ... OK
* cleaning src
* installing the package to process help pages
  ---
* installing *source* package ‘fluEvidenceSynthesis’ ...
** libs
g++ -I/usr/share/R/include -DNDEBUG
-I"/home/edwin/R/x86_64-pc-linux-gnu-library/3.2/Rcpp/include"
-I"/home/edwin/R/x86_64-pc-linux-gnu-library/3.2/BH/include"   -fpic  -g
-O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat
-Werror=format-security -D_FORTIFY_SOURCE=2 -g  -c RcppExports.cpp -o
RcppExports.o
g++ -I/usr/share/R/include -DNDEBUG
-I"/home/edwin/R/x86_64-pc-linux-gnu-library/3.2/Rcpp/include"
-I"/home/edwin/R/x86_64-pc-linux-gnu-library/3.2/BH/include"   -fpic  -g
-O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat
-Werror=format-security -D_FORTIFY_SOURCE=2 -g  -c rcpp_hello_world.cpp -o
rcpp_hello_world.o
rcpp_hello_world.cpp: In function ‘int useCpp11()’:
rcpp_hello_world.cpp:33:10: error: ‘x’ does not name a type
 auto x = 10;
  ^
rcpp_hello_world.cpp:34:12: error: ‘x’ was not declared in this scope
 return x;
^
make: *** [rcpp_hello_world.o] Error 1
ERROR: compilation failed for package ‘fluEvidenceSynthesis’
* removing ‘/tmp/RtmpWdUduu/Rinst2b601aa285e9/fluEvidenceSynthesis’
  ---
ERROR: package installation failed


Any help appreciated.

Cheers, Edwin

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] Rcpp cpp11 and R CMD build

2015-06-24 Thread Edwin van Leeuwen
Thank you! I was missing the SystemRequirements. I guess it could be useful
to add this to the example given here:
http://gallery.rcpp.org/articles/simple-lambda-func-c++11/

Cheers, Edwin

On Wed, 24 Jun 2015 at 17:50 Charles Determan  wrote:

> Hi Edwin,
>
> If you look at the build output you will notice that the C++11 compiler
> flag is not being used.  I just created a small package using Rcpp11 and
> your function and it worked without a problem.  I can't give you a specific
> reason without seeing your package but there are some possibilities I would
> guess right away.
>
> 1. Make sure you are 'LinkingTo' Rcpp11 in your DESCRIPTION
> 2. Unless you are using some custom Makevars file, you should set
> 'SystemRequirements: C++11' in your DESCRIPTION
>
> Charles
>
> On Wed, Jun 24, 2015 at 10:07 AM, Edwin van Leeuwen 
> wrote:
>
>> Hi all,
>>
>> I've just started using Rcpp and am trying to get cpp11 support working.
>> As
>> suggested I added [[Rcpp:plugins(cpp11)]] to my source file and a test
>> function:
>> // [[Rcpp::export]]
>> int useCpp11() {
>>   auto x = 10;
>>   return x;
>> }
>>
>> This works fine when using:
>> sourceCpp(filename)
>> from R, but I would like to be able to compile the package from the
>> command
>> line.
>> R CMD build mypackage
>> fails with the following error:
>> R CMD build ../fluEvidenceSynthesis
>> * checking for file ‘../fluEvidenceSynthesis/DESCRIPTION’ ... OK
>> * preparing ‘fluEvidenceSynthesis’:
>> * checking DESCRIPTION meta-information ... OK
>> * cleaning src
>> * installing the package to process help pages
>>   ---
>> * installing *source* package ‘fluEvidenceSynthesis’ ...
>> ** libs
>> g++ -I/usr/share/R/include -DNDEBUG
>> -I"/home/edwin/R/x86_64-pc-linux-gnu-library/3.2/Rcpp/include"
>> -I"/home/edwin/R/x86_64-pc-linux-gnu-library/3.2/BH/include"   -fpic  -g
>> -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat
>> -Werror=format-security -D_FORTIFY_SOURCE=2 -g  -c RcppExports.cpp -o
>> RcppExports.o
>> g++ -I/usr/share/R/include -DNDEBUG
>> -I"/home/edwin/R/x86_64-pc-linux-gnu-library/3.2/Rcpp/include"
>> -I"/home/edwin/R/x86_64-pc-linux-gnu-library/3.2/BH/include"   -fpic  -g
>> -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat
>> -Werror=format-security -D_FORTIFY_SOURCE=2 -g  -c rcpp_hello_world.cpp -o
>> rcpp_hello_world.o
>> rcpp_hello_world.cpp: In function ‘int useCpp11()’:
>> rcpp_hello_world.cpp:33:10: error: ‘x’ does not name a type
>>  auto x = 10;
>>   ^
>> rcpp_hello_world.cpp:34:12: error: ‘x’ was not declared in this scope
>>  return x;
>> ^
>> make: *** [rcpp_hello_world.o] Error 1
>> ERROR: compilation failed for package ‘fluEvidenceSynthesis’
>> * removing ‘/tmp/RtmpWdUduu/Rinst2b601aa285e9/fluEvidenceSynthesis’
>>   ---
>> ERROR: package installation failed
>>
>>
>> Any help appreciated.
>>
>> Cheers, Edwin
>>
>> [[alternative HTML version deleted]]
>>
>> __
>> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>> 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 -- To UNSUBSCRIBE and more, see
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 problem for scatterplot using ggplot

2010-07-28 Thread Edwin Husni Sutanudjaja
Dear all,

I have a memory problem in making a scatter plot of my 17.5 million-pair 
datasets.
My intention to use the "ggplot" package and use the "bin2d". Please find the 
attached script for more details.

Could somebody please give me any clues or tips to solve my problem?? please ...
Just for additional information: I'm running my R script on my 32-bit machine: 
Ubuntu 9.10, hardware: AMD Athlon Dual Core Processor 5200B, memory: 1.7GB.

Many thanks in advance.
Kind Regards, 

-- 
Ir. Edwin H. Sutanudjaja
Dept. of Physical Geography, Faculty of Geosciences, Utrecht University



  __
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] I cannot get species scores to plot with site scores in MDS when I use a distance matrix as input. Problems with NA's?

2011-11-24 Thread Edwin Lebrija Trejos

Hi, First I should note I am relatively new to R so I would appreciate answers 
that take this into account.
 
I am trying to perform an MDS ordination using the function “metaMDS” of the 
“vegan” package. I want to ordinate species according to a set of functional 
traits. “Species” here refers to “sites” in traditional vegetation analyses 
while “traits” here correspond to “species” in such analyses.  
 
My data looks like this:
 
 Trait1   Trait2 Trait3  Trait4  Trait5  Trait…  
Species1 228.44   16.56   1.66   13.22 1 short 
Species2 150.55   28.07   0.41   0.60  1 mid
Species3 NA   25.89 NA   0.55  0 large
Species4 147.70   17.65   0.42   1.12 NA large
Species… 132.68  NA   1.28   2.75  0 short

 
Because the traits have different variable types, different measurement scales, 
and also missing values for some species, I have calculated the matrix of 
species distances using the Gower coefficient of similarity available in 
Package “FD” (which allows missing values). 
My problem comes when I create a bi-plot of species and traits. As I have used 
a distance matrix in function “metaMDS” there are no species scores available. 
This is given as a warning in R: 
 
"> NMDSgowdis<- metaMDS(SpeciesGowdis)
> plot(NMDSgowdis, type = "t")
Warning message:In ordiplot(x, choices = choices, type = type, display = 
display, :Species scores not available” 
 
I have read from internet resources that in principle I could obtain the trait 
("species") scores to plot them in the ordination but my attempts have been 
unsuccessful. I have tried using the function “wascores” in package vegan and 
“add.spec.scores” in package BiodiversityR. For this purpuse I have created a 
new species x traits table where factor traits were coded into dummy variables 
and all integer variables (including binary) were coerced to numeric variables. 
Here are the codes used and the error messages I have got: 
 
“> NMDSgowdis<- metaMDS(SpeciesGowdis)
> NMDSpoints<-postMDS(NMDSgowdis$points,SpeciesGowdis)
> NMDSwasc<-wascores(NMDSpoints,TraitsNMDSdummies)
Error in if (any(w < 0) || sum(w) == 0) stop("weights must be non-negative and 
not all zero") : missing value where TRUE/FALSE needed” 
 
I imagine the problem is with the NA’s in the data. 
Alternatively, I have used the “add.spec.scores” function, method=”cor.scores”, 
found in package BiodiversityR. This seemed to work, as I got no error message, 
but the species scores were not returned. Here the R code and results:
“> 
A<-add.spec.scores(ordi=NMDSgowdis,comm=TraitsNMDSdummies,method="cor.scores",multi=1,
 Rscale=F,scaling="1")
> plot(A)
Warning message:In ordiplot(x, choices = choices, type = type, display = 
display, :Species scores not available“
 
Can anyone guide me to get the trait (“species”) scores to plot together with 
my species (“site”) scores?
Thanks in advance,
Edwin

  
__
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] I cannot get species scores to plot with site scores in MDS when I use a distance matrix as input. Problems with NA's?

2011-11-27 Thread Edwin Lebrija Trejos

Hi,
I have used the daisy() function from the package "cluster" as suggested. 
Indeed it can handle Na's but this is not different from the gowdis() function 
in Package "FD". My problem is not calculating the similarity matrix for its 
use with the metaMDS() function. My problem is that because I am using a 
similarity matrix as input for the metaMDS() function, then there are no 
"species scores" (in my case plant traits) available to plot together with the 
"site scores" (in my case species). Using the daisy() function does not solve 
the problem (see warning message):
 
> NMDSdaysi<-metaMDS(daisy(TraitsNMDS, metric="gower",type = list(ordratio = 
> 8:9,asymm = 7)))
> plot(NMDSdaysi)
Warning message:
In ordiplot(x, choices = choices, type = type, display = display,  :
  Species scores not available
 
In my original post I explain that I have tried obtaining species scores using 
the functions wascores() and add.spec.scores() of the packages vegan and 
BiodiversityR but wascores returns an error:
 
> TraitsNMDSdummies<-dummy.data.frame(TraitsNMDS, 
> c("leaf.type","dispersal.rank"))
> NMDSwasc<-wascores(NMDSpoints,TraitsNMDSdummies)
Error in if (any(w < 0) || sum(w) == 0) stop("weights must be non-negative and 
not all zero") : 
  missing value where TRUE/FALSE needed
 
And function add.spec.scores() does not solves the problem as the warning 
message shows:
> A<-add.spec.scores(ordi=NMDSdaysi,comm=TraitsNMDSdummies,method="cor.scores",multi=1,Rscale=F,scaling="1")
> plot(A)
Warning message:
In ordiplot(x, choices = choices, type = type, display = display,  :
  Species scores not available
 
I still don' know why I get an error in wascores() or how can I get species 
scores to use in a biplot. 



 
 
-- Message: 47Date: Thu, 24 Nov 2011 07:57:57 -0800 
(PST)
From: B77S To: r-help@r-project.orgSubject: Re: [R] I 
cannot get species scores to plot with site scoresin MDS when I use a distance 
matrix as input. Problems with NA's?Message-ID: 
<1322150277396-4104406.p...@n4.nabble.com>Content-Type: 
 
Try the daisy() function from the package "cluster", it seems to be able to 
handle NAs and non-dummy coded character variables metaMDS(daisy(df, 
metric="gower"))
 
Edwin Lebrija Trejos wrote> 
> Hi, First I should note I am relatively new to R so I would appreciate> 
> answers that take this into account.
> I am trying to perform an MDS ordination using the function ?metaMDS? of the 
> ?vegan? package. I want to ordinate species according to a set of> functional 
> traits. ?Species? here refers to ?sites? in traditional vegetation analyses 
> while ?traits? here correspond to ?species? in such> analyses. 
> My data looks like this:
> Trait1 Trait2 Trait3 Trait4 Trait5 Trait?
> Species1 228.44 16.56 1.66 13.22 1 short 
> Species2 150.55 28.07 0.41 0.60 1 mid
> Species3 NA 25.89 NA 0.55 0 large
> Species4 147.70 17.65 0.42 1.12 NA large
> Species? 132.68 NA 1.28 2.75 0 short
> Because the traits have different variable types, different measurement
> scales, and also missing values for some species, I have calculated the
> matrix of species distances using the Gower coefficient of similarity> 
> available in Package ?FD? (which allows missing values). 
> My problem comes when I create a bi-plot of species and traits. As I have
> used a distance matrix in function ?metaMDS? there are no species scores> 
> available. This is given as a warning in R: 
> NMDSgowdis<- metaMDS(SpeciesGowdis)>> plot(NMDSgowdis, type = "t")
> Warning message:In ordiplot(x, choices = choices, type = type, display => 
> display, :Species scores not available? 
> I have read from internet resources that in principle I could obtain the
> trait ("species") scores to plot them in the ordination but my attempts  have 
> been
> unsuccessful. I have tried using the function ?wascores? in  package vegan 
> and ?
> add.spec.scores? in package BiodiversityR. For this purpuse I have created a 
> new species x 
> traits table where factor traits> were coded into dummy variables and all 
> integer variables 
> (including> binary) were coerced to numeric variables. Here are the codes 
> used and the
> error messages I have got: 
> ?> NMDSgowdis<- metaMDS(SpeciesGowdis)
> NMDSpoints<-postMDS(NMDSgowdis$points,SpeciesGowdis)
> NMDSwasc<-wascores(NMDSpoints,TraitsNMDSdummies)
> Error in if (any(w < 0) || sum(w) == 0) stop("weights must be non-negative
> and not all zero") : missing value where TRUE/FALSE needed?
> I imagine the problem is with the NA?s in the data. 
> Alternatively, I have used the ?add.spec.scores? function,> 
&g

[R] Competing risks - calibration curve

2018-02-16 Thread Raja, Dr. Edwin Amalraj
Dear R users,

I am new to R and wanted to apply competing risk methods in my research 
work. I used the R code given by Zhang et al in his paper 'Nomogram for 
survival analysis in the presence of competing risks published in Ann Trans Med 
2017:5(20):403.

I am struggling with getting calibration curve thro' internal validation.   I 
am happy to receive suggestion in the coding as well as any reference

Can someone help with it?

Regards
Amalraj Raja
University of Aberdeen


The University of Aberdeen is a charity registered in Scotland, No SC013683.
Tha Oilthigh Obar Dheathain na charthannas cl?raichte ann an Alba, ?ir. 
SC013683.
__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] Competing risks - calibration curve

2018-02-16 Thread Raja, Dr. Edwin Amalraj
Hi,

Sorry not to provide R-code in my previous mail.  R code is below


#install.packages("rms")
require(rms)
#install.packages("mstate")
library(mstate)
require(splines)
library(ggplot2)
library(survival)
library(splines)
#install.packages("survsim")
require(survsim)
set.seed(10)
df<-crisk.sim(n=500, foltime=10, dist.ev=rep("lnorm",2), 
anc.ev=c(1.48,0.53),beta0.ev = c(3.80,2.54), dist.cens = "lnorm", anc.cens = 
3.5, beta0.cens = 5.42, z=NULL, beta = list(c(0.21, 0.017), c(0.37, 0.016)), 
x=list(c("normal",0,1), c("bern",0.564)), nsit=2)

table(status)
table(cause)

df$cause<-ifelse(is.na(df$cause),0,df$cause)
table(df$cause)

df.w<-crprep("time","cause", data=df, trans=c(1,2), cens=0, id="nid", 
keep=c("x", "x.1"))

with(df.w,table(failcode,status))
ddist<-datadist(df.w)
options(datadist='ddist')
mod<-cph(Surv(Tstart,Tstop,status==1)~rcs(x,3)+x.1,data=df.w, 
weight=weight.cens, subset=failcode==1, x=T, y=T, surv=T, time.inc = 2.5) 
mod2<-cph(Surv(Tstart,Tstop,status==1)~(x.1+rcs(x,3))^2,data=df.w, 
weight=weight.cens, subset=failcode==1, x=T, y=T, surv=T, time.inc = 2.5)
mod2

##  To develop nomogram
surv<-Survival(mod)
nom.sur<-nomogram(mod,fun=list(function(x) 1-surv(3,x), function(x) 
1-surv(5,x), function(x) 1-surv(7,x), function(x) 1-surv(9,x)), 
funlabel=c("3-year event 1 Prob.", "5-year event 1 Prob.", "7-year event 1 
Prob.", "9-year event 1 Prob."), lp=T) #plot(nom.sur, fun.side=list(rep(1,8), 
c(1,1,1,3,1,3,1,3,1,3,1,3,1,3,1),rep(1,10),rep(1,12))x)
plot(nom.sur)
#plot(nom.sur, fun.side=list(rep(1,8),c(1,1,1,3,1,3,1,3,1,3,1,3,1,3,1)))

#plot(nom.sur, fun.side=list(rep(1,10), c(1,1,1,1,3,1,3,1,3,1,3,1,3,1,3,1), 
rep(1,10), rep(1,10)))


#table(status)
###
#or f <- psm(S ~ ...)
pa <-  'polspline'%in% row.names(installed.packages())
if(pa) {
  cal <- calibrate(mod, u=2.5, m=20, B=20)  # cmethod=  '  hare  '
  plot(cal)
}


# validate

v<-validate(mod, method='boot', B=5)
v


# Calibration
set.seed(717)

cal<-calibrate(mod, method="boot", u=1, B=120, pr=FALSE, force=NULL, 
estimates=TRUE,
   bw=FALSE, aics=0, what="observed-predicted", tol=1e-12, 
maxdim=5) plot(cal, subtitles=FALSE)
plot(cal)
cal.km <- calibrate(mod, u=1, cmethod='KM', m=10, B=10, pr=FALSE)
plot(cal.km)
cal.hare = calibrate(mod, u=1, cmethod='hare', m=20, B=20)
plot(cal.hare)
#

Regards
Amalraj

From: Raja, Dr. Edwin Amalraj
Sent: 16 February 2018 10:37
To: 'r-help@r-project.org' 
Subject: Competing risks - calibration curve

Dear R users,

I am new to R and wanted to apply competing risk methods in my research 
work. I used the R code given by Zhang et al in his paper 'Nomogram for 
survival analysis in the presence of competing risks published in Ann Trans Med 
2017:5(20):403.

I am struggling with getting calibration curve thro' internal validation.   I 
am happy to receive suggestion in the coding as well as any reference

Can someone help with it?

Regards
Amalraj Raja
University of Aberdeen


The University of Aberdeen is a charity registered in Scotland, No SC013683.
Tha Oilthigh Obar Dheathain na charthannas cl?raichte ann an Alba, ?ir. 
SC013683.

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] selectFGR - variable selection in fine gray model for competing risks

2018-03-18 Thread Raja, Dr. Edwin Amalraj
Dear All,

   I would like to use R function 'selectFGR' of fine gray model in competing 
risks model.  I used the 'Melanoma' data in 'riskRegression' package.  Some of 
the variables are factor.  I get solution for full model but not in variable 
selection model.  Any advice how to use factor variable in 'selectFGR' 
function.  The following R code is produced below for reproducibility.

library(riskRegression)
library(pec)
dat <-data(Melanoma,package="riskRegression")
Melanoma$logthick <- log(Melanoma$thick)
f1 <- Hist(time,status)~age+sex+epicel+ulcer
df1 <-FGR(f1,cause=1, data=Melanoma)
df1
df <-selectFGR(f1, data=Melanoma, rule ="BIC",  direction="backward")

Thanks in advice for your suggestion. Is there any alternative solution ?

Regards
Amalraj raja


The University of Aberdeen is a charity registered in Scotland, No SC013683.
Tha Oilthigh Obar Dheathain na charthannas clàraichte ann an Alba, Àir. 
SC013683.
__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] selectFGR vs weighted coxph for internal validation and calibration curve- competing risks model

2018-03-21 Thread Raja, Dr. Edwin Amalraj
Dear Geskus,

I want to develop a prediction model.  I followed your paper and analysed thro' 
weighted coxph approach.   I can develop nomogram based on the final model 
also.  But I do not know how to do internal validation of the model and 
subsequently obtain calibration plot.   Is it possible to use Wolbers et al 
Epid 2009 approach 9 (R code for internal validation and calibration) .  It is 
possible to get these measures after using R function 'crr' or 'FGR'. That is 
why I wanted to go in that route. At the same time,  I had this doubt because 
their approach assume a record per individual whereas weight coxph creates two 
or more records per individual.  I am new to R and could not modify the R code 
easily.   Any suggestion?   Has anyone done internal validation and calibration 
after  using weighted  coxph approach?  Can you kindly refer me to the 
reference which has R code?

Thank you very much for all your inputs and suggestions

Regards
Amalraj raja

-Original Message-
From: Ronald Geskus [mailto:statist...@inter.nl.net]
Sent: 21 March 2018 04:01
To: r-help@r-project.org
Cc: Raja, Dr. Edwin Amalraj 
Subject: Re: [R] selectFGR - variable selection in fine gray model for 
competing risks

Dear Raja,

A Fine and Gray model can be fitted using the standard coxph function with 
weights that correct for right censoring and left truncation. Hence I guess any 
function that allows to perform stepwise regression with coxph should work. See 
e.g. my article in Biometrics https://doi.org/10./j.1541-0420.2010.01420.x, 
or the vignette "Multi-state models and competing risks" in the survival 
package.

best regards,

Ronald Geskus, PhD
head of biostatistics group
Oxford University Clinical Research unit Ho Chi Minh city, Vietnam associate 
professor University of Oxford http://www.oucru.org/dr-ronald-b-geskus/

"Raja, Dr. Edwin Amalraj"  writes:

> Dear All,
>
>I would like to use R function 'selectFGR' of fine gray model in
> competing risks model.  I used the 'Melanoma' data in 'riskRegression'
> package.  Some of the variables are factor.  I get solution for full
> model but not in variable selection model.  Any advice how to use
> factor variable in 'selectFGR' function.  The following R code is
> produced below for reproducibility.
>
> library(riskRegression)
> library(pec)
> dat <-data(Melanoma,package="riskRegression")
> Melanoma$logthick <- log(Melanoma$thick)
> f1 <- Hist(time,status)~age+sex+epicel+ulcer
> df1 <-FGR(f1,cause=1, data=Melanoma)
> df1
> df <-selectFGR(f1, data=Melanoma, rule ="BIC",  direction="backward")
>
> Thanks in advice for your suggestion. Is there any alternative solution ?
>
> Regards
> Amalraj raja
>
>
> The University of Aberdeen is a charity registered in Scotland, No
SC013683.
> Tha Oilthigh Obar Dheathain na charthannas clàraichte ann an Alba, Àir.
SC013683.



The University of Aberdeen is a charity registered in Scotland, No SC013683.
Tha Oilthigh Obar Dheathain na charthannas clàraichte ann an Alba, Àir. 
SC013683.

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] exporting data to stata

2018-03-22 Thread Raja, Dr. Edwin Amalraj
Hi ,

library(foreign)
write.dta(data1,  "data1.dta")

should work. The file will be saved in the working directory.
Use
getwd()
to know the working directory.

Best wishes
Amalraj Raja

-Original Message-
From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of rosario 
scandurra
Sent: 22 March 2018 07:47
To: r-help@r-project.org
Subject: [R] exporting data to stata

Hi,

I am new to R and I want to export data into Stata. Could somebody help with 
that? Thanks a lot.

This is the code I am using:


> setwd("D:/datasets/Seg-bcn/ESBD")
> data1 <- readRDS("r17045_ESDB_Habitatges_BDD_V_1_0.rds")
> library(foreign)
> write.dta(data="data1", file = "D:/datasets/data1.dta")
Error in write.dta(data = "data1", file = "D:/datasets/data1.dta") :
  The object "dataframe" must have class data.frame
> class (data1)
[1] "survey.design2" "survey.design"


[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 
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.


The University of Aberdeen is a charity registered in Scotland, No SC013683.
Tha Oilthigh Obar Dheathain na charthannas clàraichte ann an Alba, Àir. 
SC013683.
__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] restricted cubic spline in FGR function

2018-03-23 Thread Raja, Dr. Edwin Amalraj
Dear Thomas,

   I want to use evaluate effect of Age using restricted cubic form  in the  
FGR function  as
Fgr.crr <- FGR(Hist(time, event) ~ rcs(Age_years), data=dat)

It provides error.  " Error in parse(text = termtext, keep.source = FALSE):  
   1: response ~ rcs(Age_years

Do I need to change any of the R code?

Regards
Amalraj Raja



The University of Aberdeen is a charity registered in Scotland, No SC013683.
Tha Oilthigh Obar Dheathain na charthannas cl?raichte ann an Alba, ?ir. 
SC013683.

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] sprintf doesn't care of escape characters

2012-07-30 Thread Edwin Helbert Aponte Angarita
Hi.

I am having trouble with something that should be simple. I am unable
to get sprintf using escape sequences:

> sprintf("a\nb")
[1] "a\nb"

> sprintf("a\"bc\"d")
[1] "a\"bc\"d"

But it seems to need them any way:

> sprintf("a\"bc"d")
Error: unexpected symbol in "sprintf("a\"bc"d"

Any suggestion on how to solve this issue?

My R system:
> version
   _
platform   x86_64-suse-linux-gnu
arch   x86_64
os linux-gnu
system x86_64, linux-gnu
status
major  2
minor  15.0
year   2012
month  03
day30
svn rev58871
language   R
version.string R version 2.15.0 (2012-03-30)

Thanks.

__
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] sprintf doesn't care of escape characters

2012-07-30 Thread Edwin Helbert Aponte Angarita
Thank you very much. I didn't know about this difference, I thought it
just behaved as in C/C++.

Thanks.

On Mon, 2012-07-30 at 14:15 -0400, jim holtman wrote:
> sprintf is working just fine.  Your problem is the interpretation of
> what the results are.  Displaying the object will show the escape
> characters, but if you use "cat", or output to a file, you will see
> that the result is correct:
> 
> 
> > cat( sprintf("a\nb"))
> a
> b>
> > cat(sprintf("a\"bc\"d"))
> a"bc"d>
> >
> 
> 
> 
> On Mon, Jul 30, 2012 at 1:29 PM, Edwin Helbert Aponte Angarita
>  wrote:
> > Hi.
> >
> > I am having trouble with something that should be simple. I am unable
> > to get sprintf using escape sequences:
> >
> >> sprintf("a\nb")
> > [1] "a\nb"
> >
> >> sprintf("a\"bc\"d")
> > [1] "a\"bc\"d"
> >
> > But it seems to need them any way:
> >
> >> sprintf("a\"bc"d")
> > Error: unexpected symbol in "sprintf("a\"bc"d"
> >
> > Any suggestion on how to solve this issue?
> >
> > My R system:
> >> version
> >_
> > platform   x86_64-suse-linux-gnu
> > arch   x86_64
> > os linux-gnu
> > system x86_64, linux-gnu
> > status
> > major  2
> > minor  15.0
> > year   2012
> > month  03
> > day30
> > svn rev58871
> > language   R
> > version.string R version 2.15.0 (2012-03-30)
> >
> > Thanks.
> >
> > __
> > 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 message when using 'optim' for numerical maximum likelihood

2023-05-14 Thread iguodala edwin via R-help
Good morning, How can I resolved error message New_X with convergence 1.Thanks
[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.