[R] Question on Stopword Removal from a Cyrillic (Bulgarian)Text

2013-04-09 Thread Ventseslav Kozarev, MPP

Hi,

I bumped into a serious issue while trying to analyse some texts in 
Bulgarian language (with the tm package). I import a tab-separated csv 
file, which holds a total of 22 variables, most of which are text cells 
(not factors), using the read.delim function:


data<-read.delim("bigcompanies_ascii.csv",
header=TRUE,
quote="'",
sep="\t",
as.is=TRUE,
encoding='CP1251',
fileEncoding='CP1251')

(I also tried the above with UTF-8 encoding on a UTF-8-saved file.)

I have my list of stop words written in a separate text file, one word 
per line, which I read into R using the scan function:


stoplist<-scan(file='stoplist_ascii.txt',
   what='character',
   strip.white=TRUE,
   blank.lines.skip=TRUE,
   fileEncoding='CP1251',
   encoding='CP1251')

(also tried with UTF-8 here on a correspondingly encoded file)

I currently only test with a corpus based on the contents of just one 
variable, and I construct the corpus from a VectorSource. When I run 
inspect, all seems fine and I can see the text properly, with unicode 
characters present:


data.corpus<-Corpus(VectorSource(data$variable,encoding='UTF-8'),
   readerControl=list(language='bulgarian'))

However, no matter what I do - like which encoding I select - UTF-8 or 
CP1251, which is the typical code page for Bulgarian texts, I cannot get 
to remove the stop words from my corpus. The issue is present in both 
Linux and Windows, and across the computers I use R on, and I don't 
think it is related to bad configuration. Removal of punctuation, white 
space, and numbers is flawless, but the inability to remove stop words 
prevents me from further analysing the texts.


Has somebody had experience with languages other than English, and for 
which there is no predefined stop list available through the stopwords 
function? I will highly appreciate any tips and advice!


Thanks in advance,
Vince

__
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] Behaviors of diag() with character vector in R 3.0.0

2013-04-09 Thread Mike Cheung
Dear all,

According to CHANGES IN R 3.0.0:
 o diag() as used to generate a diagonal matrix has been re-written
  in C for speed and less memory usage.  It now forces the result
  to be numeric in the case diag(x) since it is said to have 'zero
  off-diagonal entries'.

diag(x) does not work for character vector in R 3.0.0 any more. For example,
v <- c("a", "b")

## R 2.15.3
diag(v)
 [,1] [,2]
[1,] "a"  "0"
[2,] "0"  "b"

## R 3.0.0
diag(v)
 [,1] [,2]
[1,]   NA0
[2,]0   NA
Warning message:
In diag(v) : NAs introduced by coercion

Regarding the character matrix, it still works. For example,
m <- matrix(c("a", "b", "c", "d"), nrow=2)
diag(m)
## Both R 2.15.3 and 3.0.0
[1] "a" "d"

n <- matrix(0, ncol=2, nrow=2)
diag(n) <- v
n
## Both R 2.15.3 and 3.0.0
 [,1] [,2]
[1,] "a"  "0"
[2,] "0"  "b"

I understand that the above behavior follows exactly what the manual says.
It appears to me that the version in 2.15.3 is more general as it works for
both numeric and character vectors and matrices, whereas the version in
3.0.0 works for character matrices but not character vectors.

Would it be possible to retain the behaviors of diag() for character
vectors? Thanks.

Mike
-- 
-
 Mike W.L. Cheung   Phone: (65) 6516-3702
 Department of Psychology   Fax:   (65) 6773-1843
 National University of Singapore
 http://courses.nus.edu.sg/course/psycwlm/internet/
-

[[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] Tablet and executing R

2013-04-09 Thread Rainer M. Krug
Trying To learn again  writes:

> Hi all,
>
> Have any of you instaled R on a Tablet, in this case, which Tablet. My
> family wants me to gift a Tablet but I suposse R can not be instaled on a
> Tablet. And my few "free" time I pass mainly trying to "improve" in R.
>
> Can yoy tell me, if there are, wich Tablets should be instaled?

I can't answer your question directly, but you can run RStudio Server on your
PC and access it from any web browser over the web.

Disclaimer: haven't used it yet.

Cheers,

Rainer

>
>   [[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.
<#secure method=pgpmime mode=sign>

-- 
Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation Biology, 
UCT), Dipl. Phys. (Germany)

Centre of Excellence for Invasion Biology
Stellenbosch University
South Africa

Tel :   +33 - (0)9 53 10 27 44
Cell:   +33 - (0)6 85 62 59 98
Fax :   +33 - (0)9 58 10 27 44

Fax (D):+49 - (0)3 21 21 25 22 44

email:  rai...@krugs.de

Skype:  RMkrug

__
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] fitting a hyperbola to data points

2013-04-09 Thread PIKAL Petr
Hi

It seems that some linearisation can be done by
with(dat,plot(exp(Requests), log(1/Time)))

it can be fitted by

fit<-lm(log(1/Time)~exp(Requests), data=dat)
or
library(MASS)
fit.r<-lqs(log(1/Time)~exp(Requests), data=dat)

coef(fit.r)
  (Intercept) exp(Requests) 
 -7.137549922  -0.002378384 
fff<- function(x)  1/(exp(-7.137549922  -0.002378384*exp(x)))
points(dat$Requests, fff(dat$Requests), col=2)

It is not perfect and especially points
 
> dat[c(91,94),]
   Requests Time
91 5.103478 3618
94 5.262253 2908

are quite far from predicted model.

Also it is probably better to use nonlinear regression 

?nls

Regards
Petr 



> -Original Message-
> From: r-help-boun...@r-project.org [mailto:r-help-bounces@r-
> project.org] On Behalf Of Manoj Srivastava
> Sent: Monday, April 08, 2013 6:05 PM
> To: r-help@r-project.org
> Subject: Re: [R] fitting a hyperbola to data points
> 
> On Mon, Apr 08 2013, PIKAL Petr wrote:
> 
> Thanks for responding.
> 
> > without data we can provide just basic help.
> > fit<-lm(Time~I(1/Requests))
> > shall give you hyperbolic fit.
> 
> > You can test if your data follow this assumption by plot(1/Requests,
> > Time) which shall for straight line.
> >
> > anyway, when you want to provide data use
> > dput(your.data) and copy console output directly to your mail.
> 
> Pardon. I had put my data on pastebin, but here is the dput:
> > dput(dat)
> structure(list(Requests = c(0.045364248295124, 0.11341062073781,
> 0.16633557708212, 0.20413911732806, 0.26462478172156, 0.31754973806587,
> 0.37047469441018, 0.42339965075449, 0.47632460709881, 0.52168885539393,
> 0.58217451978743, 0.62753876808255, 0.68802443247605, 0.73338868077118,
> 0.79387434516468, 0.8392385934598, 0.8997242578533, 0.94508850614843,
> 0.99801346249274, 1.050938418837, 1.1038633751814, 1.1567883315257,
> 1.20971328787, 1.2626382442143, 1.3155632005586, 1.3684881569029,
> 1.4214131132472, 1.4743380695915, 1.5272630259359, 1.5801879822802,
> 1.6255522305753, 1.6860378949688, 1.7389628513131, 1.7843270996082,
> 1.8448127640017, 1.897737720346, 1.9431019686412, 1.9960269249855,
> 2.056512589379, 2.1018768376741, 2.1548017940184, 2.2152874584119,
> 2.260651706707, 2.3135766630513, 2.3665016193957, 2.41942657574,
> 2.4723515320843, 2.5252764884286, 2.5782014447729, 2.6311264011172,
> 2.6764906494123, 2.7369763138058, 2.7899012701502, 2.8428262264945,
> 2.8881904747896, 2.9486761391831, 2.9940403874782, 3.1603759645603,
> 3.2057402128555, 3.266225877249, 3.3115901255441, 3.3645150818884,
> 3.4174400382327, 3.4779257026262, 3.5232899509213, 3.5762149072656,
> 3.62913986361, 3.6820648199543, 3.7349897762986, 3.7879147326429,
> 3.8408396889872, 3.8937646453315, 3.9391288936266, 3.9996145580201,
> 4.0525395143644, 4.0979037626596, 4.1583894270531, 4.2113143833974,
> 4.2566786316925, 4.317164296086, 4.3625285443811, 4.4230142087746,
> 4.4683784570698, 4.5213034134141, 4.5817890778076, 4.7330032387913,
> 4.7934889031848, 4.8388531514799, 4.9976280205129, 5.0505529768572,
> 5.1034779332015, 5.1564028895458, 5.2017671378409, 5.2622528022344 ),
> Time = c(1289L, 1262L, 1272L, 1222L, 1243L, 1259L, 1266L, 1242L, 1249L,
> 1232L, 1303L, 1236L, 1251L, 1263L, 1234L, 1226L, 1232L, 1246L, 1249L,
> 1272L, 1263L, 1247L, 1253L, 1257L, 1267L, 1262L, 1284L, 1266L, 1269L,
> 1268L, 1273L, 1261L, 1261L, 1264L, 1276L, 1283L, 1275L, 1277L, 1293L,
> 1285L, 1284L, 1289L, 1290L, 1289L, 1300L, 1292L, 1300L, 1291L, 1297L,
> 1310L, 1303L, 1311L, 1317L, 1345L, 1315L, 1327L, 1322L, 1597L, 1623L,
> 1510L, 1372L, 1429L, 1371L, 1365L, 1357L, 1366L, 1402L, 1370L, 1407L,
> 1373L, 1399L, 1420L, 1405L, 1393L, 1428L, 1394L, 1422L, 1425L, 1457L,
> 1501L, 1426L, 1539L, 1492L, 1476L, 1493L, 1580L, 1670L, 1556L, 1661L,
> 1593L, 3618L, 1903L, 1941L, 2908L)), .Names = c("Requests", "Time"),
> class = "data.frame", row.names = c(NA, -94L))
> 
> 
> When plotting with  plot(1/Requests, Time), I still get a
> parabolic line, not a linear one. Perhaps there is a data transform I
> can do to get this into a linear mode?
> 
> I have also plotted the data (Time vs Requests and 1/Requests)
> on a log and log-log scale, but the curve remains stubbornly  curved.
> This seems to argue against an exponential relationship, does  it not?
> 
> 
> thanks again.
> 
> manoj
> 
> 
> >> I am new to R, and I suspect I am missing something simple.
> 
> >> I have a data set that  performance data that correlates
> >> request  rate to response times
> >> http://pastebin.com/Xhg0RaUp
> >>  There is some jitter in the data, but mostly it looks like a hockey
> >> puck curve. It does not get converted into a straight line when I
> >> tried log conversions, so it does not seem to be a power series
> relationship.
> 
> >> My expectation is that the data will fit a curve that is a
> >> hyperbola, but I don't know how to formulate that regression. How
> >> does one fit data to a general function
> >>AX^2 + Bxy + Cy^

Re: [R] problems with text in plots when using illustrator

2013-04-09 Thread Paul Murrell

Hi

What you are seeing may be the effect of kerning.
Try pdf(..., useKerning=FALSE)

Also, make sure that you actually need to use Illustrator.  It is 
possible that you might be able to do your customisations or refinements 
in R, which will greatly improve the chances of being able to 
replicate/automate your task.


Paul

On 9/04/2013 4:39 p.m., David Winsemius wrote:


On Apr 8, 2013, at 12:28 PM, yanboulanger wrote:


Hi folks,

I have some problems with plots (any) saved from R (saved from the
menu). It
seems that text (either plot titles or axes) is sometimes not
"concatenated"
in a full "vector" (Illustrator-speaking). I mean, sometimes, a given
title
is broken in several different chunks even though in R, it's in one
"block".
Moreover, axis values (especially those < 10) are most of the times
"pasted"
in a single Illustrator vector whereas a given axis values should be a
single vector in Illustrator. This cause problem when trying to edit the
plots within Illustrator. All plots are saved in *.eps. I'm using
Illustrator CS5.


I sorry. I find this basically incoherent.

Are you expecting us to have a copy of Illustrator and are willing to
describe how you create a pdf or ps file? If so you should post a
dataset (in R code using dput) and code. Many of us do not have such a
resource but I cannot imagine understanding your complaint unless you do
post further detail.



--
Dr Paul Murrell
Department of Statistics
The University of Auckland
Private Bag 92019
Auckland
New Zealand
64 9 3737599 x85392
p...@stat.auckland.ac.nz
http://www.stat.auckland.ac.nz/~paul/

__
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] Importing from file to graphic window

2013-04-09 Thread S Ellison
 
> Can I "import" the content of a pdf (or jpg) and put it in 
> the graphic window?. 

jpeg: not in base R, but you could look at the CRAN jpeg package which says it 
reads and writes jpegs.

PDF: Not in base R. But you can create a PDF with a known filename and then 
open it in the default PDF viewer using shell() if the OS supports file 
associations. In Windows XP (I'm at work) with Adobe X installed, and with R 
2.15.3, the following works

pdf(file="temp.pdf")
hist(rnorm(500), breaks=15, col=rainbow(25))
dev.off()
shell("temp.pdf")

If shell doesn't work, consider, for example, openPDF from the Biobase package

And you could use any search engine to search for "display jpeg in R" or 
"display PDF from R" or "import image into R" and so on.


S Ellison

***
This email and any attachments are confidential. Any use...{{dropped:8}}

__
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] sem: S is numerically singular: expect problems

2013-04-09 Thread Amarnath Bose
Dear Users,

I am a new user of the sem package.
I have a model that is being flagged by sem as "S is numerically singular:
expect problems"

I have checked John Fox's response to a similar problem. Obviously the
variance-covariance matrix is singular, but none of the possible reasons
seems to hold in my case.

Any leads how I could get the model to work?

from Prof. John Fox

That seems to me a reasonably informative error message: The
observed-variable covariance matrix is singular. This could happen, e.g., if
two observed variables are perfectly correlated, if an observed variable had
0 variance, or if there were more observed variables than observations.

Thanks


-- 


 *Amarnath Bose*
* **Associate Professor   *
*Decision Sciences Department*
*Birla Institute of Management Technology
*
Tel:  +91 120 2323001 - 10 Ext.: 398
Cell: +91 9873179813

[[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] USSL diagram

2013-04-09 Thread Amit Ghosh
is there any package available which can be be used to draw us salinity
diagram?

[[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] quotes in cat() within function

2013-04-09 Thread Daniel Caro
Hello all,

Sorry if this question has been answered in the past, but I could not find
an answer.

I am trying to print quotes within a cat output. The arguments are:

file= "Data labels"
directory= "/home/mylaptop/"

The function returns:
cat("The file", file, "is located in directory", directory, sep=" ")

The output R prints is

The file Data labels is located in directory /home/mylaptop/

But I want "Data labels" and "/home/mylaptop/" to be in quotation marks.

I find examples using "\", such as

cat("Open fnd \"test\"")

But in my case "test" is an argument.


Thank you

Daniel

[[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] Remove data 3 standard deviatons from the mean using R?

2013-04-09 Thread Lorna
Hi Everyone,
 
I have a very long list of data-points (+2300) and i know from my histogram
that there are outliers which are affecting my mean.
 
I was wondering if anyone on here knows a way i can quickly get R to
calculate and remove data which is 3 standard deviations from the mean? I am
hoping this will tidy my data and give me a repeatable method of tidying for
future data collection.
 
Please if you do post code, make it as user friendly as possible! I am not a
very good programmer, i can load my data into R and do basic stats on it
however i havent tried much else
 
Thank you in advance for any advice given :)



--
View this message in context: 
http://r.789695.n4.nabble.com/Remove-data-3-standard-deviatons-from-the-mean-using-R-tp4663745.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] cbind for list of zoo objects

2013-04-09 Thread Harry Mamaysky
Thanks for the explanations. 

Wouldn't the following bit of checking in do.call() make it easier to figure 
such things out in the future?


my.call <- function(what,args,...) {
 
  ##  Get the name of the function to call.
  if (!is.character(what))
  whatStr <- deparse(substitute(what))
  else
  whatStr <- what
 
  callFctn <- paste0(gsub(paste0('.',class(args[[1]])),'',whatStr), '.', 
class(args[[1]]))
 
  ##  Check whether list names are arguments to the function.
  if ( any( names(args) %in% names(formals(callFctn)) ) )
  warning( 'Element of "args" is also an argument for ', callFctn, '.' )
 
  ##  Do the actual call.
  do.call( what, args, ... )
}

Sent from my iPhone

On Apr 8, 2013, at 7:23 PM, Gabor Grothendieck  wrote:

On Mon, Apr 8, 2013 at 3:54 PM, Harry Mamaysky  wrote:
> Can someone explain why this happens when one of the list elements is named 
> 'all'?
> 
>> zz <- list( zoo(1:10,1:10), zoo(101:110,1:10), zoo(201:210,1:10) )
>> names(zz)<-c('test','bar','foo')
>> do.call(cbind,zz)
>   test bar foo
> 1 1 101 201
> 2 2 102 202
> 3 3 103 203
> 4 4 104 204
> 5 5 105 205
> 6 6 106 206
> 7 7 107 207
> 8 8 108 208
> 9 9 109 209
> 10   10 110 210
>> names(zz)<-c('test','all','foo')
>> do.call(cbind,zz)
>   test foo
> 1 1 201
> 2 2 202
> 3 3 203
> 4 4 204
> 5 5 205
> 6 6 206
> 7 7 207
> 8 8 208
> 9 9 209
> 10   10 210

all= is an argument to cbind.zoo so it cannot be used as a column name.

> args(zoo:::cbind.zoo)
function (..., all = TRUE, fill = NA, suffixes = NULL, drop = FALSE)
NULL

--
Statistics & Software Consulting
GKX Group, GKX Associates Inc.
tel: 1-877-GKX-GROUP
email: ggrothendieck at gmail.com

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


Re: [R] predict.lm (Michael Haenlein)

2013-04-09 Thread marKo
Michael Haenlein wrote
Dear all,

I would like to use predict.lm to obtain a set of predicted values
based on
a regression model I estimated.

When I apply predict.lm to two vectors that have the same values, the
predicted values will be identical. I know that my regression model
is not
perfect and I would like to take account of the error inherent in
the model
within my predictions. So, while I understand that the expected
value of
both vectors should be the same (since they have the same value), I
would
like to have different predictions to take account of the error
inherent in
my model.

I assume I can probably use se.fit to achieve my objective of including
"random error" in my predictions but I don't really know how. Could
anybody
give me a pointer on how this can be done?

Thanks,

Michael

 [[alternative HTML version deleted]]

__
[hidden email]

 
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.
« [hide part of quote
]


I guess that, given the fact that you know how good/bad your models are, 
you can specify an additional error therm  (a random variable with given 
mean and standard deviation). That variable will "cause" the predicted 
values to be different every time you predict the outcome. The model you 
have fitted are a linear model after all (You just need to add the error).

Hope it helps,

Marko



-- 
Marko Tonc(ic'
Assistant Researcher
University of Rijeka
Faculty of Humanities and Social Sciences
Department of Psychology
Sveu?ilis(na Avenija 4, 51000 Rijeka, Croatia

[[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] quotes in cat() within function

2013-04-09 Thread Adrian Duşa
Try:
directory= "\"/home/mylaptop/\""

Hope this helps,
Adrian


On Tue, Apr 9, 2013 at 1:06 PM, Daniel Caro  wrote:

> Hello all,
>
> Sorry if this question has been answered in the past, but I could not find
> an answer.
>
> I am trying to print quotes within a cat output. The arguments are:
>
> file= "Data labels"
> directory= "/home/mylaptop/"
>
> The function returns:
> cat("The file", file, "is located in directory", directory, sep=" ")
>
> The output R prints is
>
> The file Data labels is located in directory /home/mylaptop/
>
> But I want "Data labels" and "/home/mylaptop/" to be in quotation marks.
>
> I find examples using "\", such as
>
> cat("Open fnd \"test\"")
>
> But in my case "test" is an argument.
>
>
> Thank you
>
> Daniel
>
> [[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.
>



-- 
Adrian Dusa
Romanian Social Data Archive
1, Schitu Magureanu Bd.
050025 Bucharest sector 5
Romania
Tel.:+40 21 3126618 \
   +40 21 3120210 / int.101
Fax: +40 21 3158391

[[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] quotes in cat() within function

2013-04-09 Thread arun
file<- "\"Data labels\""
 directory="\"/home/mylaptop/\""
 cat("The file", file,"is located in directory",directory,sep=" ")
The file "Data labels" is located in directory "/home/mylaptop/"
A.K.



- Original Message -
From: Daniel Caro 
To: r-help@r-project.org
Cc: 
Sent: Tuesday, April 9, 2013 6:06 AM
Subject: [R] quotes in cat() within function

Hello all,

Sorry if this question has been answered in the past, but I could not find
an answer.

I am trying to print quotes within a cat output. The arguments are:

file= "Data labels"
directory= "/home/mylaptop/"

The function returns:
cat("The file", file, "is located in directory", directory, sep=" ")

The output R prints is

The file Data labels is located in directory /home/mylaptop/

But I want "Data labels" and "/home/mylaptop/" to be in quotation marks.

I find examples using "\", such as

cat("Open fnd \"test\"")

But in my case "test" is an argument.


Thank you

Daniel

    [[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] cbind for list of zoo objects

2013-04-09 Thread Joshua Ulrich
On Tue, Apr 9, 2013 at 7:31 AM, Harry Mamaysky  wrote:
> Thanks for the explanations.
>
> Wouldn't the following bit of checking in do.call() make it easier to figure 
> such things out in the future?
>
Sure, it would have helped you figure out your issue, but you don't
want a *warning* when you purposefully try to set named function
arguments.  I.e., what if you want to set a function argument to
something other than its default value?  Do you really want a warning
when you do that?

>
> my.call <- function(what,args,...) {
>
>   ##  Get the name of the function to call.
>   if (!is.character(what))
>   whatStr <- deparse(substitute(what))
>   else
>   whatStr <- what
>
>   callFctn <- paste0(gsub(paste0('.',class(args[[1]])),'',whatStr), '.', 
> class(args[[1]]))
>
>   ##  Check whether list names are arguments to the function.
>   if ( any( names(args) %in% names(formals(callFctn)) ) )
>   warning( 'Element of "args" is also an argument for ', callFctn, '.' )
>
>   ##  Do the actual call.
>   do.call( what, args, ... )
> }
>
> Sent from my iPhone
>
> On Apr 8, 2013, at 7:23 PM, Gabor Grothendieck  
> wrote:
>
> On Mon, Apr 8, 2013 at 3:54 PM, Harry Mamaysky  wrote:
>> Can someone explain why this happens when one of the list elements is named 
>> 'all'?
>>
>>> zz <- list( zoo(1:10,1:10), zoo(101:110,1:10), zoo(201:210,1:10) )
>>> names(zz)<-c('test','bar','foo')
>>> do.call(cbind,zz)
>>   test bar foo
>> 1 1 101 201
>> 2 2 102 202
>> 3 3 103 203
>> 4 4 104 204
>> 5 5 105 205
>> 6 6 106 206
>> 7 7 107 207
>> 8 8 108 208
>> 9 9 109 209
>> 10   10 110 210
>>> names(zz)<-c('test','all','foo')
>>> do.call(cbind,zz)
>>   test foo
>> 1 1 201
>> 2 2 202
>> 3 3 203
>> 4 4 204
>> 5 5 205
>> 6 6 206
>> 7 7 207
>> 8 8 208
>> 9 9 209
>> 10   10 210
>
> all= is an argument to cbind.zoo so it cannot be used as a column name.
>
>> args(zoo:::cbind.zoo)
> function (..., all = TRUE, fill = NA, suffixes = NULL, drop = FALSE)
> NULL
>
> --
> Statistics & Software Consulting
> GKX Group, GKX Associates Inc.
> tel: 1-877-GKX-GROUP
> email: ggrothendieck at gmail.com
>

--
Joshua Ulrich  |  about.me/joshuaulrich
FOSS Trading  |  www.fosstrading.com

R/Finance 2013: Applied Finance with R  | www.RinFinance.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] USSL diagram

2013-04-09 Thread Ben Tupper
Hi,

On Apr 9, 2013, at 6:12 AM, Amit Ghosh wrote:

> is there any package available which can be be used to draw us salinity
> diagram?

If you have CTD data and are looking to plot temperature-salinity diagrams, 
then I highly recommend Dan Kelley's "oce" package.

Cheers,
Ben

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

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


Re: [R] cbind for list of zoo objects

2013-04-09 Thread Harry Mamaysky
That's true. So perhaps there should be a flag that turns on this error 
checking. Often "args" is just a list that gets generated automatically and you 
don't know what all of its elements are. It just leads to a bit of 
non-deterministic behavior. It would be useful to have the option of flagging 
when one of those list elements (inadvertently) has the same name as an 
argument of "what". 

Sent from my iPhone

On Apr 9, 2013, at 9:07 AM, Joshua Ulrich  wrote:

On Tue, Apr 9, 2013 at 7:31 AM, Harry Mamaysky  wrote:
> Thanks for the explanations.
> 
> Wouldn't the following bit of checking in do.call() make it easier to figure 
> such things out in the future?
Sure, it would have helped you figure out your issue, but you don't
want a *warning* when you purposefully try to set named function
arguments.  I.e., what if you want to set a function argument to
something other than its default value?  Do you really want a warning
when you do that?

> 
> my.call <- function(what,args,...) {
> 
>  ##  Get the name of the function to call.
>  if (!is.character(what))
>  whatStr <- deparse(substitute(what))
>  else
>  whatStr <- what
> 
>  callFctn <- paste0(gsub(paste0('.',class(args[[1]])),'',whatStr), '.', 
> class(args[[1]]))
> 
>  ##  Check whether list names are arguments to the function.
>  if ( any( names(args) %in% names(formals(callFctn)) ) )
>  warning( 'Element of "args" is also an argument for ', callFctn, '.' )
> 
>  ##  Do the actual call.
>  do.call( what, args, ... )
> }
> 
> Sent from my iPhone
> 
> On Apr 8, 2013, at 7:23 PM, Gabor Grothendieck  
> wrote:
> 
> On Mon, Apr 8, 2013 at 3:54 PM, Harry Mamaysky  wrote:
>> Can someone explain why this happens when one of the list elements is named 
>> 'all'?
>> 
>>> zz <- list( zoo(1:10,1:10), zoo(101:110,1:10), zoo(201:210,1:10) )
>>> names(zz)<-c('test','bar','foo')
>>> do.call(cbind,zz)
>>  test bar foo
>> 1 1 101 201
>> 2 2 102 202
>> 3 3 103 203
>> 4 4 104 204
>> 5 5 105 205
>> 6 6 106 206
>> 7 7 107 207
>> 8 8 108 208
>> 9 9 109 209
>> 10   10 110 210
>>> names(zz)<-c('test','all','foo')
>>> do.call(cbind,zz)
>>  test foo
>> 1 1 201
>> 2 2 202
>> 3 3 203
>> 4 4 204
>> 5 5 205
>> 6 6 206
>> 7 7 207
>> 8 8 208
>> 9 9 209
>> 10   10 210
> 
> all= is an argument to cbind.zoo so it cannot be used as a column name.
> 
>> args(zoo:::cbind.zoo)
> function (..., all = TRUE, fill = NA, suffixes = NULL, drop = FALSE)
> NULL
> 
> --
> Statistics & Software Consulting
> GKX Group, GKX Associates Inc.
> tel: 1-877-GKX-GROUP
> email: ggrothendieck at gmail.com

--
Joshua Ulrich  |  about.me/joshuaulrich
FOSS Trading  |  www.fosstrading.com

R/Finance 2013: Applied Finance with R  | www.RinFinance.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] Remove data 3 standard deviatons from the mean using R?

2013-04-09 Thread Berend Hasselman

On 09-04-2013, at 13:12, Lorna  wrote:

> Hi Everyone,
> 
> I have a very long list of data-points (+2300) and i know from my histogram
> that there are outliers which are affecting my mean.
> 
> I was wondering if anyone on here knows a way i can quickly get R to
> calculate and remove data which is 3 standard deviations from the mean? I am
> hoping this will tidy my data and give me a repeatable method of tidying for
> future data collection.
> 
> Please if you do post code, make it as user friendly as possible! I am not a
> very good programmer, i can load my data into R and do basic stats on it
> however i havent tried much else


# some test data + standard deviation of same
testdata <- rnorm(100,0,5)
sd.td <- sd(testdata)

# threshold (set to 3.0 for your specific situation)
alpha <- 1.5

# determine which items fall within bounds and select them

pidx <- (testdatamean(testdata)-alpha*sd.td)
testdata[pidx]

Berend

__
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] sem: S is numerically singular: expect problems

2013-04-09 Thread John Fox
Dear Amarnath Bose,

S is the observed-variables covariance or moment matrix and thus doesn't
really have to do with the model that you're fitting, nor with the sem
software per se; rather, S is computed directly from the data. 

It's not possible without the data to know why S is numerically singular.
The message you quote suggests three reasons, but these aren't exhaustive.
Investigating the eigenstructure or SVD of S or the data matrix might help
-- e.g., through a principal components analysis.

I hope this helps,
 John

---
John Fox
Senator McMaster Professor of Social Statistics
Department of Sociology
McMaster University
Hamilton, Ontario, Canada


> -Original Message-
> From: r-help-boun...@r-project.org [mailto:r-help-bounces@r-
> project.org] On Behalf Of Amarnath Bose
> Sent: Tuesday, April 09, 2013 8:22 AM
> To: r-help@r-project.org
> Subject: [R] sem: S is numerically singular: expect problems
> 
> Dear Users,
> 
> I am a new user of the sem package.
> I have a model that is being flagged by sem as "S is numerically
> singular:
> expect problems"
> 
> I have checked John Fox's response to a similar problem. Obviously the
> variance-covariance matrix is singular, but none of the possible
> reasons
> seems to hold in my case.
> 
> Any leads how I could get the model to work?
> 
> from Prof. John Fox
> 
> That seems to me a reasonably informative error message: The
> observed-variable covariance matrix is singular. This could happen,
> e.g., if
> two observed variables are perfectly correlated, if an observed
> variable had
> 0 variance, or if there were more observed variables than observations.
> 
> Thanks
> 
> 
> --
> 
> 
>  *Amarnath Bose*
> * **Associate Professor   *
> *Decision Sciences Department*
> *Birla Institute of Management Technology
> *
> Tel:  +91 120 2323001 - 10 Ext.: 398
> Cell: +91 9873179813
> 
>   [[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] Remove data 3 standard deviatons from the mean using R?

2013-04-09 Thread David Winsemius


On Apr 9, 2013, at 4:12 AM, Lorna wrote:


Hi Everyone,

I have a very long list of data-points (+2300) and i know from my  
histogram

that there are outliers which are affecting my mean.

I was wondering if anyone on here knows a way i can quickly get R to
calculate and remove data which is 3 standard deviations from the  
mean? I am
hoping this will tidy my data and give me a repeatable method of  
tidying for

future data collection.

Please if you do post code, make it as user friendly as possible! I  
am not a
very good programmer, i can load my data into R and do basic stats  
on it

however i havent tried much else

Thank you in advance for any advice given :)



This plan has no statistical justification. Around here we have  
reverence for data. Outliers are often meaningful. Requests to distort  
your data should be accompanied by a coherent argument.


--

David Winsemius, MD
Alameda, CA, USA

__
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] quotes in cat() within function

2013-04-09 Thread Hadley Wickham
On Tue, Apr 9, 2013 at 3:06 AM, Daniel Caro  wrote:
> Hello all,
>
> Sorry if this question has been answered in the past, but I could not find
> an answer.
>
> I am trying to print quotes within a cat output. The arguments are:
>
> file= "Data labels"
> directory= "/home/mylaptop/"
>
> The function returns:
> cat("The file", file, "is located in directory", directory, sep=" ")

cat("The file\"", file, "\"is located in directory\"", directory, "\", sep=" ")

or use single quotes

cat('The file"', file, '"is located in directory"', directory, '"', sep=" ")

Hadley

--
Chief Scientist, RStudio
http://had.co.nz/

__
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] cbind for list of zoo objects

2013-04-09 Thread Gabor Grothendieck
On Tue, Apr 9, 2013 at 9:15 AM, Harry Mamaysky  wrote:
> That's true. So perhaps there should be a flag that turns on this error 
> checking. Often "args" is just a list that gets generated automatically and 
> you don't know what all of its elements are. It just leads to a bit of 
> non-deterministic behavior. It would be useful to have the option of flagging 
> when one of those list elements (inadvertently) has the same name as an 
> argument of "what".
>

You can force an error by specifying all the default arguments.  Using
the version of zz with an all component it will encounter all= twice:

> do.call(cbind, c(zz, all = TRUE, fill = NA, suffixes = list(NULL), drop = 
> FALSE))
Error in cbind(deparse.level, ...) :
  formal argument "all" matched by multiple actual arguments

or more compactly:

> do.call(cbind, c(zz, formals(zoo:::cbind.zoo)[-1]))
Error in cbind(deparse.level, ...) :
  formal argument "all" matched by multiple actual arguments


--
Statistics & Software Consulting
GKX Group, GKX Associates Inc.
tel: 1-877-GKX-GROUP
email: ggrothendieck at gmail.com

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


Re: [R] cbind for list of zoo objects

2013-04-09 Thread Harry Mamaysky
That's a nice solution. Thanks. 

Sent from my iPhone

On Apr 9, 2013, at 10:00 AM, Gabor Grothendieck  wrote:

On Tue, Apr 9, 2013 at 9:15 AM, Harry Mamaysky  wrote:
> That's true. So perhaps there should be a flag that turns on this error 
> checking. Often "args" is just a list that gets generated automatically and 
> you don't know what all of its elements are. It just leads to a bit of 
> non-deterministic behavior. It would be useful to have the option of flagging 
> when one of those list elements (inadvertently) has the same name as an 
> argument of "what".
> 

You can force an error by specifying all the default arguments.  Using
the version of zz with an all component it will encounter all= twice:

> do.call(cbind, c(zz, all = TRUE, fill = NA, suffixes = list(NULL), drop = 
> FALSE))
Error in cbind(deparse.level, ...) :
 formal argument "all" matched by multiple actual arguments

or more compactly:

> do.call(cbind, c(zz, formals(zoo:::cbind.zoo)[-1]))
Error in cbind(deparse.level, ...) :
 formal argument "all" matched by multiple actual arguments


--
Statistics & Software Consulting
GKX Group, GKX Associates Inc.
tel: 1-877-GKX-GROUP
email: ggrothendieck at gmail.com

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


Re: [R] Behaviors of diag() with character vector in R 3.0.0

2013-04-09 Thread arun
Hi,
You could try this:
v <- c("a", "b")
mat1<-diag(length(v))
 diag(mat1)<- v
 mat1
# [,1] [,2]
#[1,] "a"  "0" 
#[2,] "0"  "b" 


 v1<- letters[1:5]
mat2<- diag(length(v1))
 diag(mat2)<- v1
mat2
# [,1] [,2] [,3] [,4] [,5]
#[1,] "a"  "0"  "0"  "0"  "0" 
#[2,] "0"  "b"  "0"  "0"  "0" 
#[3,] "0"  "0"  "c"  "0"  "0" 
#[4,] "0"  "0"  "0"  "d"  "0" 
#[5,] "0"  "0"  "0"  "0"  "e" 
A.K.




- Original Message -
From: Mike Cheung 
To: r-help 
Cc: 
Sent: Tuesday, April 9, 2013 3:15 AM
Subject: [R] Behaviors of diag() with character vector in R 3.0.0

Dear all,

According to CHANGES IN R 3.0.0:
o diag() as used to generate a diagonal matrix has been re-written
      in C for speed and less memory usage.  It now forces the result
      to be numeric in the case diag(x) since it is said to have 'zero
      off-diagonal entries'.

diag(x) does not work for character vector in R 3.0.0 any more. For example,
v <- c("a", "b")

## R 2.15.3
diag(v)
     [,1] [,2]
[1,] "a"  "0"
[2,] "0"  "b"

## R 3.0.0
diag(v)
     [,1] [,2]
[1,]   NA    0
[2,]    0   NA
Warning message:
In diag(v) : NAs introduced by coercion

Regarding the character matrix, it still works. For example,
m <- matrix(c("a", "b", "c", "d"), nrow=2)
diag(m)
## Both R 2.15.3 and 3.0.0
[1] "a" "d"

n <- matrix(0, ncol=2, nrow=2)
diag(n) <- v
n
## Both R 2.15.3 and 3.0.0
     [,1] [,2]
[1,] "a"  "0"
[2,] "0"  "b"

I understand that the above behavior follows exactly what the manual says.
It appears to me that the version in 2.15.3 is more general as it works for
both numeric and character vectors and matrices, whereas the version in
3.0.0 works for character matrices but not character vectors.

Would it be possible to retain the behaviors of diag() for character
vectors? Thanks.

Mike
-- 
-
Mike W.L. Cheung               Phone: (65) 6516-3702
Department of Psychology       Fax:   (65) 6773-1843
National University of Singapore
http://courses.nus.edu.sg/course/psycwlm/internet/
-

    [[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] Mistake in German Error message for friedman.test

2013-04-09 Thread Kaisers


There are two misspellings in the german Error message for friedman test:

Fehler in friedman.test.default(cont$score, group = cont$goup, blocks = 
cont$cont) :
  y, Gruppen und blöcke müssen die sekbe Länge haben

The correct spelling would be:

Fehler in friedman.test.default(cont$score, group = cont$goup, blocks = 
cont$cont) :
  y, Gruppen und *Blöcke* müssen die *selbe* Länge haben


Instead of "die selbe", it could be "dieselbe" or "die gleiche".

Thanks
W. Kaisers



[[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] Boxplot Labels

2013-04-09 Thread Beatriz González Domínguez
#Dear all,

#Could anyone help me with the following?
#DATA
num <- as.numeric(seq(100:125))
ave <- c(0.5, 1, 1.6, 2, 2, 2.3, 2.5, 2.4, 3, 3.2, 3.3, 4, 4.8, 3.5, 2.7, 3.1, 
2.8, 3.5, 4.1, 2.0, 2.5, 2.1, 3.4, 2.5, 2.6, 7)
DATA <- data.frame(cbind(num, ave))
rm(num, ave)

#BOXPLOT
x11()
bp <- boxplot(DATA$ave, data= DATA, main= "Average Size")
identify(x= bp$group, y= bp$out, labels= DATA$num, cex = 0.7) 
#I would like the labels that appear in the boxplot to be DATA$num values. 
#When I identify the outlier it appears a "1" when I would like to appear a "26"

#Do you have any idea of how I could do that?

#Many thanks!
 
#Bea
[[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] sorting the VAR model output according to variable names??

2013-04-09 Thread londonphd
I was wondering if one can have the coefficients of VAR model sorted
according to variable names rather than lags. If you notice below, the
output is sorted according to lags.

>VAR(cbind(fossil,labour),p=2,type="const")

VAR Estimation Results:
=== 

Estimated coefficients for equation fossil: 
=== 
Call:
fossil = fossil.l1 + labour.l1 + fossil.l2 + labour.l2 + const 

 fossil.l1  labour.l1  fossil.l2  labour.l2  const 
 0.4686535 -0.5324335  0.2308964  0.8777865 -0.6711897 

Estimated coefficients for equation labour: 
=== 
Call:
labour = fossil.l1 + labour.l1 + fossil.l2 + labour.l2 + const 

  fossil.l1   labour.l1   fossil.l2   labour.l2   const 
 0.01431961  0.99648957  0.04160058 -0.11316312  1.11396823


If you take the last equation above (labour equation) the output is given as
follows:
fossil.l1   labour.l1   fossil.l2   labour.l2  const


is there any way I can have the output of this equation as follows:
fossil.l1  fossil.l2  labour.l1   labour.l2  const


It makes it easy to do hypothesis testing on specific lagged coefficients.



--
View this message in context: 
http://r.789695.n4.nabble.com/sorting-the-VAR-model-output-according-to-variable-names-tp4663770.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] Boxplot Labels

2013-04-09 Thread Beatriz González Domínguez
#Dear all,

#Could anyone help me with the following?
#DATA
num <- as.numeric(seq(100:125))
ave <- c(0.5, 1, 1.6, 2, 2, 2.3, 2.5, 2.4, 3, 3.2, 3.3, 4, 4.8, 3.5, 2.7, 3.1, 
2.8, 3.5, 4.1, 2.0, 2.5, 2.1, 3.4, 2.5, 2.6, 7)
DATA <- data.frame(cbind(num, ave))
rm(num, ave)

#BOXPLOT
x11()
bp <- boxplot(DATA$ave, data= DATA, main= "Average Size")
identify(x= bp$group, y= bp$out, labels= DATA$num, cex = 0.7) 
#I would like the labels that appear in the boxplot to be DATA$num values. 
#When I identify the outlier it appears a "1" when I would like to appear a "26"

#Do you have any idea of how I could do that?

#Many thanks!
#Bea
[[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] Boxplot Labels

2013-04-09 Thread Jose Iparraguirre
Estimada Beatriz,

If you use the Box.plot function in the car package (notice that here it's 
Box.plot, not box.plot), and add the argument id.method=c("identify"), it 
should work.
You only need one instruction:

R> library(car)
R> bp <- Boxplot(DATA$ave, data= DATA, main= "Average 
Size",id.method=c("identify"))

Kind regards,

José 

José Iparraguirre
Chief Economist
Age UK

T 020 303 31482
E jose.iparragui...@ageuk.org.uk
Twitter @jose.iparraguirre@ageuk


Tavis House, 1- 6 Tavistock Square
London, WC1H 9NB
www.ageuk.org.uk | ageukblog.org.uk | @ageukcampaigns 




-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On 
Behalf Of Beatriz González Domínguez
Sent: 09 April 2013 16:17
To: R Help; r-help@r-project.org
Subject: [R] Boxplot Labels

#Dear all,

#Could anyone help me with the following?
#DATA
num <- as.numeric(seq(100:125))
ave <- c(0.5, 1, 1.6, 2, 2, 2.3, 2.5, 2.4, 3, 3.2, 3.3, 4, 4.8, 3.5, 2.7, 3.1, 
2.8, 3.5, 4.1, 2.0, 2.5, 2.1, 3.4, 2.5, 2.6, 7)
DATA <- data.frame(cbind(num, ave))
rm(num, ave)

#BOXPLOT
x11()
bp <- boxplot(DATA$ave, data= DATA, main= "Average Size")
identify(x= bp$group, y= bp$out, labels= DATA$num, cex = 0.7) 
#I would like the labels that appear in the boxplot to be DATA$num values. 
#When I identify the outlier it appears a "1" when I would like to appear a "26"

#Do you have any idea of how I could do that?

#Many thanks!
#Bea
[[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.

Please donate to the Syria Crisis Appeal by text or online:

To donate £5 by mobile, text SYRIA to 70800.  To donate online, please visit 

http://www.ageinternational.org.uk/syria

Over one million refugees are desperately in need of water, food, healthcare, 
warm clothing, 
blankets and shelter; Age International urgently needs your support to help 
affected older refugees.


Age International is a subsidiary charity of Age UK and a member of the 
Disasters Emergency Committee (DEC).  
The DEC launches and co-ordinates national fundraising appeals for public 
donations on behalf of its member agencies.

Texts cost £5 plus one standard rate message.  Age International will receive a 
minimum of £4.96.  
More info at ageinternational.org.uk/SyriaTerms



 

---
Age UK is a registered charity and company limited by guarantee, (registered 
charity number 1128267, registered company number 6825798). 
Registered office: Tavis House, 1-6 Tavistock Square, London WC1H 9NA.

For the purposes of promoting Age UK Insurance, Age UK is an Appointed 
Representative of Age UK Enterprises Limited, Age UK is an Introducer 
Appointed Representative of JLT Benefit Solutions Limited and Simplyhealth 
Access for the purposes of introducing potential annuity and health 
cash plans customers respectively.  Age UK Enterprises Limited, JLT Benefit 
Solutions Limited and Simplyhealth Access are all authorised and 
regulated by the Financial Services Authority. 
--

This email and any files transmitted with it are confidential and intended 
solely for the use of the individual or entity to whom they are 
addressed. If you receive a message in error, please advise the sender and 
delete immediately.

Except where this email is sent in the usual course of our business, any 
opinions expressed in this email are those of the author and do not 
necessarily reflect the opinions of Age UK or its subsidiaries and associated 
companies. Age UK monitors all e-mail transmissions passing 
through its network and may block or modify mails which are deemed to be 
unsuitable.

Age Concern England (charity number 261794) and Help the Aged (charity number 
272786) and their trading and other associated companies merged 
on 1st April 2009.  Together they have formed the Age UK Group, dedicated to 
improving the lives of people in later life.  The three national 
Age Concerns in Scotland, Northern Ireland and Wales have also merged with Help 
the Aged in these nations to form three registered charities: 
Age Scotland, Age NI, Age Cymru.




__
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] Boxplot Labels

2013-04-09 Thread John Kane
  p <- boxplot(dat1$ave, data= dat1, main= "Average Size", yaxt = "n")
  text(1.1, , y  = max(dat1$ave), label = "26", cex = .7)
  
but I don't understand 
 #I would like the labels that appear in the boxplot to be DATA$num values.

You want 26 values potted?



John Kane
Kingston ON Canada


> -Original Message-
> From: aguitatie...@hotmail.com
> Sent: Tue, 9 Apr 2013 16:17:01 +0100
> To: r-help-boun...@r-project.org, r-help@r-project.org
> Subject: [R] Boxplot Labels
> 
> #Dear all,
> 
> #Could anyone help me with the following?
> #DATA
> num <- as.numeric(seq(100:125))
> ave <- c(0.5, 1, 1.6, 2, 2, 2.3, 2.5, 2.4, 3, 3.2, 3.3, 4, 4.8, 3.5, 2.7,
> 3.1, 2.8, 3.5, 4.1, 2.0, 2.5, 2.1, 3.4, 2.5, 2.6, 7)
> DATA <- data.frame(cbind(num, ave))
> rm(num, ave)
> 
> #BOXPLOT
> x11()
> bp <- boxplot(DATA$ave, data= DATA, main= "Average Size")
> identify(x= bp$group, y= bp$out, labels= DATA$num, cex = 0.7)
> #I would like the labels that appear in the boxplot to be DATA$num
> values.
> #When I identify the outlier it appears a "1" when I would like to appear
> a "26"
> 
> #Do you have any idea of how I could do that?
> 
> #Many thanks!
> #Bea
>   [[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.


FREE 3D MARINE AQUARIUM SCREENSAVER - Watch dolphins, sharks & orcas on your 
desktop!

__
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] Mistake in German Error message for friedman.test

2013-04-09 Thread P Ehlers



On 2013-04-09 7:35, kais...@med.uni-duesseldorf.de wrote:



There are two misspellings in the german Error message for friedman test:

Fehler in friedman.test.default(cont$score, group = cont$goup, blocks = 
cont$cont) :
   y, Gruppen und blöcke müssen die sekbe Länge haben

The correct spelling would be:

Fehler in friedman.test.default(cont$score, group = cont$goup, blocks = 
cont$cont) :
   y, Gruppen und *Blöcke* müssen die *selbe* Länge haben


Instead of "die selbe", it could be "dieselbe" or "die gleiche".


I believe that "die gleiche" would be most precise.

Peter Ehlers



Thanks
W. Kaisers



[[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] rep() fails at times=0.29*100

2013-04-09 Thread Jorge Fernando Saraiva de Menezes
Dear list,

I have found an unusual behavior and would like to check if it is a
possible bug, and if updating R would fix it. I am not sure if should post
it in this mail list but I don't where is R bug tracker. The only mention I
found that might relate to this is "If times is a computed quantity it is
prudent to add a small fuzz." in rep() help, but not sure if it is related
to this particular problem

Here it goes:

> rep(TRUE,29)
 [1] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE
TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE
[28] TRUE TRUE
> rep(TRUE,0.29*100)
 [1] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE
TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE
[28] TRUE
> length(rep(TRUE,29))
[1] 29
> length(rep(TRUE,0.29*100))
[1] 28

Just to make sure:
> 0.29*100
[1] 29

This behavior seems to be independent of what is being repeated (rep()'s
first argument)
> length(rep(1,0.29*100))
[1] 28

Also it occurs only with the 0.29.
> length(rep(1,0.291*100))
[1] 29
> for(a in seq(0,1,0.01)) {print(sum(rep(TRUE,a*100)))} #also shows correct
values in values from 0 to 1 except for 0.29.

I have confirmed that this behavior happens in more than one machine
(though I only have session info of this one)


> sessionInfo()
R version 2.15.3 (2013-03-01)
Platform: x86_64-w64-mingw32/x64 (64-bit)

locale:
[1] LC_COLLATE=Portuguese_Brazil.1252  LC_CTYPE=Portuguese_Brazil.1252
 LC_MONETARY=Portuguese_Brazil.1252
[4] LC_NUMERIC=C   LC_TIME=Portuguese_Brazil.1252

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

other attached packages:
[1] spatstat_1.31-1 deldir_0.0-21   mgcv_1.7-22

loaded via a namespace (and not attached):
[1] grid_2.15.3 lattice_0.20-13 Matrix_1.0-11   nlme_3.1-108
 tools_2.15.3

[[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] Boxplot Labels OK

2013-04-09 Thread Beatriz González Domínguez
Dear all,

I have just sent an enquiry but probably I hadn’t expressed myself properly. 

Could anyone help me with the following?

When I run the code on my data I get a boxplot with outliers identified by 
numbers 200 & 201.
However, what I would like is to label these outliers with their corresponding 
“DATA$num” values of the data frame. 
In this example, the outliers should be labelled as: 211 & 225

Do you have any idea of how I could do this?

Please, if you need any more details just get in touch.

Many thanks in advance! 

## R CODE
#DATA
num <- as.numeric(200:225)
ave <- c(0.5, 1, 1.6, 2, 2, 2.3, 2.5, 2.4, 3, 3.2, 3.3, 7.2, 4, 4.8, 3.5, 2.7, 
3.1, 2.8, 4.1, 2.0, 2.5, 2.1, 3.4, 2.5, 2.6, 7)
DATA <- data.frame(cbind(num, ave))
rm(num, ave)

#BOXPLOT
x11()
bp <- boxplot(DATA$ave, data= DATA, main= "Average Size")
identify(x= bp$group, y= bp$out, labels= DATA$num, cex = 0.7)

Bea
[[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] rep() fails at times=0.29*100

2013-04-09 Thread Henrik Bengtsson
FYI,

> (0.29*100) < 29
[1] TRUE

See R FAQ 7.31 for why.

/Henrik

On Tue, Apr 9, 2013 at 9:11 AM, Jorge Fernando Saraiva de Menezes
 wrote:
> Dear list,
>
> I have found an unusual behavior and would like to check if it is a
> possible bug, and if updating R would fix it. I am not sure if should post
> it in this mail list but I don't where is R bug tracker. The only mention I
> found that might relate to this is "If times is a computed quantity it is
> prudent to add a small fuzz." in rep() help, but not sure if it is related
> to this particular problem
>
> Here it goes:
>
>> rep(TRUE,29)
>  [1] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE
> TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE
> [28] TRUE TRUE
>> rep(TRUE,0.29*100)
>  [1] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE
> TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE
> [28] TRUE
>> length(rep(TRUE,29))
> [1] 29
>> length(rep(TRUE,0.29*100))
> [1] 28
>
> Just to make sure:
>> 0.29*100
> [1] 29
>
> This behavior seems to be independent of what is being repeated (rep()'s
> first argument)
>> length(rep(1,0.29*100))
> [1] 28
>
> Also it occurs only with the 0.29.
>> length(rep(1,0.291*100))
> [1] 29
>> for(a in seq(0,1,0.01)) {print(sum(rep(TRUE,a*100)))} #also shows correct
> values in values from 0 to 1 except for 0.29.
>
> I have confirmed that this behavior happens in more than one machine
> (though I only have session info of this one)
>
>
>> sessionInfo()
> R version 2.15.3 (2013-03-01)
> Platform: x86_64-w64-mingw32/x64 (64-bit)
>
> locale:
> [1] LC_COLLATE=Portuguese_Brazil.1252  LC_CTYPE=Portuguese_Brazil.1252
>  LC_MONETARY=Portuguese_Brazil.1252
> [4] LC_NUMERIC=C   LC_TIME=Portuguese_Brazil.1252
>
> attached base packages:
> [1] stats graphics  grDevices utils datasets  methods   base
>
> other attached packages:
> [1] spatstat_1.31-1 deldir_0.0-21   mgcv_1.7-22
>
> loaded via a namespace (and not attached):
> [1] grid_2.15.3 lattice_0.20-13 Matrix_1.0-11   nlme_3.1-108
>  tools_2.15.3
>
> [[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] Boxplot Labels

2013-04-09 Thread Rui Barradas

Hello,

The construct data.frame(cbind(...)) is not at all needed, the following 
is much better.


dat1 <- data.frame(num, ave)


Also, I've modified the text() call a bit, in order to have R tell the 
dat1$num corresponding to the (unique) max of ave, and with an extra 
argument, pos. This would allow for placement of the label near the point.


p <- boxplot(dat1$ave, data= dat1, main= "Average Size", yaxt = "n")
text(1, , y = max(dat1$ave), label = dat1$num[which.max(dat1$ave)], cex 
= .7, pos = 4)



Hope this helps,

Rui Barradas


Em 09-04-2013 16:44, John Kane escreveu:

   p <- boxplot(dat1$ave, data= dat1, main= "Average Size", yaxt = "n")
   text(1.1, , y  = max(dat1$ave), label = "26", cex = .7)

but I don't understand
  #I would like the labels that appear in the boxplot to be DATA$num values.

You want 26 values potted?



John Kane
Kingston ON Canada



-Original Message-
From: aguitatie...@hotmail.com
Sent: Tue, 9 Apr 2013 16:17:01 +0100
To: r-help-boun...@r-project.org, r-help@r-project.org
Subject: [R] Boxplot Labels

#Dear all,

#Could anyone help me with the following?
#DATA
num <- as.numeric(seq(100:125))
ave <- c(0.5, 1, 1.6, 2, 2, 2.3, 2.5, 2.4, 3, 3.2, 3.3, 4, 4.8, 3.5, 2.7,
3.1, 2.8, 3.5, 4.1, 2.0, 2.5, 2.1, 3.4, 2.5, 2.6, 7)
DATA <- data.frame(cbind(num, ave))
rm(num, ave)

#BOXPLOT
x11()
bp <- boxplot(DATA$ave, data= DATA, main= "Average Size")
identify(x= bp$group, y= bp$out, labels= DATA$num, cex = 0.7)
#I would like the labels that appear in the boxplot to be DATA$num
values.
#When I identify the outlier it appears a "1" when I would like to appear
a "26"

#Do you have any idea of how I could do that?

#Many thanks!
#Bea
[[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.



FREE 3D MARINE AQUARIUM SCREENSAVER - Watch dolphins, sharks & orcas on your 
desktop!

__
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] Text Encoding

2013-04-09 Thread Emily Ottensmeyer
Dear Milan and David,

Thank you both very much for your help!  I finally figured it out.

Text on the website was UTF-8, but in the process of downloading it using
RDF, it got converted to the java/javascript encoding.  To convert it back
to UTF-8:

> test <- "4.5\\u00B5g of cDNA was used"
> iconv(test, "JAVA", "UTF-8")
[1] "4.5µg of cDNA was used"

This may also impact anyone using JSON with R.  Posting here in case it
helps anyone else.  =)

-Emily


On Sat, Apr 6, 2013 at 10:37 AM, David Winsemius wrote:

>
> On Apr 5, 2013, at 11:30 AM, Emily Ottensmeyer wrote:
>
> > Dear R-Help,
> >
> > I am using the RDF package/ R 2.14 with the RDF package to download data
> > from a website, and then use R to manipulate it.
> >
> > Text on the website is UTF-8.  The RDF package's rdf_load command is
> > converting it into a different encoding, which converts non-ASCII
> > characters to unicode codes.
> >
> > On the webpage/sparql RDF: "4.5µg of cDNA was used"
> >
> > In R, the RDF triple gives: "4.5\\u00B5g of cDNA was used"
> >
> > I can't seem to convert it back from \\u00B5  into "µ".
> >
> > I've tried iconv with various settings without success:
> >> iconv(test, "latin1", "UTF-8")
> > [1] "4.5\\u00B5g of cDNA was used"
> >
> > And, I tried Encoding, to see if I could figure that out, but it returns
> > "unknown" on my string.
> >> Encoding(test)
> > [1] "unknown"
> >
> On my device entering this: "4.5\\u00B5g of cDNA was used"
>
> ... returns [1] "4.5\\u00B5g of cDNA was used"
>
> But entering: "4.5\u00B5g of cDNA was used" returns:
>
> [1] "4.5µg of cDNA was used"
>
> > nchar("4.5\\u00B5g of cDNA was used")
> [1] 27
> > nchar("4.5\u00B5g of cDNA was used")
> [1] 22
>
> So the doubled "\" is really a single character in the first case  and has
> no effect in escaping the next four hex digits but "\u00B5" in the second
> case is a correct "micro-character" (for my setup with my fonts)
>
> If this is a systematic problem then you should contact the maintainer
> with a full problem description and a link to the website. If this is just
> a one-off problem just remove the extraneous backslash.
>
> --
> David.
>
> > sessionInfo()
> R version 3.0.0 RC (2013-03-31 r62463)
> Platform: x86_64-apple-darwin10.8.0 (64-bit)
>
> locale:
> [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
> 
>
> > Anyone have any ideas on how to correct/convert the text encoding?
> >
> >
> > Thanks!
> > -Emily
> >
> >   [[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.
>
> David Winsemius
> Alameda, CA, USA
>
>

[[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] Behaviors of diag() with character vector in R 3.0.0

2013-04-09 Thread R. Michael Weylandt
On Tue, Apr 9, 2013 at 7:15 AM, Mike Cheung  wrote:
> Dear all,
>
> According to CHANGES IN R 3.0.0:
>  o diag() as used to generate a diagonal matrix has been re-written
>   in C for speed and less memory usage.  It now forces the result
>   to be numeric in the case diag(x) since it is said to have 'zero
>   off-diagonal entries'.
>
> diag(x) does not work for character vector in R 3.0.0 any more. For example,
> v <- c("a", "b")
>
> ## R 2.15.3
> diag(v)
>  [,1] [,2]
> [1,] "a"  "0"
> [2,] "0"  "b"
>
> ## R 3.0.0
> diag(v)
>  [,1] [,2]
> [1,]   NA0
> [2,]0   NA
> Warning message:
> In diag(v) : NAs introduced by coercion
>
> Regarding the character matrix, it still works. For example,
> m <- matrix(c("a", "b", "c", "d"), nrow=2)
> diag(m)
> ## Both R 2.15.3 and 3.0.0
> [1] "a" "d"
>
> n <- matrix(0, ncol=2, nrow=2)
> diag(n) <- v
> n
> ## Both R 2.15.3 and 3.0.0
>  [,1] [,2]
> [1,] "a"  "0"
> [2,] "0"  "b"
>
> I understand that the above behavior follows exactly what the manual says.
> It appears to me that the version in 2.15.3 is more general as it works for
> both numeric and character vectors and matrices, whereas the version in
> 3.0.0 works for character matrices but not character vectors.
>
> Would it be possible to retain the behaviors of diag() for character
> vectors? Thanks.

Persuant to what the NEWS file says, I'm not sure it's a good idea,
but here's a patch against a recent R-devel which I believe restores
the old behavior. It's not coming out of svn diff too cleanly, but it
applies as it should.

Should it be adopted, someone with more taste might want to move case
VECSXP or case RAWSXP to error out as well.

Michael

Index: array.c
===
--- array.c (revision 62536)
+++ array.c (working copy)
@@ -1539,26 +1539,41 @@
  error(_("too many elements specified"));
 #endif

-   if (TYPEOF(x) == CPLXSXP) {
+   int nx = LENGTH(x);
+   R_xlen_t NR = nr;
+
+   switch(TYPEOF(x)){
+   case CPLXSXP:
PROTECT(ans = allocMatrix(CPLXSXP, nr, nc));
-   int nx = LENGTH(x);
-   R_xlen_t NR = nr;
-   Rcomplex *rx = COMPLEX(x), *ra = COMPLEX(ans), zero;
+   Rcomplex *cx = COMPLEX(x), *ca = COMPLEX(ans), zero;
zero.r = zero.i = 0.0;
-   for (R_xlen_t i = 0; i < NR*nc; i++) ra[i] = zero;
-   for (int j = 0; j < mn; j++) ra[j * (NR+1)] = rx[j % nx];
-  } else {
-   if(TYPEOF(x) != REALSXP) {
+   for(R_xlen_t i = 0; i < NR*nc; i++) ca[i] = zero;
+   for(int j = 0; j < mn; j++) ca[j*(NR+1)] = cx[j % nx];
+   break;
+   case LGLSXP:
+   case REALSXP:
+   case INTSXP:
+   case RAWSXP:
+   case VECSXP:
+   if(TYPEOF(x) != REALSXP){
PROTECT(x = coerceVector(x, REALSXP));
nprotect++;
}
PROTECT(ans = allocMatrix(REALSXP, nr, nc));
-   int nx = LENGTH(x);
-   R_xlen_t NR = nr;
double *rx = REAL(x), *ra = REAL(ans);
for (R_xlen_t i = 0; i < NR*nc; i++) ra[i] = 0.0;
for (int j = 0; j < mn; j++) ra[j * (NR+1)] = rx[j % nx];
+   break;
+   case STRSXP:
+ PROTECT(ans = allocMatrix(STRSXP, nr, nc));
+ for (R_xlen_t i = 0; i < NR*nc; i++) SET_STRING_ELT(ans, i,
mkChar("0")); // Odd to put character 0 here?
+ for (R_xlen_t j = 0; j < mn; j++) SET_STRING_ELT(ans, j*(NR+1),
STRING_ELT(x, j));
+ break;
+   default:
+ error(_("'data' must be of a vector type, was '%s'"),
+   type2char(TYPEOF(x)));
}
+
UNPROTECT(nprotect);
return ans;
 }
__
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] Boxplot Labels

2013-04-09 Thread David L Carlson
The problem is that identify() is designed for a scatterplot not a boxplot.
You can use it but you have to feed it the correct x and y coordinates:

identify(rep(1, nrow(DATA)), DATA$ave, cex=.7)

This will give you "26" as you requested if you click on the outlying point.
That is the row name for the point. You specified DATA$num as your labels,
but they are the same as the row names so there is no need to add that. You
can also identify points at the whiskers, hinges, or median, but they will
probably overprint the lines.

I wasn't sure if your definition of num was intentional or a mistype, eg:

> num <- as.numeric(seq(100:125))
> num
 [1]  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
25
[26] 26
> num <- as.numeric(seq(100, 125))
> num
 [1] 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117
118
[20] 119 120 121 122 123 124 125
>

If you wanted the numbers from 1 to 26, num <- 1:26 would be more compact.

--
David L Carlson
Associate Professor of Anthropology
Texas A&M University
College Station, TX 77843-4352



> -Original Message-
> From: r-help-boun...@r-project.org [mailto:r-help-bounces@r-
> project.org] On Behalf Of John Kane
> Sent: Tuesday, April 09, 2013 10:45 AM
> To: Beatriz González Domínguez; R Help; r-help@r-project.org
> Subject: Re: [R] Boxplot Labels
> 
>   p <- boxplot(dat1$ave, data= dat1, main= "Average Size", yaxt = "n")
>   text(1.1, , y  = max(datDAT1$ave), label = "26", cex = .7)
> 
> but I don't understand
>  #I would like the labels that appear in the boxplot to be DATA$num
> values.
> 
> You want 26 values potted?
> 
> 
> 
> John Kane
> Kingston ON Canada
> 
> 
> > -Original Message-
> > From: aguitatie...@hotmail.com
> > Sent: Tue, 9 Apr 2013 16:17:01 +0100
> > To: r-help-boun...@r-project.org, r-help@r-project.org
> > Subject: [R] Boxplot Labels
> >
> > #Dear all,
> >
> > #Could anyone help me with the following?
> > #DATA
> > num <- as.numeric(seq(100:125))
> > ave <- c(0.5, 1, 1.6, 2, 2, 2.3, 2.5, 2.4, 3, 3.2, 3.3, 4, 4.8, 3.5,
> 2.7,
> > 3.1, 2.8, 3.5, 4.1, 2.0, 2.5, 2.1, 3.4, 2.5, 2.6, 7)
> > DATA <- data.frame(cbind(num, ave))
> > rm(num, ave)
> >
> > #BOXPLOT
> > x11()
> > bp <- boxplot(DATA$ave, data= DATA, main= "Average Size")
> > identify(x= bp$group, y= bp$out, labels= DATA$num, cex = 0.7)
> > #I would like the labels that appear in the boxplot to be DATA$num
> > values.
> > #When I identify the outlier it appears a "1" when I would like to
> appear
> > a "26"
> >
> > #Do you have any idea of how I could do that?
> >
> > #Many thanks!
> > #Bea
> > [[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.
> 
> 
> FREE 3D MARINE AQUARIUM SCREENSAVER - Watch dolphins, sharks & orcas on
> your desktop!
> 
> __
> 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] rep() fails at times=0.29*100

2013-04-09 Thread arun
Possibly R FAQ 7.31

length(rep(TRUE,signif(0.29*100,2)))
#[1] 29
A.K.


- Original Message -
From: Jorge Fernando Saraiva de Menezes 
To: r-help@r-project.org
Cc: 
Sent: Tuesday, April 9, 2013 12:11 PM
Subject: [R] rep() fails at times=0.29*100

Dear list,

I have found an unusual behavior and would like to check if it is a
possible bug, and if updating R would fix it. I am not sure if should post
it in this mail list but I don't where is R bug tracker. The only mention I
found that might relate to this is "If times is a computed quantity it is
prudent to add a small fuzz." in rep() help, but not sure if it is related
to this particular problem

Here it goes:

> rep(TRUE,29)
[1] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE
TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE
[28] TRUE TRUE
> rep(TRUE,0.29*100)
[1] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE
TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE
[28] TRUE
> length(rep(TRUE,29))
[1] 29
> length(rep(TRUE,0.29*100))
[1] 28

Just to make sure:
> 0.29*100
[1] 29

This behavior seems to be independent of what is being repeated (rep()'s
first argument)
> length(rep(1,0.29*100))
[1] 28

Also it occurs only with the 0.29.
> length(rep(1,0.291*100))
[1] 29
> for(a in seq(0,1,0.01)) {print(sum(rep(TRUE,a*100)))} #also shows correct
values in values from 0 to 1 except for 0.29.

I have confirmed that this behavior happens in more than one machine
(though I only have session info of this one)


> sessionInfo()
R version 2.15.3 (2013-03-01)
Platform: x86_64-w64-mingw32/x64 (64-bit)

locale:
[1] LC_COLLATE=Portuguese_Brazil.1252  LC_CTYPE=Portuguese_Brazil.1252
LC_MONETARY=Portuguese_Brazil.1252
[4] LC_NUMERIC=C                       LC_TIME=Portuguese_Brazil.1252

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

other attached packages:
[1] spatstat_1.31-1 deldir_0.0-21   mgcv_1.7-22

loaded via a namespace (and not attached):
[1] grid_2.15.3     lattice_0.20-13 Matrix_1.0-11   nlme_3.1-108
tools_2.15.3

    [[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] rep() fails at times=0.29*100

2013-04-09 Thread Ted Harding
[See at end]
On 09-Apr-2013 16:11:18 Jorge Fernando Saraiva de Menezes wrote:
> Dear list,
> 
> I have found an unusual behavior and would like to check if it is a
> possible bug, and if updating R would fix it. I am not sure if should post
> it in this mail list but I don't where is R bug tracker. The only mention I
> found that might relate to this is "If times is a computed quantity it is
> prudent to add a small fuzz." in rep() help, but not sure if it is related
> to this particular problem
> 
> Here it goes:
> 
>> rep(TRUE,29)
>  [1] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE
> TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE
> [28] TRUE TRUE
>> rep(TRUE,0.29*100)
>  [1] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE
> TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE
> [28] TRUE
>> length(rep(TRUE,29))
> [1] 29
>> length(rep(TRUE,0.29*100))
> [1] 28
> 
> Just to make sure:
>> 0.29*100
> [1] 29
> 
> This behavior seems to be independent of what is being repeated (rep()'s
> first argument)
>> length(rep(1,0.29*100))
> [1] 28
> 
> Also it occurs only with the 0.29.
>> length(rep(1,0.291*100))
> [1] 29
>> for(a in seq(0,1,0.01)) {print(sum(rep(TRUE,a*100)))} #also shows correct
> values in values from 0 to 1 except for 0.29.
> 
> I have confirmed that this behavior happens in more than one machine
> (though I only have session info of this one)
> 
> 
>> sessionInfo()
> R version 2.15.3 (2013-03-01)
> Platform: x86_64-w64-mingw32/x64 (64-bit)
> [1]  LC_COLLATE=Portuguese_Brazil.1252  LC_CTYPE=Portuguese_Brazil.1252
>  LC_MONETARY=Portuguese_Brazil.1252
> [4] LC_NUMERIC=C   LC_TIME=Portuguese_Brazil.1252
> 
> attached base packages:
> [1] stats graphics  grDevices utils datasets  methods   base
> 
> other attached packages:
> [1] spatstat_1.31-1 deldir_0.0-21   mgcv_1.7-22
> 
> loaded via a namespace (and not attached):
> [1] grid_2.15.3 lattice_0.20-13 Matrix_1.0-11   nlme_3.1-108
>  tools_2.15.3

The basic issue is, believe or not, that despite apparently:
  0.29*100
  # [1] 29

in "reality":
  0.29*100 == 29
  # [1] FALSE

In other words, as computed by R, 0.29*100 is not exactly equal to 29:

  29 - 0.29*100
  # [1] 3.552714e-15

The difference is tiny, but it is sufficient to make 0.29*100 slightly
smaller than 29, so rep(TRUE,0.29*100) uses the largest integer compatible
with "times = 0.29*100", i.e. 28. Hence the recommendation to "add a
little fuzz".

On the other hand, when you use rep(1,0.291*100) you will be OK:
This is because:

  29 - 0.291*100
  # [1] -0.1

so 0.291*100 is comfortably greater than 29 (but well clear of 30).

The reason for the small inaccuracy (compared with "mathematical
truth") is that R performs numerical calculations using binary
representations of numbers, and there is no exact binary representation
of 0.29, so the result of 0.29*100 will be slightly inaccurate.

If you do need to do this sort of thing (e.g. the value of "times"
will be the result of a calculation) then one useful precaution
could be to round the result:

  round(0.29*100)
  # [1] 29
  29-round(0.29*100)
  # [1] 0
  length(rep(TRUE,0.29*100))
  # [1] 28
  length(rep(TRUE,round(0.29*100)))
  # [1] 29

(The default for round() is 0 decimal places, i.e. it rounds to
an integer).

So, compared with:
  0.29*100 == 29
  # [1] FALSE

we have:
  round(0.29*100) == 29
  # [1] TRUE

Hoping this helps,
Ted.

-
E-Mail: (Ted Harding) 
Date: 09-Apr-2013  Time: 17:56:33
This message was sent by XFMail

__
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] Confirmatory Factor Analysis

2013-04-09 Thread Laura Thomas
Hi,

I have used R to run a confirmatory factor analysis using the sem package.
The analysis has run ok, but I am missing some information (e.g., Tucker
Lewis Index, RMSEA) I was wondering if there was a reason for this, I have
though it may be due to the low sample size?

Any help would be appreciated.

Many Thanks,

Laura


Laura Thomas
PhD Student- Sport and Exercise Psychology
Department of Sport and Exercise
Penglais Campus
Aberystywth University
Aberystwyth

01970621947
l...@aber.ac.uk
www.aber.ac.uk/en/sport-exercise/

__
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] rep() fails at times=0.29*100

2013-04-09 Thread Jorge Fernando Saraiva de Menezes
Thank for your help,  and sorry for posting before reading the FAQ, I know
it is one of the basic rules. Though, knowing myself I would never relate
the error in rep with 0.29*100!=29


2013/4/9 arun 

> Possibly R FAQ 7.31
>
> length(rep(TRUE,signif(0.29*100,2)))
> #[1] 29
> A.K.
>
>
> - Original Message -
> From: Jorge Fernando Saraiva de Menezes 
> To: r-help@r-project.org
> Cc:
> Sent: Tuesday, April 9, 2013 12:11 PM
> Subject: [R] rep() fails at times=0.29*100
>
> Dear list,
>
> I have found an unusual behavior and would like to check if it is a
> possible bug, and if updating R would fix it. I am not sure if should post
> it in this mail list but I don't where is R bug tracker. The only mention I
> found that might relate to this is "If times is a computed quantity it is
> prudent to add a small fuzz." in rep() help, but not sure if it is related
> to this particular problem
>
> Here it goes:
>
> > rep(TRUE,29)
> [1] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE
> TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE
> [28] TRUE TRUE
> > rep(TRUE,0.29*100)
> [1] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE
> TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE
> [28] TRUE
> > length(rep(TRUE,29))
> [1] 29
> > length(rep(TRUE,0.29*100))
> [1] 28
>
> Just to make sure:
> > 0.29*100
> [1] 29
>
> This behavior seems to be independent of what is being repeated (rep()'s
> first argument)
> > length(rep(1,0.29*100))
> [1] 28
>
> Also it occurs only with the 0.29.
> > length(rep(1,0.291*100))
> [1] 29
> > for(a in seq(0,1,0.01)) {print(sum(rep(TRUE,a*100)))} #also shows correct
> values in values from 0 to 1 except for 0.29.
>
> I have confirmed that this behavior happens in more than one machine
> (though I only have session info of this one)
>
>
> > sessionInfo()
> R version 2.15.3 (2013-03-01)
> Platform: x86_64-w64-mingw32/x64 (64-bit)
>
> locale:
> [1] LC_COLLATE=Portuguese_Brazil.1252  LC_CTYPE=Portuguese_Brazil.1252
> LC_MONETARY=Portuguese_Brazil.1252
> [4] LC_NUMERIC=C   LC_TIME=Portuguese_Brazil.1252
>
> attached base packages:
> [1] stats graphics  grDevices utils datasets  methods   base
>
> other attached packages:
> [1] spatstat_1.31-1 deldir_0.0-21   mgcv_1.7-22
>
> loaded via a namespace (and not attached):
> [1] grid_2.15.3 lattice_0.20-13 Matrix_1.0-11   nlme_3.1-108
> tools_2.15.3
>
> [[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.
>
>

[[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] sensitivity for grouped data

2013-04-09 Thread Endy BlackEndy
I could not locate any package (using RSeek.org) to compute sensitivity,
specificity and related measures, for logistic regression models with
grouped data. (For ungrouped data I know one, the SMDTools). Any suggestion
will be greatly appreciated.

Many thanks
Endy

[[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] Boxplot Labels OK

2013-04-09 Thread Rui Barradas

Hello,

The answers you had in another thread could lead you to

bp <- boxplot(DATA$ave, data= DATA, main= "Average Size")
idx <- which(DATA$ave %in% bp$out)
text(x= bp$group, y= bp$out, labels= DATA$num[idx], cex = 0.7, pos = 4)


Hope this helps,

Rui Barradas

Em 09-04-2013 17:31, Beatriz González Domínguez escreveu:

Dear all,

I have just sent an enquiry but probably I hadn’t expressed myself properly.

Could anyone help me with the following?

When I run the code on my data I get a boxplot with outliers identified by numbers 
200 & 201.
However, what I would like is to label these outliers with their corresponding 
“DATA$num� values of the data frame.
In this example, the outliers should be labelled as: 211 & 225

Do you have any idea of how I could do this?

Please, if you need any more details just get in touch.

Many thanks in advance!

## R CODE
#DATA
num <- as.numeric(200:225)
ave <- c(0.5, 1, 1.6, 2, 2, 2.3, 2.5, 2.4, 3, 3.2, 3.3, 7.2, 4, 4.8, 3.5, 2.7, 
3.1, 2.8, 4.1, 2.0, 2.5, 2.1, 3.4, 2.5, 2.6, 7)
DATA <- data.frame(cbind(num, ave))
rm(num, ave)

#BOXPLOT
x11()
bp <- boxplot(DATA$ave, data= DATA, main= "Average Size")
identify(x= bp$group, y= bp$out, labels= DATA$num, cex = 0.7)

Bea
[[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] R crash

2013-04-09 Thread Tasnuva Tabassum
I have a generalized linear model to solve. I used package "geepack". When
I use the correlation structure "unstructured", I get a messeage that- R
GUI front-end has stopped working. Why this happens? What is the solution?
The r codes are as follows:
a<-read.table("d:/bmt.txt",header=T")
cutoffs<-c(1.75,3.34,5.09,6.93,9.11,11.8,15.3,20.1,23.7,27.3,30.9,34.3,37.6,41.5,46.5,51.1,57,63,73.1,93.68)
a$icr <- REL
library(pseudo)
pseudo <- pseudoci(time=a$TIME,event=a$icr,tmax=cutoffs)

#rearranging data
b <- NULL
 for(it in 1:length(pseudo$time)){
 b <- rbind(b,cbind(a,pseudo = pseudo$pseudo[[1]][,it],
 tpseudo = pseudo$time[it],id=1:nrow(a)))
 }
 b <- b[order(b$id),]


 library(geepack)

fit3 <-  geese(pseudo ~ as.factor(AGE) + as.factor(WEIGHT) +
as.factor(HEIGHT) ,
data =b, id=id, jack = TRUE, scale.fix=TRUE,
mean.link = "logit", corstr="unstructured")

#The results using the AJ variance estimate
cbind(mean = round(fit3$beta,4), SD = round(sqrt(diag(fit3$vbeta.ajs)),4),
Z = round(fit3$beta/sqrt(diag(fit3$vbeta.ajs)),4),
PVal = round(2-2*pnorm(abs(fit3$beta/sqrt(diag(fit3$vbeta.ajs,4))

[[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] Confirmatory Factor Analysis

2013-04-09 Thread John Fox
Dear Laura,

In the current version of the Rcmdr package, output of "fit indices" beyond
the LR test, AIC, and BIC is optional, and is controlled by the fit.indices
argument to the summary() method (see ?summary.objectiveML) or by the
fit.indices option. Everyone seems to have different preferences for fit
indices and allowing each person to choose seemed preferable to just
printing them all out.

I hope this helps,
 John

> -Original Message-
> From: r-help-boun...@r-project.org [mailto:r-help-bounces@r-
> project.org] On Behalf Of Laura Thomas
> Sent: Tuesday, April 09, 2013 12:28 PM
> To: r-help@r-project.org
> Subject: [R] Confirmatory Factor Analysis
> 
> Hi,
> 
> I have used R to run a confirmatory factor analysis using the sem
> package.
> The analysis has run ok, but I am missing some information (e.g.,
> Tucker
> Lewis Index, RMSEA) I was wondering if there was a reason for this, I
> have
> though it may be due to the low sample size?
> 
> Any help would be appreciated.
> 
> Many Thanks,
> 
> Laura
> 
> 
> Laura Thomas
> PhD Student- Sport and Exercise Psychology
> Department of Sport and Exercise
> Penglais Campus
> Aberystywth University
> Aberystwyth
> 
> 01970621947
> l...@aber.ac.uk
> www.aber.ac.uk/en/sport-exercise/
> 
> __
> 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] Question on Stopword Removal from a Cyrillic (Bulgarian)Text

2013-04-09 Thread Milan Bouchet-Valat
Le mardi 09 avril 2013 à 10:10 +0300, Ventseslav Kozarev, MPP a écrit :
> Hi,
> 
> I bumped into a serious issue while trying to analyse some texts in 
> Bulgarian language (with the tm package). I import a tab-separated csv 
> file, which holds a total of 22 variables, most of which are text cells 
> (not factors), using the read.delim function:
> 
> data<-read.delim("bigcompanies_ascii.csv",
>  header=TRUE,
>  quote="'",
>  sep="\t",
>  as.is=TRUE,
>  encoding='CP1251',
>  fileEncoding='CP1251')
> 
> (I also tried the above with UTF-8 encoding on a UTF-8-saved file.)
> 
> I have my list of stop words written in a separate text file, one word 
> per line, which I read into R using the scan function:
> 
> stoplist<-scan(file='stoplist_ascii.txt',
> what='character',
> strip.white=TRUE,
> blank.lines.skip=TRUE,
> fileEncoding='CP1251',
> encoding='CP1251')
> 
> (also tried with UTF-8 here on a correspondingly encoded file)
> 
> I currently only test with a corpus based on the contents of just one 
> variable, and I construct the corpus from a VectorSource. When I run 
> inspect, all seems fine and I can see the text properly, with unicode 
> characters present:
> 
> data.corpus<-Corpus(VectorSource(data$variable,encoding='UTF-8'),
> readerControl=list(language='bulgarian'))
> 
> However, no matter what I do - like which encoding I select - UTF-8 or 
> CP1251, which is the typical code page for Bulgarian texts, I cannot get 
> to remove the stop words from my corpus. The issue is present in both 
> Linux and Windows, and across the computers I use R on, and I don't 
> think it is related to bad configuration. Removal of punctuation, white 
> space, and numbers is flawless, but the inability to remove stop words 
> prevents me from further analysing the texts.
> 
> Has somebody had experience with languages other than English, and for 
> which there is no predefined stop list available through the stopwords 
> function? I will highly appreciate any tips and advice!
Well, at least show us the code that you use to remove stopwords... Can
you provide a reproducible example with a toy corpus?

> Thanks in advance,
> Vince
> 
> __
> 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] Simple GLS regression with CAPER

2013-04-09 Thread Xavier Prudent
Dear R experts,

I hope this is the right list for my question.

As a newcomer in R, I am testing the R CAPER package, applying a simple
regression on a phylogeny tree with three binary traits: (t1, t2, t3).

My goal is to test the sensitivity to a correlation between t1 and t3. But
if a correlation of 100% is considered (i.e. t3 = t1). The pgls method of
CAPER seems to crash:

You can find there the code I used
http://iktp.tu-dresden.de/~prudent/Divers/R/toy.R
with the tree
http://iktp.tu-dresden.de/~prudent/Divers/R/toy3.tree
and the data
http://iktp.tu-dresden.de/~prudent/Divers/R/toy_cor100.data

just copy the .tree and .data files and run
> R
> source("toy.R")

(please find the outpt below)

Am I doing anything wrong?

Thanks in advance,

regards,

Xavier Prudent

==
>>> Regression #2


Call:
pgls(formula = t1 ~ t3, data = cdat)

Coefficients:
(Intercept)   t3
  01


Call:
pgls(formula = t1 ~ t3, data = cdat)

Residuals:
   Min 1Q Median 3QMax
 0  0  0  0  0

Branch length transformations:

kappa  [Fix]  : 1.000
lambda [Fix]  : 1.000
delta  [Fix]  : 1.000

Coefficients:
Estimate Std. Error t value  Pr(>|t|)
(Intercept)0  0  NANA
t3 1  0 Inf < 2.2e-16 ***
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 0 on 8 degrees of freedom
Multiple R-squared: 1,  Adjusted R-squared: 1
F-statistic:   Inf on 2 and 8 DF,  p-value: < 2.2e-16
Error in density.default(res) : 'x' contains missing values
===

[[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] calculating number of peaks from acf

2013-04-09 Thread Aimee Kopolow
Hi,

Is there a way to calculate the number of peaks produced when running acf
on time series data? What I'm looking for is a way to calculate the number
of peaks that are greater than the confidence limits if the lag is preset
and constant.



thanks for any help you are able to give,
Aimee.

[[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] Confirmatory Factor Analysis

2013-04-09 Thread Laura Thomas
Hi,

I have used sem package to run confirmatory factor analysis. The analysis
has run ok, but I am missing some information (e.g., Tucker
Lewis Index, RMSEA) I was wondering if there was a reason for this, I have
though it may be due to the low sample size?

Any help would be appreciated.

Many Thanks,

Laura



Laura Thomas
PhD Student- Sport and Exercise Psychology
Department of Sport and Exercise
Penglais Campus
Aberystywth University
Aberystwyth

01970621947
l...@aber.ac.uk
www.aber.ac.uk/en/sport-exercise/

__
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 does clusplot exactly make use of cmdscale?

2013-04-09 Thread Junru Wu
Dear people,

I used clusplot to plot a partition result. The partition result was from
pamk with a distance object as input. Then I applied cmdscale on the same
distance object for coordinates to make another scatterplot.

My problem is this: the coordinates from the cmdscale calculation, though
with the same shape, were different in scale and rotation from the scatter
plot yielded by clusplot. clusplot is scaled around [-20, 30], while
cmdscale is scaled between [-1,1]. Also in my case, the two plots are
mirroring of each other. Is there a way to replicate the way that clusplot
makes use of cmdscale? Or just yielding more comparable plots through the
two functions?

I know both clusplot and cmdscale decided the rotation based on princomp.
Then where come these differences? I tried to look at the code through
typing "clusplot" in the console but it was brief and the complex methods
seem to hide somewhere else.

Thank you in advance for your kind help.

Kind regards,

  Junru

[[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] R problem and help

2013-04-09 Thread arun
Hi,
Try this:
source("catalin2.txt")

dat2$year<- as.numeric(row.names(dat2))
 indx<-findInterval(dat2$year,seq(1591,1700,by=10))  #based on the last row in 
the dataset
group<-seq(1590,1700,by=10)
ind<-seq(1,length(group),by=1)
labl1<-paste(group[ind],group[ind+1],sep="-")
labl1<- labl1[-length(labl1)]
dat2$decade<- as.character(labl1[indx])
dat2$decade<- as.numeric(gsub(".*\\-","",dat2$decade))
 lst1<-split(dat2[,-c(31,32)],dat2$decade)
 res<-do.call(rbind,lapply(lst1,function(x) {x1<-x[!is.na(x)]; 
if(length(x1)!=0) c(major=sum(x1>0.5),minor=sum(x1<=0.5)) else NA}))
res
# major minor
#1600    NA    NA
#1610 0 4
#1620    NA    NA
#1630    NA    NA
#1640    NA    NA
#1650    NA    NA
#1660    NA    NA
#1670    NA    NA
#1680 4 6
#1690 0 7
#1700    NA    NA

 dat3<- dat2[,-31]
 dat4<-data.frame(res,decade=rownames(res))
 res1<-merge(dat3,dat4,by="decade")
tail(res1,2)
#    decade 01 02 03 04    05 06 07 08 09-236 10-63T 11 12 13 14 15 16
#99    1690 NA NA NA NA 0.2501569 NA NA NA NA NA NA NA NA NA NA NA
#100   1700 NA NA NA NA    NA NA NA NA NA NA NA NA NA NA NA NA
#    17-234 18 19 20 23 24 25 26 27 HAR133 HAR105 HAR211 HUMH255 HUMH276 major
#99  NA NA NA NA NA NA NA NA NA NA NA NA  NA  NA 0
#100 NA NA NA NA NA NA NA NA NA NA NA NA  NA  NA    NA
#    minor
#99  7
#100    NA
A.K.




 From: catalin roibu 
To: arun  
Sent: Tuesday, April 9, 2013 3:17 PM
Subject: Re: R problem and help
 

Hi Arun,
My initial data frame is like that:
dput(head(gc25,100))
structure(list(`01` = c(NA_real_, NA_real_, NA_real_, NA_real_, 
NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, 
NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, 
NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, 
NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, 
NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, 
NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, 
NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, 
NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, 
NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, 
NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, 
NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, 
NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, 
NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, 
NA_real_, NA_real_, NA_real_, NA_real_, NA_real_), `02` = c(NA_real_, 
NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, 
NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, 
NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, 
NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, 
NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, 
NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, 
NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, 
NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, 
NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, 
NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, 
NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, 
NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, 
NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, 
NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, 
NA_real_), `03` = c(NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, 
NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, 
NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, 
NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, 
NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, 
NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, 
NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, 
NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, 
NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, 
NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, 
NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, 
NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, 
NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, 
NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, 
NA_real_, NA_real_, NA_real_, NA_real_), `04` = c(NA_real_, NA_real_, 
NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, 
NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, 
NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, 
NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA

[R] str on large data.frame is slow on factors with many levels

2013-04-09 Thread Sam Steingold
str() takes 2+ minutes to print
--8<---cut here---start->8---
'data.frame':   9445743 obs. of  25 variables:
 $ share.id: Factor w/ 1641168 levels "387059b61ffef5cf",..: 7 118 118 
209 242 242 254 254 263 291 ...
...
--8<---cut here---end--->8---
pausing for tens of seconds to print each factor variable which have a
lot of levels.
Why?

(R version 2.15.3 (2013-03-01) -- "Security Blanket"
 Platform: x86_64-pc-linux-gnu (64-bit))

-- 
Sam Steingold (http://sds.podval.org/) on Ubuntu 12.10 (quantal) X 11.0.1130
http://www.childpsy.net/ http://pmw.org.il http://palestinefacts.org
http://mideasttruth.com http://americancensorship.org http://camera.org
Garbage In, Gospel Out

__
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] Boxplot Labels OK

2013-04-09 Thread Rui Barradas

Hello,

I'm glad it help. You should cc the list, maybe it will be of use to others.

Rui Barradas

Em 09-04-2013 21:00, Beatriz González Domínguez escreveu:

I have solved it, many thanks!

-Original Message- From: Rui Barradas
Sent: Tuesday, April 09, 2013 7:33 PM
To: Beatriz González Domínguez
Cc: r-help-ow...@r-project.org ; R Help 1 ; R Help 2
Subject: Re: [R] Boxplot Labels OK

Hello,

The answers you had in another thread could lead you to

bp <- boxplot(DATA$ave, data= DATA, main= "Average Size")
idx <- which(DATA$ave %in% bp$out)
text(x= bp$group, y= bp$out, labels= DATA$num[idx], cex = 0.7, pos = 4)


Hope this helps,

Rui Barradas

Em 09-04-2013 17:31, Beatriz González Domínguez escreveu:

Dear all,

I have just sent an enquiry but probably I hadn’t expressed myself
properly.

Could anyone help me with the following?

When I run the code on my data I get a boxplot with outliers
identified by numbers 200 & 201.
However, what I would like is to label these outliers with their
corresponding “DATA$num� values of the data frame.
In this example, the outliers should be labelled as: 211 & 225

Do you have any idea of how I could do this?

Please, if you need any more details just get in touch.

Many thanks in advance!

## R CODE
#DATA
num <- as.numeric(200:225)
ave <- c(0.5, 1, 1.6, 2, 2, 2.3, 2.5, 2.4, 3, 3.2, 3.3, 7.2, 4, 4.8,
3.5, 2.7, 3.1, 2.8, 4.1, 2.0, 2.5, 2.1, 3.4, 2.5, 2.6, 7)
DATA <- data.frame(cbind(num, ave))
rm(num, ave)

#BOXPLOT
x11()
bp <- boxplot(DATA$ave, data= DATA, main= "Average Size")
identify(x= bp$group, y= bp$out, labels= DATA$num, cex = 0.7)

Bea
[[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] Converting matrix to data frame without losing an assigned dimname

2013-04-09 Thread Paul Miller
Hello All,

Would like to be able to convert a matrix to a dataframe without losing an 
assigned dimname.

Here is an example that should illustrate what I'm talking about.

tableData <- state.x77[c(7, 38, 20, 46), c(7, 1, 8)]
names(dimnames(tableData)) <- c("State", "")
tableData

State  Frost Population  Area
  Connecticut139   3100  4862
  Pennsylvania   126  11860 44966
  Maryland   101   4122  9891
  Virginia85   4981 39780

tableData <- as.data.frame(tableData)
tableData

 Frost Population  Area
Connecticut139   3100  4862
Pennsylvania   126  11860 44966
Maryland   101   4122  9891
Virginia85   4981 39780

Notice how "State" gets removed when converting to a dataframe. How can I get a 
dataframe with a separate column called "State" instead of having the state 
become the row.names? I can think of an ugly way to do it but suspect there 
must be something more elegant.

Thanks,

Paul

__
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] quotes in cat() within function

2013-04-09 Thread Duncan Murdoch

On 13-04-09 6:06 AM, Daniel Caro wrote:

Hello all,

Sorry if this question has been answered in the past, but I could not find
an answer.

I am trying to print quotes within a cat output. The arguments are:

file= "Data labels"
directory= "/home/mylaptop/"

The function returns:
cat("The file", file, "is located in directory", directory, sep=" ")

The output R prints is

The file Data labels is located in directory /home/mylaptop/

But I want "Data labels" and "/home/mylaptop/" to be in quotation marks.

I find examples using "\", such as

cat("Open fnd \"test\"")

But in my case "test" is an argument.


See ?dQuote.  (Read it carefully:  some people don't like directional 
quotes, and dQuote might give them to you.)


Duncan Murdoch

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


Re: [R] Mistake in German Error message for friedman.test

2013-04-09 Thread Duncan Murdoch

On 13-04-09 9:35 AM, kais...@med.uni-duesseldorf.de wrote:



There are two misspellings in the german Error message for friedman test:

Fehler in friedman.test.default(cont$score, group = cont$goup, blocks = 
cont$cont) :
   y, Gruppen und blöcke müssen die sekbe Länge haben

The correct spelling would be:

Fehler in friedman.test.default(cont$score, group = cont$goup, blocks = 
cont$cont) :
   y, Gruppen und *Blöcke* müssen die *selbe* Länge haben


Instead of "die selbe", it could be "dieselbe" or "die gleiche".


You probably want to send this message to the German translation team. 
Contact details for translation teams are on


http://developer.r-project.org/TranslationTeams.html

Duncan Murdoch

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


[R] Error when using fitdist function in R

2013-04-09 Thread Paul Bernal
Hello everyone,

I  was trying to do some distribution fitting with a numerical field called
Tolls. The sample size = 999 rows.

Basically I assigned the Toll data to a new variable K by doing:
k<-dtest$Toll

After that, tried to fit a gamma distribution by doing: fitG<-fitdist(k,
"gamma")

Then the following messages showed (oh and I checked for empty rows before
doing this):

Warning in dgamma(c(363328L, 376216L, 367032L, 314826L, 311892L, 313340L,  :
  NaNs produced
Warning in dgamma(c(363328L, 376216L, 367032L, 314826L, 311892L, 313340L,  :
  NaNs produced
Warning in dgamma(c(363328L, 376216L, 367032L, 314826L, 311892L, 313340L,  :
  NaNs produced
Warning in dgamma(c(363328L, 376216L, 367032L, 314826L, 311892L, 313340L,  :
  NaNs produced
Warning in dgamma(c(363328L, 376216L, 367032L, 314826L, 311892L, 313340L,  :
  NaNs produced
Warning in dgamma(c(363328L, 376216L, 367032L, 314826L, 311892L, 313340L,  :
  NaNs produced
Warning in dgamma(c(363328L, 376216L, 367032L, 314826L, 311892L, 313340L,  :
  NaNs produced
Warning in dgamma(c(363328L, 376216L, 367032L, 314826L, 311892L, 313340L,  :
  NaNs produced
Warning in dgamma(c(363328L, 376216L, 367032L, 314826L, 311892L, 313340L,  :
  NaNs produced
Warning in dgamma(c(363328L, 376216L, 367032L, 314826L, 311892L, 313340L,  :
  NaNs produced
Warning in dgamma(c(363328L, 376216L, 367032L, 314826L, 311892L, 313340L,  :
  NaNs produced
Warning in dgamma(c(363328L, 376216L, 367032L, 314826L, 311892L, 313340L,  :
  NaNs produced
Warning in dgamma(c(363328L, 376216L, 367032L, 314826L, 311892L, 313340L,  :
  NaNs produced
Warning in dgamma(c(363328L, 376216L, 367032L, 314826L, 311892L, 313340L,  :
  NaNs produced
Warning in dgamma(c(363328L, 376216L, 367032L, 314826L, 311892L, 313340L,  :
  NaNs produced
Warning in dgamma(c(363328L, 376216L, 367032L, 314826L, 311892L, 313340L,  :
  NaNs produced
[1] "Error in optim(par = vstart, fn = fnobj, fix.arg = fix.arg, obs =
data,  : \n  non-finite finite-difference value [2]\n"
attr(,"class")
[1] "try-error"
attr(,"condition")

Error in fitdist(k, "gamma") :
  the function mle failed to estimate the parameters,
with the error code 100
>

[[alternative HTML version deleted]]

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


Re: [R] Error when using fitdist function in R

2013-04-09 Thread Paul Bernal
>
> Hello everyone,
>


>
> I  was trying to do some distribution fitting with a numerical field
> called Tolls. The sample size = 999 rows.
>
> Basically I assigned the Toll data to a new variable K by doing:
> k<-dtest$Toll
>
> After that, tried to fit a gamma distribution by doing: fitG<-fitdist(k,
> "gamma")
>
> Then the following messages showed (oh and I checked for empty rows before
> doing this):
>
> Warning in dgamma(c(363328L, 376216L, 367032L, 314826L, 311892L, 313340L,
> :
>   NaNs produced
> Warning in dgamma(c(363328L, 376216L, 367032L, 314826L, 311892L, 313340L,
> :
>   NaNs produced
> Warning in dgamma(c(363328L, 376216L, 367032L, 314826L, 311892L, 313340L,
> :
>   NaNs produced
> Warning in dgamma(c(363328L, 376216L, 367032L, 314826L, 311892L, 313340L,
> :
>   NaNs produced
> Warning in dgamma(c(363328L, 376216L, 367032L, 314826L, 311892L, 313340L,
> :
>   NaNs produced
> Warning in dgamma(c(363328L, 376216L, 367032L, 314826L, 311892L, 313340L,
> :
>   NaNs produced
> Warning in dgamma(c(363328L, 376216L, 367032L, 314826L, 311892L, 313340L,
> :
>   NaNs produced
> Warning in dgamma(c(363328L, 376216L, 367032L, 314826L, 311892L, 313340L,
> :
>   NaNs produced
> Warning in dgamma(c(363328L, 376216L, 367032L, 314826L, 311892L, 313340L,
> :
>   NaNs produced
> Warning in dgamma(c(363328L, 376216L, 367032L, 314826L, 311892L, 313340L,
> :
>   NaNs produced
> Warning in dgamma(c(363328L, 376216L, 367032L, 314826L, 311892L, 313340L,
> :
>   NaNs produced
> Warning in dgamma(c(363328L, 376216L, 367032L, 314826L, 311892L, 313340L,
> :
>   NaNs produced
> Warning in dgamma(c(363328L, 376216L, 367032L, 314826L, 311892L, 313340L,
> :
>   NaNs produced
> Warning in dgamma(c(363328L, 376216L, 367032L, 314826L, 311892L, 313340L,
> :
>   NaNs produced
> Warning in dgamma(c(363328L, 376216L, 367032L, 314826L, 311892L, 313340L,
> :
>   NaNs produced
> Warning in dgamma(c(363328L, 376216L, 367032L, 314826L, 311892L, 313340L,
> :
>   NaNs produced
> [1] "Error in optim(par = vstart, fn = fnobj, fix.arg = fix.arg, obs =
> data,  : \n  non-finite finite-difference value [2]\n"
> attr(,"class")
> [1] "try-error"
> attr(,"condition")
>  data, ddistnam = ddistname, hessian = TRUE, method = meth, lower =
> lower, upper = upper, ...): non-finite finite-difference value [2]>
> Error in fitdist(k, "gamma") :
>   the function mle failed to estimate the parameters,
> with the error code 100
> >
>
>

Any idea of why this is happening?

Best regards,

Paul

[[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] Converting matrix to data frame without losing an assigned dimname

2013-04-09 Thread Gabor Grothendieck
On Tue, Apr 9, 2013 at 4:52 PM, Paul Miller  wrote:
> Hello All,
>
> Would like to be able to convert a matrix to a dataframe without losing an 
> assigned dimname.
>
> Here is an example that should illustrate what I'm talking about.
>
> tableData <- state.x77[c(7, 38, 20, 46), c(7, 1, 8)]
> names(dimnames(tableData)) <- c("State", "")
> tableData
>
> State  Frost Population  Area
>   Connecticut139   3100  4862
>   Pennsylvania   126  11860 44966
>   Maryland   101   4122  9891
>   Virginia85   4981 39780
>
> tableData <- as.data.frame(tableData)
> tableData
>
>  Frost Population  Area
> Connecticut139   3100  4862
> Pennsylvania   126  11860 44966
> Maryland   101   4122  9891
> Virginia85   4981 39780
>
> Notice how "State" gets removed when converting to a dataframe. How can I get 
> a dataframe with a separate column called "State" instead of having the state 
> become the row.names? I can think of an ugly way to do it but suspect there 
> must be something more elegant.
>

Try this:

> library(plyr)
> adply(tableData, 1, c)
 State Frost Population  Area
1  Connecticut   139   3100  4862
2 Pennsylvania   126  11860 44966
3 Maryland   101   4122  9891
4 Virginia85   4981 39780

--
Statistics & Software Consulting
GKX Group, GKX Associates Inc.
tel: 1-877-GKX-GROUP
email: ggrothendieck at gmail.com

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


Re: [R] R crash

2013-04-09 Thread Duncan Murdoch

On 13-04-09 2:41 PM, Tasnuva Tabassum wrote:

I have a generalized linear model to solve. I used package "geepack". When
I use the correlation structure "unstructured", I get a messeage that- R
GUI front-end has stopped working. Why this happens? What is the solution?


Presumably geepack has a bug.  You should simplify your example as much 
as you can and send it to the maintainer of that package.


Duncan Murdoch


The r codes are as follows:
a<-read.table("d:/bmt.txt",header=T")
cutoffs<-c(1.75,3.34,5.09,6.93,9.11,11.8,15.3,20.1,23.7,27.3,30.9,34.3,37.6,41.5,46.5,51.1,57,63,73.1,93.68)
a$icr <- REL
library(pseudo)
pseudo <- pseudoci(time=a$TIME,event=a$icr,tmax=cutoffs)

#rearranging data
b <- NULL
  for(it in 1:length(pseudo$time)){
  b <- rbind(b,cbind(a,pseudo = pseudo$pseudo[[1]][,it],
  tpseudo = pseudo$time[it],id=1:nrow(a)))
  }
  b <- b[order(b$id),]


  library(geepack)

fit3 <-  geese(pseudo ~ as.factor(AGE) + as.factor(WEIGHT) +
as.factor(HEIGHT) ,
data =b, id=id, jack = TRUE, scale.fix=TRUE,
mean.link = "logit", corstr="unstructured")

#The results using the AJ variance estimate
cbind(mean = round(fit3$beta,4), SD = round(sqrt(diag(fit3$vbeta.ajs)),4),
Z = round(fit3$beta/sqrt(diag(fit3$vbeta.ajs)),4),
PVal = round(2-2*pnorm(abs(fit3$beta/sqrt(diag(fit3$vbeta.ajs,4))

[[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] Dengrogram Help (Custom Make)

2013-04-09 Thread gunturus
Hi

I am tring to making a dengrogram. I know how to make a normal dengrogram.
But I want to know if there is certain option.

My dengrogram will be clustered using a value called MatchPrint. But now I
want another value called matchscore displayed next to the leaves. The value
matchscore next to the leave is displayed using a colorkey (heatmap) not the
number.

Plz give me suggestions.

thank you,
Santosh 



--
View this message in context: 
http://r.789695.n4.nabble.com/Dengrogram-Help-Custom-Make-tp4663806.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] Converting matrix to data frame without losing an assigned dimname

2013-04-09 Thread Rolf Turner


Interesting.  The problem is that only ***arrays*** are allowed to have
a dimnames attribute, and data frames are not arrays (they are lists).

The only way that I can see to achieve the effect that you want is to
make the row names into the first column of your data frame and wipe
out the row names.  That is probably the "ugly" procedure that you've
already thought of.

You could automate the procedure to some extent:

fixUpRowNames <- function(X,name) {
X <- as.data.frame(X)
X <- cbind(rownames(X),X)
names(X)[1] <- name
rownames(X) <- NULL
X
}

Then do:

tableData <- state.x77[c(7, 38, 20, 46), c(7, 1, 8)]
newTD <- fixUpRowNames(tableData,"State")

And then all is (more or less) in harmony.

Best that I can come up with.

cheers,

Rolf Turner

On 04/10/2013 08:52 AM, Paul Miller wrote:

Hello All,

Would like to be able to convert a matrix to a dataframe without losing an 
assigned dimname.

Here is an example that should illustrate what I'm talking about.

tableData <- state.x77[c(7, 38, 20, 46), c(7, 1, 8)]
names(dimnames(tableData)) <- c("State", "")
tableData

State  Frost Population  Area
   Connecticut139   3100  4862
   Pennsylvania   126  11860 44966
   Maryland   101   4122  9891
   Virginia85   4981 39780

tableData <- as.data.frame(tableData)
tableData

  Frost Population  Area
Connecticut139   3100  4862
Pennsylvania   126  11860 44966
Maryland   101   4122  9891
Virginia85   4981 39780

Notice how "State" gets removed when converting to a dataframe. How can I get a dataframe 
with a separate column called "State" instead of having the state become the row.names? I 
can think of an ugly way to do it but suspect there must be something more elegant.


__
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] count by value

2013-04-09 Thread catalin roibu
Hello all!
I have a big problem now. I want a data frame like this:
dput(head(test,100))
structure(c(NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, "medium",
"medium", "medium", "medium", "medium", "medium", "medium", NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, "medium",
"medium", "major", "major", "major", "major", "medium", NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA

Re: [R] Converting matrix to data frame without losing an assigned dimname

2013-04-09 Thread arun
Hi,

library(plyr)
library(reshape2)
 df2<-mutate(dcast(melt(tableData),State~Var2), 
State=factor(State,levels=rownames(tableData)))
dfNew<-df2[as.numeric(df2$State),c(1,3:4,2)]
dfNew$State<- as.character(dfNew$State)
 dfNew
# State Frost Population  Area
#1  Connecticut   139   3100  4862
#3 Pennsylvania   126  11860 44966
#2 Maryland   101   4122  9891
#4 Virginia    85   4981 39780
A.K.




- Original Message -
From: Paul Miller 
To: r-help@r-project.org
Cc: 
Sent: Tuesday, April 9, 2013 4:52 PM
Subject: [R] Converting matrix to data frame without losing an assigned dimname

Hello All,

Would like to be able to convert a matrix to a dataframe without losing an 
assigned dimname.

Here is an example that should illustrate what I'm talking about.

tableData <- state.x77[c(7, 38, 20, 46), c(7, 1, 8)]
names(dimnames(tableData)) <- c("State", "")
tableData

State          Frost Population  Area
  Connecticut    139       3100  4862
  Pennsylvania   126      11860 44966
  Maryland       101       4122  9891
  Virginia        85       4981 39780

tableData <- as.data.frame(tableData)
tableData

             Frost Population  Area
Connecticut    139       3100  4862
Pennsylvania   126      11860 44966
Maryland       101       4122  9891
Virginia        85       4981 39780

Notice how "State" gets removed when converting to a dataframe. How can I get a 
dataframe with a separate column called "State" instead of having the state 
become the row.names? I can think of an ugly way to do it but suspect there 
must be something more elegant.

Thanks,

Paul

__
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] Dengrogram Help (Custom Make)

2013-04-09 Thread mlell08
Hi,

please give a *small* working example or everyone will have to guess
what could be right.

see text for drawing text and rect(x1,y1,x2,y2,col,...) for drawing
colred rectangles.

Regards, Moritz

On 09.04.2013 23:34, gunturus wrote:
> Hi
> 
> I am tring to making a dengrogram. I know how to make a normal dengrogram.
> But I want to know if there is certain option.
> 
> My dengrogram will be clustered using a value called MatchPrint. But now I
> want another value called matchscore displayed next to the leaves. The value
> matchscore next to the leave is displayed using a colorkey (heatmap) not the
> number.
> 
> Plz give me suggestions.
> 
> thank you,
> Santosh 
> 
> 
> 
> --
> View this message in context: 
> http://r.789695.n4.nabble.com/Dengrogram-Help-Custom-Make-tp4663806.html
> Sent from the R help mailing list archive at Nabble.com.
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

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


Re: [R] [R-SIG-Finance] EM algorithm with R manually implemented?

2013-04-09 Thread R. Michael Weylandt
Moved to R-help because there's no obvious financial content.

Michael

On Sat, Apr 6, 2013 at 10:56 AM, Stat Tistician
 wrote:
> Hi,
> I want to implement the EM algorithm manually, with my own loops and so.
> Afterwards, I want to compare it to the normalmixEM output of mixtools
> package.
>
> Since the notation is very advanced, I used LaTex and attached the two
> screenshots I also attached the data. Alternatively, the data can be found
> here:http://uploadeasy.net/upload/py6j4.rar and the screenshots here:
> http://uploadeasy.net/upload/9i04.PNG
> http://uploadeasy.net/upload/vloku.PNG
>
> I want to fit two gaussian mixtures.
>
> My main question is: Did I implement the EM algorithm correctly? It does
> not work, because I get such odd values especially for sigma, that the
> likelihood of some observations is zero and therefore the log is -Inf.
>
> Where is my mistake?
>
> My code:
>
> # EM algorithm manually
> # dat is the data
>
>
> # initial values
> pi1<-0.5
> pi2<-0.5
> mu1<--0.01
> mu2<-0.01
> sigma1<-0.01
> sigma2<-0.02
> loglik[1]<-0
> loglik[2]<-sum(pi1*(log(pi1)+
> log(dnorm(dat,mu1,sigma1+sum(pi2*(log(pi2)+log(dnorm(dat,mu2,sigma2
>
>
>
> tau1<-0
> tau2<-0
> k<-1
>
> # loop
> while(abs(loglik[k+1]-loglik[k])>= 0.1) {
>
> # E step
>
> tau1<-pi1*dnorm(dat,mean=mu1,sd=sigma1)/(pi1*dnorm(x,mean=mu1,sd=sigma1)+pi2*dnorm(dat,mean=mu2,sd=sigma2))
>
> tau2<-pi2*dnorm(dat,mean=mu2,sd=sigma2)/(pi1*dnorm(x,mean=mu1,sd=sigma1)+pi2*dnorm(dat,mean=mu2,sd=sigma2))
>
> # M step
> pi1<-sum(tau1)/length(dat)
> pi2<-sum(tau2)/length(dat)
>
> mu1<-sum(tau1*x)/sum(tau1)
> mu2<-sum(tau2*x)/sum(tau2)
>
> sigma1<-sum(tau1*(x-mu1)^2)/sum(tau1)
> sigma2<-sum(tau2*(x-mu2)^2)/sum(tau2)
>
>
> loglik[k]<-sum(tau1*(log(pi1)+log(dnorm(x,mu1,sigma1+sum(tau2*(log(pi2)+log(dnorm(x,mu2,sigma2
> k<-k+1
> }
>
>
> # compare
> library(mixtools)
>
> gm<-normalmixEM(x,k=2,lambda=c(0.5,0.5),mu=c(-0.01,0.01),sigma=c(0.01,0.02))
> gm$lambda
> gm$mu
> gm$sigma
>
> gm$loglik
>
>
> Thanks
>
> [[alternative HTML version deleted]]
>
> ___
> r-sig-fina...@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-finance
> -- Subscriber-posting only. If you want to post, subscribe first.
> -- Also note that this is not the r-help list where general R questions 
> should go.

__
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] Problem with ode

2013-04-09 Thread Bingzhang Chen
Hi,

I am trying to run a 1D nutrient-phytoplankton-zooplankton model in R
using the package 'deSolve'.  The code is shown below:

DEPTH = seq(2.5, 147.5, 5)
NPZ = function(t, state, params){
  with(as.list(params), {
 P <- state[1:NB]
 Z <- state[(NB + 1): (2*NB)]
 N <- state[(2*NB + 1): (3*NB)]
 F.I = function(z, hr){
I0 = function(hr){
if (hr <=16){
   450*sin(hr*pi/16)
   } else {
   0
   }
}
 i = which(z == DEPTH)
 I = I0(hr=hr)*0.43*exp(-z*Kw - Kc*(cumsum(delz*P)[i]
- delz*P[i]/2))
 FI = alpha*I/(um^2 + (alpha*I)^2)^.5
  return(FI)
  }
J1 = function(x){
n = 10^3
FI2 <- function(y)F.I(z = x, y)
J1 = sum(sapply(runif(n, 0, 16), FI2))*16/24/n
   return(J1)
}
J = sapply(DEPTH, J1) #the factor of light limitation
   deltaz <- c(rep(5, NB - 1), 2.5)
   P.Flux <- -D*diff(c(P,0))/deltaz
   Z.Flux <- -D*diff(c(Z,0))/deltaz
   N.Flux <- -D*diff(c(N,N0))/deltaz
   dP.dt = P*um*N/(N+Kn)*J - Z*Im*P^2/(P^2+Kp^2) - diff(c(0,P.Flux))/delz
   dZ.dt = Z*(eps*Im*P^2/(P^2+Kp^2) - g*Z) - diff(c(0,Z.Flux))/delz
   dN.dt = -P*um*N/(N+Kn)*J + Z*(1-eps)*Im*P^2/(P^2+Kp^2) + g*Z^2
-  diff(c(0,N.Flux))/delz
   return(list(c(dP.dt, dZ.dt, dN.dt)))
   })
}

params1 = c(um = 1,  #maximal phytoplankton growth rate, d-1
Kn = 0.2,  #nitrogen half-saturation constant uM/L
Kw = 0.04, #light attenuation due to water, unit: m^-1
Kc = 0.03,  #light attenuation by phytoplankton,
#unit: m^2 (mmol N)^-1
alpha = 0.025,
Im = 0.6,  #zooplankton maximal ingestion rate, unit: /d
Kp = 1,#zooplankton half-saturation for
ingestion, unit: mmol N/m^3
eps = .3,  #Growth efficiency of zooplankton
delz = 5,
D = 2.6, #diffusion coefficiency, unit: m^2/d
g = 0.025,   #zooplankton mortality rate, unit: d^-1
(mmol N)^-1
N0 = 14, #Nitrate concentration at 150 m
NB = length(DEPTH))#Number of depth intervals
P.int = c(rep(0.07, 8),.12, .18,rep(0.21,3),rep(0.35,2),
rep(0.42,2),rep(0.07, 8), rep(0.01, 5))
Z.int = P.int/7
N.int = c(rep(0.1, 13), rep(4.55, 5), rep(10,12))
state = c(P.int, Z.int, N.int)
Time = seq(0,100, by = 1)
NPZ.out <- ode.1D(state, Time, NPZ, params1, nspec = 3, names = c("P","Z","N"))

After running for about 7 hours, the result returns:
DLSODA-  At current T (=R1), MXSTEP (=I1) steps
  taken on this call before reaching TOUT
In above message, I =
[1] 5000
In above message, R =
[1] 0.0498949
Warning:
1: In lsoda(y[ii], times, func = bmod, parms = parms, bandup = nspec *  :
  an excessive amount of work (> maxsteps ) was done, but integration
was not successful - increase maxsteps
2: In lsoda(y[ii], times, func = bmod, parms = parms, bandup = nspec *  :
  Returning early. Results are accurate, as far as they go

And the diagnostics(NPZ.out) shows:

lsoda return code


  return code (idid) =  -1
  Excess work done on this call. (Perhaps wrong Jacobian type MF.)


INTEGER values


  1 The return code : -1
  2 The number of steps taken for the problem so far: 5000
  3 The number of function evaluations for the problem so far: 44438
  5 The method order last used (successfully): 1
  6 The order of the method to be attempted on the next step: 1
  7 If return flag =-4,-5: the largest component in error vector 0
  8 The length of the real work array actually required: 1732
  9 The length of the integer work array actually required: 110
 14 The number of Jacobian evaluations and LU decompositions so far: 4834
 15 The method indicator for the last succesful step,
   1=adams (nonstiff), 2= bdf (stiff): 2
 16 The current method indicator to be attempted on the next step,
   1=adams (nonstiff), 2= bdf (stiff): 2


RSTATE values


  1 The step size in t last used (successfully): 2.189586e-06
  2 The step size to be attempted on the next step: 1.039085e-05
  3 The current value of the independent variable which the solver has
reached: 0.0498949
  4 Tolerance scale factor > 1.0 computed when requesting too much accuracy: 0
  5 The value of t at the time of the last method switch, if any: 0.005314453


So I wonder what are the exact problems with this model. Is it just
because of inappropriate parameters? I also wonder how I can speed up
the calculation time in R.

Thanks,
-- 
Bingzhang Chen
Ph. D.,
State Key Lab of Marine Environmental Science,
College of Oceanography and Environmental Science,
Xiamen University,
Xiamen, Fujian 361005
P. R. China

_

[R] problem with the image command

2013-04-09 Thread cassie jones
Hello R-users,

I am trying to do an image plot where I have been given latitudes,
longitudes and the values at the corresponding locations. A sample of the
data is given as follows:

   values=c(0,1,0,0,0,0,2,2,0,0)
lat=c(29.6660,29.6756,29.3492,29.2654,29.2827,29.4070,35.3510,35.6590,35.7587,38.2794)
long=c(-95.8121,-95.6565,-95.5771,-95.4400,-95.4356,-95.0294,-81.7940,-81.4850,-81.3777,-86.)


I used the following command to generate the image plot along with an U.S.
map:

library(maps)
image(values,x=sort(long),y=sort(lat))
map("state",add=T)

But every time I run the code I get the following error:

Error in image.default(values,x=sort(long),y=sort(lat),

increasing 'x' and 'y' values expected

Even though I sort the latitude and longitude in increasing order, I am
getting this error. Any help is greatly appreciated.

Thanks in advance,

Cassie.

[[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] problem with the image command

2013-04-09 Thread Pascal Oettli

Hi,

Did you carefully read the help for "image" ?

## Default S3 method:
image(x, y, z, zlim, xlim, ylim, col = heat.colors(12),
  add = FALSE, xaxs = "i", yaxs = "i", xlab, ylab,
  breaks, oldstyle = FALSE, useRaster, ...)

Regards,
Pascal


On 04/10/2013 10:07 AM, cassie jones wrote:

Hello R-users,

I am trying to do an image plot where I have been given latitudes,
longitudes and the values at the corresponding locations. A sample of the
data is given as follows:

values=c(0,1,0,0,0,0,2,2,0,0)
lat=c(29.6660,29.6756,29.3492,29.2654,29.2827,29.4070,35.3510,35.6590,35.7587,38.2794)
long=c(-95.8121,-95.6565,-95.5771,-95.4400,-95.4356,-95.0294,-81.7940,-81.4850,-81.3777,-86.)


I used the following command to generate the image plot along with an U.S.
map:

library(maps)
image(values,x=sort(long),y=sort(lat))
map("state",add=T)

But every time I run the code I get the following error:

Error in image.default(values,x=sort(long),y=sort(lat),

increasing 'x' and 'y' values expected

Even though I sort the latitude and longitude in increasing order, I am
getting this error. Any help is greatly appreciated.

Thanks in advance,

Cassie.

[[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] Plot two separate curves in R Graphics and R Lattice package

2013-04-09 Thread jpm miao
Hi,

   How can I plot two curves with distinct x and y vectors? I would like to
join one of them by regular lines and plot the other just by points (no
lines). Can it be done in  regular R graphic tools, say "plot" function?
Can it be done in Lattice package, say "xyplot" function?

   Thanks,

Miao

My data look like this: two curves with different vector size

x y
 3973730 0.00322  2391576 0.003487  2840944 0.005145  2040943 0.006359
1982715 0.006253  1618162 0.00544  820082.3 0.004213  1658597 0.004883
1762794 0.006216  93439.5 0.004255  218481.3 0.006924  2332477 0.004862
725835.5 0.00089  811575.3 0.012962  292223 0.002614  153862.3 0.007524
1272367 0.006899  734199 0.00988  421404.5 0.005048  189047.5 0.004821
529102 0.009637  56833 0.006171  125856.3 0.00839  598893.8 0.006622  258240
0.00613  159086.3 0.008819  122863 0.010093  404699.5 0.008148  453514.5
0.008407  545028 0.006096  1233366 0.006111  1192758 0.008162  147563.3
0.00838  247293 0.010283  1074838 0.007413  459227.5 0.00862  202332
0.009061  377401.3 0.006923  1876753 0.010226
and
x   y
 50118.72 0.012117  51286.14 0.012054  52480.75 0.011991  53703.18 0.011928
54954.09 0.011865  56234.13 0.011803  57543.99 0.011742  58884.37 0.01168
60255.96 0.011619  61659.5 0.011559  63095.73 0.011498  64565.42 0.011438
66069.34 0.011379  67608.3 0.011319  69183.1 0.01126

[[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] problem with the image command

2013-04-09 Thread cassie jones
Yes, I did. But I get the following error with the command
image(x=long,y=lat,z=values)

"Error in image.default(x=long,y=lat,z=values):
 error in evaluating the argument 'x' in selecting a method for function
'image': Error in long: recursive indexing failed at level 2"


Thanks,
Cassie

On Tue, Apr 9, 2013 at 8:16 PM, Pascal Oettli  wrote:

> Hi,
>
> Did you carefully read the help for "image" ?
>
> ## Default S3 method:
> image(x, y, z, zlim, xlim, ylim, col = heat.colors(12),
>   add = FALSE, xaxs = "i", yaxs = "i", xlab, ylab,
>   breaks, oldstyle = FALSE, useRaster, ...)
>
> Regards,
> Pascal
>
>
>
> On 04/10/2013 10:07 AM, cassie jones wrote:
>
>> Hello R-users,
>>
>> I am trying to do an image plot where I have been given latitudes,
>> longitudes and the values at the corresponding locations. A sample of the
>> data is given as follows:
>>
>> values=c(0,1,0,0,0,0,2,2,0,0)
>> lat=c(29.6660,29.6756,29.3492,**29.2654,29.2827,29.4070,35.**
>> 3510,35.6590,35.7587,38.2794)
>> long=c(-95.8121,-95.6565,-95.**5771,-95.4400,-95.4356,-95.**
>> 0294,-81.7940,-81.4850,-81.**3777,-86.)
>>
>>
>> I used the following command to generate the image plot along with an U.S.
>> map:
>>
>> library(maps)
>> image(values,x=sort(long),y=**sort(lat))
>> map("state",add=T)
>>
>> But every time I run the code I get the following error:
>>
>> Error in image.default(values,x=sort(**long),y=sort(lat),
>>
>> increasing 'x' and 'y' values expected
>>
>> Even though I sort the latitude and longitude in increasing order, I am
>> getting this error. Any help is greatly appreciated.
>>
>> Thanks in advance,
>>
>> Cassie.
>>
>> [[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.
>>
>>

[[alternative HTML version deleted]]

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


Re: [R] Plot two separate curves in R Graphics and R Lattice package

2013-04-09 Thread Janesh Devkota
Hi,

This should be fairly easy by using base R graphics.

Lets suppose your first data is represented by (x1,y1) and second data is
represented by (x2,y2)

You can use the following command.
plot(x1,y1,type="l")
points(x2,y2)

Hope it helps.


On Tue, Apr 9, 2013 at 8:24 PM, jpm miao  wrote:

> Hi,
>
>How can I plot two curves with distinct x and y vectors? I would like to
> join one of them by regular lines and plot the other just by points (no
> lines). Can it be done in  regular R graphic tools, say "plot" function?
> Can it be done in Lattice package, say "xyplot" function?
>
>Thanks,
>
> Miao
>
> My data look like this: two curves with different vector size
>
> x y
>  3973730 0.00322  2391576 0.003487  2840944 0.005145  2040943 0.006359
> 1982715 0.006253  1618162 0.00544  820082.3 0.004213  1658597 0.004883
> 1762794 0.006216  93439.5 0.004255  218481.3 0.006924  2332477 0.004862
> 725835.5 0.00089  811575.3 0.012962  292223 0.002614  153862.3 0.007524
> 1272367 0.006899  734199 0.00988  421404.5 0.005048  189047.5 0.004821
> 529102 0.009637  56833 0.006171  125856.3 0.00839  598893.8 0.006622
>  258240
> 0.00613  159086.3 0.008819  122863 0.010093  404699.5 0.008148  453514.5
> 0.008407  545028 0.006096  1233366 0.006111  1192758 0.008162  147563.3
> 0.00838  247293 0.010283  1074838 0.007413  459227.5 0.00862  202332
> 0.009061  377401.3 0.006923  1876753 0.010226
> and
> x   y
>  50118.72 0.012117  51286.14 0.012054  52480.75 0.011991  53703.18 0.011928
> 54954.09 0.011865  56234.13 0.011803  57543.99 0.011742  58884.37 0.01168
> 60255.96 0.011619  61659.5 0.011559  63095.73 0.011498  64565.42 0.011438
> 66069.34 0.011379  67608.3 0.011319  69183.1 0.01126
>
> [[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.
>

[[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] problem with the image command

2013-04-09 Thread Pascal Oettli

Hello,

In the case:

image(x=long,y=lat,z=values)),

"long" is not in (strictly) ascending order, according to the sample you 
provided:


plot(long)

Regards,
Pascal


On 04/10/2013 10:28 AM, cassie jones wrote:

Yes, I did. But I get the following error with the command
image(x=long,y=lat,z=values)

"Error in image.default(x=long,y=lat,z=values):
  error in evaluating the argument 'x' in selecting a method for
function 'image': Error in long: recursive indexing failed at level 2"


Thanks,
Cassie

On Tue, Apr 9, 2013 at 8:16 PM, Pascal Oettli mailto:kri...@ymail.com>> wrote:

Hi,

Did you carefully read the help for "image" ?

## Default S3 method:
image(x, y, z, zlim, xlim, ylim, col = heat.colors(12),
   add = FALSE, xaxs = "i", yaxs = "i", xlab, ylab,
   breaks, oldstyle = FALSE, useRaster, ...)

Regards,
Pascal



On 04/10/2013 10:07 AM, cassie jones wrote:

Hello R-users,

I am trying to do an image plot where I have been given latitudes,
longitudes and the values at the corresponding locations. A
sample of the
data is given as follows:

 values=c(0,1,0,0,0,0,2,2,0,0)

lat=c(29.6660,29.6756,29.3492,__29.2654,29.2827,29.4070,35.__3510,35.6590,35.7587,38.2794)

long=c(-95.8121,-95.6565,-95.__5771,-95.4400,-95.4356,-95.__0294,-81.7940,-81.4850,-81.__3777,-86.)


I used the following command to generate the image plot along
with an U.S.
map:

library(maps)
image(values,x=sort(long),y=__sort(lat))
map("state",add=T)

But every time I run the code I get the following error:

Error in image.default(values,x=sort(__long),y=sort(lat),

increasing 'x' and 'y' values expected

Even though I sort the latitude and longitude in increasing
order, I am
getting this error. Any help is greatly appreciated.

Thanks in advance,

Cassie.

 [[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] Behaviors of diag() with character vector in R 3.0.0

2013-04-09 Thread Mike Cheung
Thanks, A.K.

I managed to create diagonal matrices for character vectors. Since this new
behavior broke a package that I have written, I would like to make sure
that this new behavior was not introduced by mistakes. If this new behavior
is final, I will modify my code to fit it.

Mike


On Tue, Apr 9, 2013 at 10:14 PM, arun  wrote:

> Hi,
> You could try this:
> v <- c("a", "b")
> mat1<-diag(length(v))
>  diag(mat1)<- v
>  mat1
> # [,1] [,2]
> #[1,] "a"  "0"
> #[2,] "0"  "b"
>
>
>  v1<- letters[1:5]
> mat2<- diag(length(v1))
>  diag(mat2)<- v1
> mat2
> # [,1] [,2] [,3] [,4] [,5]
> #[1,] "a"  "0"  "0"  "0"  "0"
> #[2,] "0"  "b"  "0"  "0"  "0"
> #[3,] "0"  "0"  "c"  "0"  "0"
> #[4,] "0"  "0"  "0"  "d"  "0"
> #[5,] "0"  "0"  "0"  "0"  "e"
> A.K.
>
>
>
>
> - Original Message -
> From: Mike Cheung 
> To: r-help 
> Cc:
> Sent: Tuesday, April 9, 2013 3:15 AM
> Subject: [R] Behaviors of diag() with character vector in R 3.0.0
>
> Dear all,
>
> According to CHANGES IN R 3.0.0:
> o diag() as used to generate a diagonal matrix has been re-written
>   in C for speed and less memory usage.  It now forces the result
>   to be numeric in the case diag(x) since it is said to have 'zero
>   off-diagonal entries'.
>
> diag(x) does not work for character vector in R 3.0.0 any more. For
> example,
> v <- c("a", "b")
>
> ## R 2.15.3
> diag(v)
>  [,1] [,2]
> [1,] "a"  "0"
> [2,] "0"  "b"
>
> ## R 3.0.0
> diag(v)
>  [,1] [,2]
> [1,]   NA0
> [2,]0   NA
> Warning message:
> In diag(v) : NAs introduced by coercion
>
> Regarding the character matrix, it still works. For example,
> m <- matrix(c("a", "b", "c", "d"), nrow=2)
> diag(m)
> ## Both R 2.15.3 and 3.0.0
> [1] "a" "d"
>
> n <- matrix(0, ncol=2, nrow=2)
> diag(n) <- v
> n
> ## Both R 2.15.3 and 3.0.0
>  [,1] [,2]
> [1,] "a"  "0"
> [2,] "0"  "b"
>
> I understand that the above behavior follows exactly what the manual says.
> It appears to me that the version in 2.15.3 is more general as it works for
> both numeric and character vectors and matrices, whereas the version in
> 3.0.0 works for character matrices but not character vectors.
>
> Would it be possible to retain the behaviors of diag() for character
> vectors? Thanks.
>
> Mike
> --
> -
> Mike W.L. Cheung   Phone: (65) 6516-3702
> Department of Psychology   Fax:   (65) 6773-1843
> National University of Singapore
> http://courses.nus.edu.sg/course/psycwlm/internet/
> -
>
> [[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.
>
>


-- 
-
 Mike W.L. Cheung   Phone: (65) 6516-3702
 Department of Psychology   Fax:   (65) 6773-1843
 National University of Singapore
 http://courses.nus.edu.sg/course/psycwlm/internet/
-

[[alternative HTML version deleted]]

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


Re: [R] Plot two separate curves in R Graphics and R Lattice package

2013-04-09 Thread jpm miao
Thank you very much.

Could it be done in Lattice package?

Thanks,

Miao


2013/4/10 Janesh Devkota 

> Hi,
>
> This should be fairly easy by using base R graphics.
>
> Lets suppose your first data is represented by (x1,y1) and second data is
> represented by (x2,y2)
>
> You can use the following command.
> plot(x1,y1,type="l")
> points(x2,y2)
>
> Hope it helps.
>
>
> On Tue, Apr 9, 2013 at 8:24 PM, jpm miao  wrote:
>
>> Hi,
>>
>>How can I plot two curves with distinct x and y vectors? I would like
>> to
>> join one of them by regular lines and plot the other just by points (no
>> lines). Can it be done in  regular R graphic tools, say "plot" function?
>> Can it be done in Lattice package, say "xyplot" function?
>>
>>Thanks,
>>
>> Miao
>>
>> My data look like this: two curves with different vector size
>>
>> x y
>>  3973730 0.00322  2391576 0.003487  2840944 0.005145  2040943 0.006359
>> 1982715 0.006253  1618162 0.00544  820082.3 0.004213  1658597 0.004883
>> 1762794 0.006216  93439.5 0.004255  218481.3 0.006924  2332477 0.004862
>> 725835.5 0.00089  811575.3 0.012962  292223 0.002614  153862.3 0.007524
>> 1272367 0.006899  734199 0.00988  421404.5 0.005048  189047.5 0.004821
>> 529102 0.009637  56833 0.006171  125856.3 0.00839  598893.8 0.006622
>>  258240
>> 0.00613  159086.3 0.008819  122863 0.010093  404699.5 0.008148  453514.5
>> 0.008407  545028 0.006096  1233366 0.006111  1192758 0.008162  147563.3
>> 0.00838  247293 0.010283  1074838 0.007413  459227.5 0.00862  202332
>> 0.009061  377401.3 0.006923  1876753 0.010226
>> and
>> x   y
>>  50118.72 0.012117  51286.14 0.012054  52480.75 0.011991  53703.18
>> 0.011928
>> 54954.09 0.011865  56234.13 0.011803  57543.99 0.011742  58884.37 0.01168
>> 60255.96 0.011619  61659.5 0.011559  63095.73 0.011498  64565.42 0.011438
>> 66069.34 0.011379  67608.3 0.011319  69183.1 0.01126
>>
>> [[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.
>>
>
>

[[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] Error while displaying help page of a function existing inside two different loaded libraries

2013-04-09 Thread Pascal Oettli

Dear R users,

I recently upgraded R from version 2.15.3 to version 3.0.0 (after 
removing version 2.15.3 and cleaning installation directory) using the 
package provided by openSUSE (R-base).


I am now running into an issue when two loaded packages share the same 
name for a function.


For example, "image" (packages graphics and gstat) and "dotchart" 
(packaged graphics and survey) functions.


In R-2.15.3, a choice was displayed, in order to choose the function 
within the desired package.


In R-3.0.0, an error appears inside the web browser (Firefox):

?image
Error in httpd("/library/NULL/help/image", NULL, NULL, c(48, 6f, 73, 74, 
 : replacement has length zero


?dotchart
Error in httpd("/library/NULL/help/dotchart", NULL, NULL, c(48, 6f, 73, 
 : replacement has length zero



Did anybody else already encounter this issue? Or is it a problem with 
my own installation?



Herewith is the result of "sessionInfo"

> sessionInfo()
R version 3.0.0 (2013-04-03)
Platform: x86_64-suse-linux-gnu (64-bit)

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

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

other attached packages:
[1] survey_3.29-4 gstat_1.0-16  sp_1.0-8

loaded via a namespace (and not attached):
[1] grid_3.0.0   intervals_0.14.0 lattice_0.20-15  spacetime_1.0-4
[5] tools_3.0.0  xts_0.9-3zoo_1.7-9


Best Regards,
Pascal Oettli

__
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] Not enough predicted values from pscl package?

2013-04-09 Thread Noah Silverman
Hi, 

I'm used the pscl library to fit a zero inflated poisson model.

My data has 25,327 rows (no missing values.)

zeroinfl(y ~ x)  works fine.  I get coefficients, etc.

Now, I want to see the fitted values and do some comparisons to the truth.  So 
I used:

predict(mod, type="count)

The resulting vector only contains 25,213 values.  So, somehow, the predict 
function skipped predictions for several of my data points.  The problem is I 
don't know why and I don't know which values were skipped.  


Any suggestions?


--
Noah Silverman, M.S.
UCLA Department of Statistics
8117 Math Sciences Building
Los Angeles, CA 90095

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


Re: [R] Plot two separate curves in R Graphics and R Lattice package

2013-04-09 Thread David Winsemius


On Apr 9, 2013, at 8:21 PM, jpm miao wrote:


Thank you very much.

Could it be done in Lattice package?




Your example was not presented in a form that lent itself to easy  
editing. Please learn to use dput to present data structures:


xyplot( 4:6 ~ 1:3,
   panel=function(x,y) {
panel.xyplot(x,y, type="l")
panel.points(x=c(1.1, 2.1), y=c(4.1, 5.1),  
col="red") } )


--
David.


Thanks,

Miao


2013/4/10 Janesh Devkota 


Hi,

This should be fairly easy by using base R graphics.

Lets suppose your first data is represented by (x1,y1) and second  
data is

represented by (x2,y2)

You can use the following command.
plot(x1,y1,type="l")
points(x2,y2)

Hope it helps.


On Tue, Apr 9, 2013 at 8:24 PM, jpm miao  wrote:


Hi,

  How can I plot two curves with distinct x and y vectors? I would  
like

to
join one of them by regular lines and plot the other just by  
points (no
lines). Can it be done in  regular R graphic tools, say "plot"  
function?

Can it be done in Lattice package, say "xyplot" function?

  Thanks,

Miao

My data look like this: two curves with different vector size

x y
3973730 0.00322  2391576 0.003487  2840944 0.005145  2040943  
0.006359
1982715 0.006253  1618162 0.00544  820082.3 0.004213  1658597  
0.004883
1762794 0.006216  93439.5 0.004255  218481.3 0.006924  2332477  
0.004862
725835.5 0.00089  811575.3 0.012962  292223 0.002614  153862.3  
0.007524
1272367 0.006899  734199 0.00988  421404.5 0.005048  189047.5  
0.004821

529102 0.009637  56833 0.006171  125856.3 0.00839  598893.8 0.006622
258240
0.00613  159086.3 0.008819  122863 0.010093  404699.5 0.008148   
453514.5
0.008407  545028 0.006096  1233366 0.006111  1192758 0.008162   
147563.3

0.00838  247293 0.010283  1074838 0.007413  459227.5 0.00862  202332
0.009061  377401.3 0.006923  1876753 0.010226
and
x   y
50118.72 0.012117  51286.14 0.012054  52480.75 0.011991  53703.18
0.011928
54954.09 0.011865  56234.13 0.011803  57543.99 0.011742  58884.37  
0.01168
60255.96 0.011619  61659.5 0.011559  63095.73 0.011498  64565.42  
0.011438

66069.34 0.011379  67608.3 0.011319  69183.1 0.01126

   [[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.






[[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.


David Winsemius, MD
Alameda, CA, USA

__
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.