[R] Leaflet maps. Nudging co-incident markers

2018-01-19 Thread Gavin Rudge (Institute of Applied Health Research)
I have a dataset showing points, with a category for each point and its 
location.

I simply want to display my points, in a way that users can toggle the points 
on and off by category.

Where I have two objects in the same category I'd like to display them nudged 
to appear as two distinct, but very close points.
I have made reproduceable example (the places are not real), which is loosely 
based on a tutorial I found recently 
(https://allthisblog.wordpress.com/2016/10/12/r-311-with-leaflet-tutorial/)

I have three categories of things (cafes, libraries and galleries), at three 
locations but have four objects in my set. This is because on of my locations 
has two functions - there is a cafe at a gallery (North St Gallery and the 
Gallery Cafe on the same site)

If I make a selection that includes galleries and cafes there are just two 
points. I would like to nudge the point for the North St Galley and the Gallery 
Cafe so they appear as two (very close) points on the map and display the name 
when clicked on.

Also if anyone has any suggestions for generally tidying up the code I'd be 
grateful as my real version is much more complex with many more points and 
marker categories.   I believe there are Java libraries out there for managing 
markers and how they behave, but I'm hoping this can be done in the Leaflet R 
library somehow. 

The only solution I could think of was to interrogate the entire dataframe, 
identify points that were had the same co-ords and move them diagonally apart 
by adding and subtracting a fixed amount of longitude and latitude from the 
co-ordinates. 

Thanks in advance.

GavinR

Here is the code:

library(leaflet)

#make data frame of points

idno=c(1,2,3,4)
x=c(-1.9116, -1.9116,-1.9237,-1.91848)
y=c(52.4898,52.4898,52.5015,52.4851)
cat=c('Gallery','Cafe','Library','Cafe')
n=c('North St Gallery','Gallery cafe', 'South St Library', 'Coffee 2 go')
d<-data.frame(idno,x,y,cat,n)

#get a map and zoom into approx area of interest

m=leaflet()%>% setView(lng = -1.935, lat=52.485, zoom=12)
m=addTiles(m) 
m

#create groups of objects

c= subset(d,cat=="Cafe")
l= subset(d, cat=="Library")
g= subset(d, cat=="Gallery")  

#add markers
  
m=addCircleMarkers(m,
 lng = c$x,
 lat = c$y,
 popup = c$n,
 radius = 5,
 stroke =FALSE,
 fillOpacity = 0.75,
 group = "1 - Cafes")
 
m=addCircleMarkers(m,
   lng = g$x,
   lat = g$y,
   popup = g$n,
   radius = 5,
   stroke =FALSE,
   fillOpacity = 0.75,
   group = "2 - Galleries")

m=addCircleMarkers(m,
   lng = l$x,
   lat = l$y,
   popup = l$n,
   radius = 5,
   stroke =FALSE,
   fillOpacity = 0.75,
   group = "3 - libraries")

m = addLayersControl(m, overlayGroups = c("1 - Cafes","2 - Galleries","3 - 
libraries"))

m

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


[R] Compiling R2.15.1 on ubuntu with x86-64 architecture and shared library

2012-09-17 Thread Conklin, Mike (GfK Custom Research NA)
I am sure I am providing insufficient information, please ask for more.

I installed R 2.14.2 on my Ubuntu laptop with and AMD64 processor and also 
installed RStudio  and everything worked fine.

Now, I tried to build R 2.15.1 from source and installed it using defaults. 
RStudio now complained that R was not built as a shared library.

Went back and uninstalled, and configured with -enable-R-shlib

Now make fails at:
/usr/bin/ld: CConverters.o: relocation R_X86_64_325 against '.rodata' can not 
be used when making a shared object; recompile with -fPIC

Being new to Linux, I have no idea how to recompile with -fPIC

Any help would be appreciated.

Mike

W. Michael Conklin
Executive Vice President | GfK Marketing Science | Consumer Experiences North 
America
GfK Custom Research, LLC | 8401 Golden Valley Road | Minneapolis, MN, 55427
T +1 763 417 4545 | M +1 612 567 8287
www.gfk.comhttp://www.gfk.com/


[[alternative HTML version deleted]]

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


Re: [R] Cannot write a dataframe to xls or csv Windows 7

2012-09-14 Thread research email
Thank you so much,
Yes I need to look up how to make a reproducible example,
William I will try your advice, I believe this will be my salvation here, once 
I get my computer.

Pancho

On Sep 13, 2012, at 23:59, William Dunlap wdun...@tibco.com wrote:

 
 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On 
 Behalf
 Of R. Michael Weylandt
 Sent: Thursday, September 13, 2012 2:52 PM
 To: pmulonge
 Cc: r-help@r-project.org
 Subject: Re: [R] Cannot write a dataframe to xls or csv Windows 7
 
 On Thu, Sep 13, 2012 at 4:05 PM, pmulonge
 resea...@namibia.pharmaccess.org wrote:
 Hello,
 I have  a similar issue , but in my case I am using Windows 7
 i try the following command to write a dataframe to xls using the
 xlsReadWrite package or the write.csv function
 write.xls(DATA,'Reg_IDcleaned.xls')
 or I will write.csv replacin the suffix with .csv
 I get absolutely no error message and the setwd appears at top of my code
 with absolute path
 
 Immediately after the write.xls(..., file=something) run
   normalizePath(something, mustWork=TRUE)
 and it should give a full path to the file called something.
 
 Bill Dunlap
 Spotfire, TIBCO Software
 wdunlap tibco.com
 
 However when I look in the relevant folder ,the xls or cdv outfile is
 nowhere to be found.
 Is there a gremlin in the computer or what?
 
 It seems unlikely, but I suppose it can't be ruled out
 
 Before, this write.xls was working fine and now it stopped, i used the
 write.csv to test if it was an error in the package.
 So since write.csv also fails to produce the oufile in .csv in the relevant
 folder, I am at my witts end
 
 
 Firstly, please do quote context: most of us don't read nabble and I
 have no idea what similar problem you're having. (Well, actually, I
 clicked the link and I do, but I'm not letting on) Secondly, can you
 whip up a reproducible example?
 
 http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-
 example
 
 I see no reason why
 
 setwd(~) # Replace with appropriate Windows-ism
 write.csv(data.frame(1:5, letters[1:5]))
 
 wouldn't work if you have the right permissions, but perhaps you are
 doing something funny.
 
 Cheers,
 Michael
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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] Tendonitis and R users

2012-09-04 Thread research email

Hello
This request asks something beyond the technicalities of the R language, I 
would like to ask you wonderful people if you have ever suffered as programmers 
( or de facto programmers like myself though I am a 'research assistant') from 
tendonitis and how you coped with it, i have golfer's elbow on both sides. Any 
resources?

Pancho Mulongeni
Namibia
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Exporting data to spss

2012-08-22 Thread research email
I have a dataframe of 80+ columns and over 700 rows. I use 
write.foreigin(data,C:/filename.dat,codefile.sps) and it does write out the 
.dat file and the code file.
Problem is that when I open the codefile in SPSS 20, I can an error message 
saying there are too many variables and something about the formatting (this is 
not an SPSS list so the details of the error are not germane).
Question: is there another way of reading data into SPSS without having to 
first create a text file, excel file that is then opened in SPSS manually.
Is there any other function apart from write.foreign?
Thank you


[[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] analysing a three level reponse

2011-06-22 Thread Matt Ellis (Research)
Hello,
I am struggling to figure out how to analyse a dataset I have inherited
(please note this was conducted some time ago, so the data is as it is,
and I know it isn't perfect!).
 
A brief description of the experiment follows:
Pots of grass were grown in 1l pots of standad potting medium for 1
month with a regular light and watering regime. At this point they were
randomly given 1l of one of 4 different pesticides at one of 4 different
concentrations (100%, 75%, 50% or 25% in water). There were 20 pots of
grass for each pesticide/concentration giving 320 pots. There were no
control (untreated) pots. The response was measured after 1 week and
recorded as either:
B1 - grass dead
B2 - grass affected but not dead
B3 - no visible effect
 
I could analyse this as lethal effect vs non-lethal effect (B1 vs B2+B3)
or some effect vs no effect (B1+B2 vs B3) binomial model, but I can't
see how to do it with three levels.
 
Any pointing in the right direction greatly appreciated!
Thanks
Matt

--
Disclaimer: 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 have received this email in error please notify me at 
matt.el...@basc.org.uk then delete it. BASC may monitor email traffic.  By 
replying to this e-mail you consent to BASC monitoring the content of any email 
you send or receive from BASC. Any views expressed in this message are those of 
the individual sender, except where the sender specifies with authority, states 
them to be the views of the British Association for Shooting and Conservation. 
BASC can confirm that this email message and any attachments have been scanned 
for the presence of computer viruses but recommends that you make your own 
virus checks. Registered Industrial and Provident Society No.: 28488R. 
Registered Office: Marford Mill, Rossett, Wrexham, LL12 0HL. 
--



[[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] Odp: Help me with prediction in linear model

2010-07-24 Thread Research student

Thanks Murphy and pikal,

I need another help,for fitting first fourier transformation ,i used
following thing .Please advise on this


beer_monthl has 400+ records

EXample:
 head(beer_monthly)
  beer
1 93.2
2 96.0
3 95.2
4 77.1
5 70.9
6 64.8




time-seq(1956,1995.2,length=length(beer_monthly))
sin.t-sin(2*pi*time)
cos.t-cos(2*pi*time)
beer_fit_fourier=lm(beer_monthly[,1]~poly(time,2)+sin.t+cos.t) #this is not
working
beer_fit_fourier=lm(beer_monthly[,1]~time+time2+sin.t+cos.t) #it is working


#prediction is not workinng

tpred_four - data.frame(time = seq(1995, 1998, length = 20))
predict(beer_fit_fourier, newdata = tpred_four)

Is there any way to fit first fourier  frequency ,

Please assist.

Thanks in advance





-- 
View this message in context: 
http://r.789695.n4.nabble.com/Help-me-with-prediction-in-linear-model-tp2297313p2300991.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] help me with holt-winter model

2010-07-22 Thread Research student



Please help me with this i need to submit my thesis .

Thanks In advance

-- 
View this message in context: 
http://r.789695.n4.nabble.com/help-me-with-holt-winter-model-tp2295552p2298464.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] Please advise acf and pacf in order to determine order of Arima

2010-07-22 Thread Research student

I have data as below.Please let me know how the ACF and Pacf used to
determine the order od arima model.
Is  there any rules need to be followed to determine order.Please advise



 turkey.price.ts
  Jan  Feb  Mar  Apr  May  Jun  Jul  Aug  Sep  Oct  Nov  Dec
2001 1.58 1.75 1.63 1.45 1.56 2.07 1.81 1.74 1.54 1.45 0.57 1.15
2002 1.50 1.66 1.34 1.67 1.81 1.60 1.70 1.87 1.47 1.59 0.74 0.82
2003 1.43 1.77 1.47 1.38 1.66 1.66 1.61 1.74 1.62 1.39 0.70 1.07
2004 1.48 1.48 1.50 1.27 1.56 1.61 1.55 1.69 1.49 1.32 0.53 1.03
2005 1.62 1.63 1.40 1.73 1.73 1.80 1.92 1.77 1.71 1.53 0.67 1.09
2006 1.71 1.90 1.68 1.46 1.86 1.85 1.88 1.86 1.62 1.45 0.67 1.18
2007 1.68 1.74 1.70 1.49 1.81 1.96 1.97 1.91 1.89 1.65 0.70 1.17
2008 1.76 1.78 1.53 1.90
 





 acf(turkey.price.ts,plot=FALSE)

Autocorrelations of series ‘turkey.price.ts’, by lag

0. 0.0833 0.1667 0.2500 0. 0.4167 0.5000 0.5833 0.6667 0.7500 0.8333 
 1.000  0.465 -0.019 -0.165 -0.145 -0.219 -0.215 -0.122 -0.136 -0.200 -0.016 
0.9167 1. 1.0833 1.1667 1.2500 1. 1.4167 1.5000 1.5833 
 0.368  0.723  0.403 -0.013 -0.187 -0.141 -0.180 -0.226 -0.130 
 pacf(turkey.price.ts,plot=FALSE)

Partial autocorrelations of series ‘turkey.price.ts’, by lag

0.0833 0.1667 0.2500 0. 0.4167 0.5000 0.5833 0.6667 0.7500 0.8333 0.9167 
 0.465 -0.300 -0.020 -0.060 -0.218 -0.054 -0.061 -0.211 -0.180  0.098  0.299 
1. 1.0833 1.1667 1.2500 1. 1.4167 1.5000 1.5833 
 0.571 -0.122 -0.077 -0.075  0.119  0.064 -0.149 -0.061 



Thanks in advance
-- 
View this message in context: 
http://r.789695.n4.nabble.com/Please-advise-acf-and-pacf-in-order-to-determine-order-of-Arima-tp2298474p2298474.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] KALMAN

2010-07-21 Thread Research

Hello,

I am looking for some very simple, step by step, hands on 
application/examples/notes etc. on setting up a multivariate time series 
Kalman filter model in R.


Any help/pointers much appreciated.

Best regards,
Costas

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] List of zoo multivariate series

2010-06-30 Thread Research

Hi,

I have a list which is basically a database of zoo multivariate objects:

 x.Date - as.Date(2003-02-01) + c(1:100) - 1
 x - zoo(rnorm(100), x.Date)
 z - zoo(rnorm(100), x.Date)
 y - zoo(rnorm(100), x.Date)
 k - zoo(rnorm(100), x.Date)

a-merge(x,z)
b-merge(y,k)
c-merge(z,x,y)

test-list(a=a, b=b, c=c)

Can I access the elements of the list in a for/next do loop?

for example something like:

for (i in 1:3)
{
x11()
plot(test[i])
}

So far I can only recover the zoo objects as test$a, test$b etc. etc...

Thanks,
Costas

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] merge.zoo and fill

2010-06-30 Thread Research

Hello again,

I merge different zoo time series with prices at different dates. This 
returns a multivariate zoo object with NA's at various points i.e.,


2010-02-28 NA NA  NA   NA   850.2  2444.4 NA  
NA  NA  NA NA  NA   NA
2010-03-01   61.1   55.361.581.24  NA  NA 1712.2 3.3 
11139.3   163.7 2242.4  9015.6  109.791
2010-03-31 NA NA  NA   NA   846.5  2439.0 NA  
NA  NA  NA NA  NA   NA
2010-04-01   66.9   49.465.784.48  NA  NA 1700.6 3.8 
11203.0   164.4 2245.7  9064.5  109.887
2010-04-30 NA NA  NA   NA   838.0  2440.0 NA  
NA  NA  NA NA  NA   NA
2010-05-01   66.6   45.665.773.84  NA  NA 1705.3 4.0 
11252.0   165.1 2248.4  9113.9  110.065


Will the fill parameter of the zoo.merge() allow a missing value for 
each zoo object merged  to take the last available (previous in time) 
price for that particular time series or one has to do that using  the 
na.locf() command afterwards?


I want ot keep the series as zoo and not convert to other formats or 
interpolate (as in the FAQ)


Thanks,
Costas

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Duplicate dates in zoo objects

2010-06-22 Thread Research

Hello,

I have a zoo time series read from an excel file which has some dates 
the same, such as the following example:


02/10/1995 4925.5
30/10/1995 4915.9
23/01/1996 4963.5
23/01/1996 5009.2
04/03/1996 5031.9 # here
04/03/1996 5006.5 # here
03/04/1996 5069.2
03/05/1996 5103.7
31/05/1996 5107.1
01/07/1996 5153.1
02/08/1996 5151.7

Is there a simple way to keep the last  price of the ones that have the 
same dates?


04/03/19965031.9
04/03/19965006.5

i.e., keep only the 04/03/19965006.5  price and discard the 
previous one... Is there an implicit function that does that or do I 
need some sort of recursive algorithm?


You can try a solution on this example (for convenience):

x.Date - as.Date(2003-02-01) + c(1, 3, 7, 7, 14) - 1
x - zoo(rnorm(5), x.Date)

Zoo object  has 2 prices with same dates.

Many thanks in advance,
Costas

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Time problems (POSIXct)

2010-05-25 Thread Research

Thanks Gabor,

I suppose that in the example below,  you can convet Date to POSIXct as 
well, can't you?


Best,
Costas


On 20/05/2010 18:08, Gabor Grothendieck wrote:

The warning message does tell you exactly what was wrong.   You are
trying to merge zoo objects that have two different index classes.
The first is POSIXct and the second is Date class.  Next time
please provide your data in reproducible form
as shown here:

   

library(zoo)
z1- zoo(1:6, as.Date(c(1950-01-05, 1950-01-06, 1950-01-09,
 

+   1950-01-10, 1950-01-11, 1950-01-12)))
   

z2- zoo(c(16.66, 16.85, 16.93, 16.98, 17.08, 17.03),
 

+ as.POSIXct(c(1950-01-03, GMT, 1950-01-04, GMT, 1950-01-05, GMT,
+   1950-01-06, GMT, 1950-01-09 GMT, 1950-01-10 GMT)))
   

merge(z1, z2 = aggregate(z2, as.Date, identity))
 

z1z2
1950-01-03 NA 16.66
1950-01-04 NA 16.85
1950-01-05  1 16.93
1950-01-06  2 16.98
1950-01-09  3 17.08
1950-01-10  4 17.03
1950-01-11  5NA
1950-01-12  6NA
   


# or
z2.Date- z2
time(z2.Date)- as.Date(time(z2.Date))

merge(z1, z2.Date)
 

z1 z2.Date
1950-01-03 NA   16.66
1950-01-04 NA   16.85
1950-01-05  1   16.93
1950-01-06  2   16.98
1950-01-09  3   17.08
1950-01-10  4   17.03
1950-01-11  5  NA
1950-01-12  6  NA


On Thu, May 20, 2010 at 10:48 AM, Researchrisk2...@ath.forthnet.gr  wrote:
   

Hello,

I have a zoo time series object (say a)  with the following time
stamp/format



[1] 1950-01-03 GMT 1950-01-04 GMT 1950-01-05 GMT 1950-01-06 GMT
[5] 1950-01-09 GMT 1950-01-10 GMT


and another (say b) with


[1] 1950-01-05 1950-01-06 1950-01-09 1950-01-10 1950-01-11
[6] 1950-01-12


I want to merge these series   but when I try:


 

head(merge(a, b ))
   

a   b
1950-01-03 02:00:00   16.66   NA
1950-01-04 02:00:00   16.85   NA
1950-01-05 02:00:00   16.93   NA
1950-01-06 02:00:00   16.98   NA
1950-01-09 02:00:00   17.08   NA
1950-01-10 02:00:00   17.03   NA
Warning message:
In merge.zoo(a, b) :
  Index vectors are of different classes: POSIXt Date
 
   

Anybody can help?  I tried as.POSIXct(a,tz=GMT) but it doesn't seem to
work

Many thanks in advance!

Costas
  _
platform   i386-pc-mingw32
arch   i386
os mingw32
system i386, mingw32
status
major  2
minor  10.1
year   2009
month  12
day14
svn rev50720
language   R
version.string R version 2.10.1 (2009-12-14)
 
   

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

 

__ Information from ESET Smart Security, version of virus signature 
database 5133 (20100520) __

The message was checked by ESET Smart Security.

http://www.eset.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] Time problems (POSIXct)

2010-05-20 Thread Research

Hello,

I have a zoo time series object (say a)  with the following time 
stamp/format




[1] 1950-01-03 GMT 1950-01-04 GMT 1950-01-05 GMT 1950-01-06 GMT
[5] 1950-01-09 GMT 1950-01-10 GMT


and another (say b) with


[1] 1950-01-05 1950-01-06 1950-01-09 1950-01-10 1950-01-11
[6] 1950-01-12


I want to merge these series   but when I try:


 head(merge(a, b ))
a   b
1950-01-03 02:00:00   16.66   NA
1950-01-04 02:00:00   16.85   NA
1950-01-05 02:00:00   16.93   NA
1950-01-06 02:00:00   16.98   NA
1950-01-09 02:00:00   17.08   NA
1950-01-10 02:00:00   17.03   NA
Warning message:
In merge.zoo(a, b) :
  Index vectors are of different classes: POSIXt Date


Anybody can help?  I tried as.POSIXct(a,tz=GMT) but it doesn't seem to 
work


Many thanks in advance!

Costas
  _
platform   i386-pc-mingw32
arch   i386
os mingw32
system i386, mingw32
status
major  2
minor  10.1
year   2009
month  12
day14
svn rev50720
language   R
version.string R version 2.10.1 (2009-12-14)


__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Histogram Bin

2010-05-14 Thread Research

Hello,

Is there a function that returns the number of the bin (or quantile, 
or percentile etc. etc.) that a value of a variable may belong to?


Tor example:

breaks-hist(variable, 18, plot=FALSE)

If the following breaks are

 5 10 15 20 25 30 35 40 45 50 55 60 65 70 75 80 85

the boundaries of successive bins of a histogram, then value 6 belongs 
to the 2nd bin.


Best regards,
Costas

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] mvpart : Printing response values at terminal nodes

2010-04-26 Thread S, Manjunath (GE, Research)
 
I have created a multivariate regression tree using mvpart, with 3-4
responses.  Though the plot shows bargraphs for each response, I would
like to have the VALUES of the responses
printed or indicated (via a scale or something) alongside the bargraph.
 
Is this possible ??
 
Thanks,
Manjunath
 
 

[[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] N'th of month working day problem

2010-04-12 Thread Research
Dear Gabor,

Thanks for your reply. however:

  tail(DJd)
^DJI.Close
2010-04-01   10927.07
2010-04-05   10973.55
2010-04-06   10969.99
2010-04-07   10897.52
2010-04-08   10927.07
*2010-04-09   10997.35*
  tail(ag)

2009-11-30 10344.84
2009-12-31 10428.05
2010-01-31 10067.33
2010-02-28 10325.26
2010-03-31 10856.63
*2010-04-30 10997.35
*
It seems the script makes up dates (?)

Best,
Costas

On 09/04/2010 14:55, Gabor Grothendieck wrote:
 The function seems to be working properly.  You are asking for a day
 of the month which does not exist. I assume this was written a very
 long time ago since there are easier ways to do this now.  yearmon
 class gives an object representing the year and month of a date and if
 ym is such an object then as.Date(ym) gives the first of the month and
 as.Date(ym, frac = 1) gives the last of the month so:

 # nth day of month or last day of month if less
 nth.of.month- function(date, n) {
   ym- as.yearmon(date)
   pmin(as.Date(ym) + n - 1, as.Date(ym, frac = 1))
 }

 ag- aggregate(DJd, nth.of.month(time(DJd), 31), tail, 1)



 On Fri, Apr 9, 2010 at 7:01 AM, Researchrisk2...@ath.forthnet.gr  wrote:

 Dear all,

 Some time ago I received some very kind  help (special thanks to Gabor) to
 construct a function that isolates the n'th   working day of each month for
 zoo object (time series) to create monthly data from daily observations.

 I found out that the code works fine except for the 29 till 31st dates of
 each month as it skips some months (February for example).

 If  you could help me isolate the problem I would be grateful as I can not
 find a way to explain to R to keep the last  working day of month if I
 choose the 29th, 30th or 31st dates...

 I enclose  a working version of the function and a script for demo purposes.

 Many thanks in advance,
 Costas

 library(fImport)
 library(zoo)
 DJ-yahooSeries(^DJI, frequency=daily, nDaysBack=1)
 DJd-as.zoo(DJ[,4])

 ### Choose number of day for month

 chooseday-function(z, day)

 {

 # z.na is same as z but with missing days added using NAs
 # Its formed by merging z with a zoo-width series containing all days.

 rng- range(time(z))
 z.na- merge(z, zoo(, seq(rng[1], rng[2], by = day)))

 # form a series that has NAs wherever z.na does but has 1, 2, 3, ...
 # instead of z.na's data values and then use na.locf to fill in NAs

 idx- na.locf(seq_along(z.na) + (0 * z.na))

 # pick off elements of z.na corresponding to i'th of month

 noofday- paste(day)

 if (day10) noofday-paste(0,day, sep=)

 tempdata-z.na[idx[format(time(z.na), %d) == noofday]]

 return(tempdata)

 }

 length(chooseday(DJd,1))
 length(chooseday(DJd,2))
 length(chooseday(DJd,31))
 length(chooseday(DJd,30))
 length(chooseday(DJd,29))
 length(chooseday(DJd,28))
 tail(chooseday(DJd,31))







  



[[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] Exchanging zoo object dates

2010-04-08 Thread Research

Hi,

I have two zoo objects (time series of same frequency) say A and B. I 
need to exchange A's dates for B's.


Is there and easy way?

I managed to do it by converting A to a vector and pasting it on a   zoo 
vector (all ones) with B's dates but I wonder if there is an easier  way 
by some zoo command  I have overlooked...


Thanks in advance,
Costas

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Playwith with Linux Mint

2010-03-19 Thread Research
Hi,

I am having problems installing playwith on a Linux Mint ver. 8 (Helena) 
computer running R-2.10.1. src/base/R-2/R-2.10.1.tar.gz

Anybody facing similar problems?

Is it a GTK issue? I can not install the cairo related 
packages/libraries as well.

Any pointers very welcome.

Thanks + bestregards,
Costas

[[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] List of zoo dataframes

2010-03-03 Thread Research
Hello,

I have various datasets of zoo time series (merged into single frames 
via the merge command)  such as

datevar0var1var2var3
08/07/1996  652.54  0.2239220.5158190.502638
08/08/1996  662.59  0.9978410.0003830.999806
06/09/1996  655.68  0.9016850.5697630.866333
08/10/1996  700.64  0.2688550.2447010.329285
08/11/1996  730.82  0.4384070.5014270.461374
06/12/1996  739.6   0.4322330.5621750.052423
08/01/1997  748.41  0.6162110.7992115.96E-09
07/02/1997  789.56  0.3784150.6450880.93862
07/03/1997  804.97  0.1427060.4221560.145648
08/04/1997  766.12  0.990.9994350.998576
08/05/1997  820.26  0.8107950.9660440.000427
06/06/1997  858.01  0.9986520.9982870.994222
08/07/1997  918.75  0.9515530.9742510.89633



I am trying to put all these into a sort of a list so I can invoke them 
via the list
and not individually so I can run a batch of statistical analyses on them.

I also want to have the specification of the analysis on a list of some 
sort as well.

For example:

List a has 3 zoo data sets and list b has  2 specifications (calls) 
for a function (say,  analysis(specification, inputdata) ) that runs 
some statistical manipulations (regressions, nonlin models, etc. etc.) 
on the elements of the zoo data frames. Thus I want to be able to run 
(this is pseudo R code):

for (i in 1:3)
{
output1-analysis(b[1], a[i])
output2-analysis(b[2], a[i])
}

Thanks in advance for any pointers or help.

Best,
Costas






[[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] ZOO object colnames refering to Dates

2010-02-11 Thread Research

Hello,

I have  large zoo objects (about 100 or more time series merged next to 
eachother). Example:


X05.Oct.99 X05.Nov.99 X05.Dec.99 X05.Jan.00 X05.Feb.00 X05.Mar.00 
X05.Apr.00 X05.May.00 X05.Jun.00
[1,] 5649.3 5679.4 5679.4 5679.4 5679.4 
5679.4 5679.4 5679.4 5679.4
[2,] 5682.7 5719.2 5719.2 5719.2 5719.2 
5719.2 5719.2 5719.2 5719.2
[3,] 5697.5 5745.5 5745.5 5745.5 5745.5 
5745.5 5745.5 5745.5 5745.5
[4,] 5723.9 5767.8 5767.8 5767.8 5767.8 
5767.8 5767.8 5767.8 5767.8
[5,] 5782.1 5829.8 5829.8 5829.8 5829.8 
5829.8 5829.8 5829.8 5829.8
[6,] 5815.0 5850.9 5850.9 5850.9 5850.9 
5850.9 5850.9 5850.9 5850.9



The column names contain dates, i.e.,  X05.Oct.99 stands for a time 
sequence that was obtained on 05/10/1999. Each column is obtained  month 
+ 1 from the previous one.


Is it possible to access these columns (time series data) via a for/next 
loop (or a while) that uses dates i/o (i in 1:8) in the above example?


Say: if month==Oct and year==1999 choose column X05.Oct.99 ...

Could I also generate automatically a variable, appropriately named from 
the corresponding columns name that would contain the data and access it 
by that date?


Any pointers really appreciated.

Thanks in advance,
Costas


__ Information from ESET Smart Security, version of virus signature 
database 4857 (20100211) __

The message was checked by ESET Smart Security.

http://www.eset.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] Using tcltk or other graphical widgets to view zoo time series objects

2010-02-01 Thread Research
Dear Felix,

Thanks. That was most useful. I am having trouble though exporting 
values of variables to the R environment from within the playwith.

Say I need to do a claculation by setting up an extra  button within

playwith(xyplot(dat[,c(1,i)]),  parameters = list(i = 1:100,
do_something = function(playState) print(playState$env$i),
do_something_else = function(playstate) ###Export here mean value of 
sequence playState$env$i###
)
)

Can I pass the value of this to the rest of R ? I could not find 
something in the help pages. Can you direct me to it please?

Thanks +

Best regards,
Costas

Felix Andrews wrote:
 The playwith package might help, though if I understand the problem
 correctly, the help(xyplot.zoo) example is not so relevant. If you
 want to switch between many series you could use a spin-button or
 somesuch. To execute a function you can create a button.

 If you have a hundred-column dataset like
 dat - zoo(matrix(rnorm(100*100),ncol=100), Sys.Date()+1:100)
 colnames(dat) - paste(Series, 1:100)

 Then this will give you a spin button to choose the column to plot,
 and a button to print out the current series number.

 playwith(xyplot(dat[,c(1,i)]),  parameters = list(i = 1:100,
 do_something = function(playState) print(playState$env$i))
 )

 Note that the playwith package uses RGtk2, and therefore requires the
 GTK+ libraries to be installed on your system.



 On 28 January 2010 23:16, Gabor Grothendieck ggrothendi...@gmail.com wrote:
   
 There is an example of using zoo together with the playwith package at
 the end of the examples section of help(xyplot.zoo) which may address
 this.

 On Thu, Jan 28, 2010 at 7:10 AM, Research risk2...@ath.forthnet.gr wrote:
 
 Dear all,

 I am looking at the R-help entry below:

 http://finzi.psych.upenn.edu/R/Rhelp02/archive/26640.html

 I have a more complicatedt problem. I have a zoo time series frame with 100+
 sequences.

 I want to cycle through them back and forth and compare them to the 1st
 column at any time.

 I need also a button to click when I need the viewed-selected sequence (that
 is being compared to the 1st column one) to be manipulated
 (by some algorithm or be saved individually etc. etc.)...

 I am trying to modify the code at the above link but somehow I can not make
 it to work with zoo time series objects.


 Any help would be greatly appreciated.

 Thanks in advance,
 Costas


 __ Information from ESET Smart Security, version of virus signature
 database 4813 (20100128) __

 The message was checked by ESET Smart Security.

 http://www.eset.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.

 



   




__ Information from ESET Smart Security, version of virus signature 
database 4823 (20100201) __

The message was checked by ESET Smart Security.

http://www.eset.com


[[alternative HTML version deleted]]

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


Re: [R] Using tcltk or other graphical widgets to view zoo time series objects

2010-02-01 Thread Research
Many thanks Liviu!

Liviu Andronic wrote:
 On 2/1/10, Research risk2...@ath.forthnet.gr wrote:
   
 do_something_else = function(playstate) ###Export here mean value of 
 sequence playState$env$i###

 

 Would this do the trick?
 playwith(xyplot(dat[,c(1,i)]),  parameters = list(i = 1:100,
 do_something = function(playState) print(playState$env$i),
 do_something_else = function(playState) print(mean(dat[, 
 playState$env$i])),
 do_something_diff = function(playState) {
 assign(x, mean(dat[, playState$env$i]), envir = .GlobalEnv)
 print(x)
 }
 )
 )


 Liviu

 __ Information from ESET Smart Security, version of virus signature 
 database 4823 (20100201) __

 The message was checked by ESET Smart Security.

 http://www.eset.com




   




__ Information from ESET Smart Security, version of virus signature 
database 4823 (20100201) __

The message was checked by ESET Smart Security.

http://www.eset.com


[[alternative HTML version deleted]]

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


[R] Using tcltk or other graphical widgets to view zoo time series objects

2010-01-28 Thread Research

Dear all,

I am looking at the R-help entry below:

http://finzi.psych.upenn.edu/R/Rhelp02/archive/26640.html

I have a more complicatedt problem. I have a zoo time series frame with 
100+ sequences.


I want to cycle through them back and forth and compare them to the 1st 
column at any time.


I need also a button to click when I need the viewed-selected sequence 
(that is being compared to the 1st column one) to be manipulated

(by some algorithm or be saved individually etc. etc.)...

I am trying to modify the code at the above link but somehow I can not 
make it to work with zoo time series objects.



Any help would be greatly appreciated.

Thanks in advance,
Costas


__ Information from ESET Smart Security, version of virus signature 
database 4813 (20100128) __

The message was checked by ESET Smart Security.

http://www.eset.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] piecewise regression using nlme function

2010-01-07 Thread Carlson, Erik A (GE, Research)
 
Is a 95% CI on a breakpoint fixed effect legitimate when the nonlinear
equation is continuous but not differentiable at the breakpoint?
 
I used the nlme to generate a non-linear mixed-effects piecewise model
with initial slope zero prior to an unknown breakpoint. It did give a
95% CI for the breakpoint.
 
Thanks
Erik
 
whole model is complex, but here is the simple equation used:
 
dr.hockey-function(a,b,x,brk){
 a+ifelse(x=brk,0,b*(x-brk))}
 
 

[[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] End of Month date capture

2009-11-11 Thread Research

Dear R-users,

I have the following zoo object:

   x1x2  x3   x4   
x5 x6
1998-08-31 -0.0704375904  NA  NA   NA   
NA NA
1998-09-01  0.0379028122  NA  NA   NA   
NA 0.00609139
1998-09-02 -0.0038191639  NA  NA   NA   
NA NA
1998-09-03 -0.0083235389  NA  NA   NA   
NA NA
1998-09-04 -0.0085576782  NA  NA 0.0028570541   
NA NA
1998-09-07  0.00  NA  NA   NA   
NA NA
1998-09-08  0.0496459618  NA  NA   NA   
NA NA
1998-09-09 -0.0170081847  NA  NA   NA   
NA NA
1998-09-10 -0.0261897076  NA  NA   NA   
NA NA
1998-09-11  0.0290280530  NA  NA   NA   
NA NA
1998-09-14  0.0202677162  NA  NA   NA   
NA NA
1998-09-15  0.0077005314  NA  NA   NA   
NA NA
1998-09-16  0.0074886581  NA  NA   NA 
-0.002710978 NA
1998-09-17 -0.0257819401  NA  NA   NA   
NA NA
1998-09-18  0.0011966887  NA  NA   NA   
NA NA
1998-09-21  0.0037182403  NA  NA   NA   
NA NA
1998-09-22  0.0055904154  NA  NA   NA   
NA NA
1998-09-23  0.0347982355  NA  NA   NA   
NA NA
1998-09-24 -0.0221650663  NA  NA   NA   
NA NA
1998-09-25  0.0019449387  NA 0.007833611   NA   
NA NA
1998-09-28  0.0037641439  NA  NA   NA   
NA NA
1998-09-29  0.0003146288  NA  NA   NA   
NA NA
1998-09-30 -0.0309894451  NA  NA   NA   
NA NA
1998-10-01 -0.0305704149  NA  NA   NA   
NA 0.
1998-10-02  0.0163000909 -0.03409975  NA 0.0004991463   
NA NA
1998-10-05 -0.0141025660  NA  NA   NA   
NA NA
1998-10-06 -0.0040240279  NA  NA   NA   
NA NA
1998-10-07 -0.0142284540  NA  NA   NA   
NA NA
1998-10-08 -0.0116470759  NA  NA   NA   
NA NA
1998-10-09  0.0256723791  NA  NA   NA   
NA NA
1998-10-12  0.0134404929  NA  NA   NA   
NA NA
1998-10-13 -0.0029209410  NA  NA   NA   
NA NA
1998-10-14  0.0107283327  NA  NA   NA   
NA NA
1998-10-15  0.0408820605  NA  NA   NA   
NA NA
1998-10-16  0.0084890073  NA  NA   NA  
0.006675831 NA
1998-10-19  0.0056352536  NA  NA   NA   
NA NA
1998-10-20  0.0014485122  NA  NA   NA   
NA NA
1998-10-21  0.0056142800  NA  NA   NA   
NA NA
1998-10-22  0.0079687631  NA  NA   NA   
NA NA
1998-10-23 -0.0072680217  NA  NA   NA   
NA NA




I need to create second one which contains the end of each month rows 
only. Is there an easy way of doing this? The data starts at 1998-08-31 
and ends at 2009-11-06.


Many thanks in advance,
Costas

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] AMRAtoMA

2009-11-10 Thread Pietrzykowski, Matthew (GE, Research)
Hello R Users!

I have a question about the output of ARMAtoMA when used to calculate
the variance of
a model.  I have a mixed model of the form ARMA(1,1).  The actual
model takes the form:

X(t) = 0.75X(t-12) + a(t) - 0.4a(t-1)

Given that gamma(0) takes the form [(1 + theta^2 -
2*theta*phi)/(1-phi^2)]*sigma(a), I would
expect a process variance of 4.02*sigma(a) when I substitute 0.75 for
phi and -0.4 for theta.

When I run ARMAtoMA,

result - ARMAtoMA(ar=c(0.75), ma=(-0.4), lag.max=40)
sum(result^2)+1

I get 1.28.  If I input 0.4 instead of -0.4 in ARMAtoMA I get the
result I expected.  Is there a sign
dependence in the R function I am overlooking?

Thanks in advance.

Matt 

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] A beginner's question about ggplot

2009-05-01 Thread MUHC-Research

Dear R-users,

I would have another question about the ggplot() function in the ggplot2
package.

All the examples I've read so far in the documentation make use of a single
neatly formatted data.frame. However, sometimes, one may be interested in
plotting on the same grid information or objects derived from two totally
different datasets and customize both displays. I still cannot tell how this
can be done using ggplot().

Here's an example.

###
## A very simple data.frame;

my.data = data.frame(X1 =
as.factor(rep(1:2,c(4,4))),X2=c(4,3,5,2,6,2,3,5),X3=c(1:3,2,2:4,5)) ;

## Let's say I want to add the X^2 line to the plot;

squared = data.frame(X=1:12,Y=((1:12)/2)^2) ;

## A scatterplot for my.data ;

p = ggplot(my.data,aes(x=X2,y=X3,group=X1)) ;
p = p+geom_point(aes(colour=X1)) ; 

#

How can squared be added to the plot? At first, I used

p+geom_line(data=squared,aes(x=X,y=Y,group=1,colour=green)) ;

but the plotted line is always blue! In fact, I can replace colour by any
character value and I will still get a blue line.

Although I may be wrong, I think this is pretty straightforward. Can anyone
give me a pointer as to how we can add arbitrary curves to a ggplot graph
and then customize them? A bit later, I'll have to overlay histograms
derived from totally different datasets and, if possible, I'd like to use
the ggplot2 library for that too, hence the importance of understanding how
ggplot objects can be mixed.

Thanks a lot,

Luc
-- 
View this message in context: 
http://www.nabble.com/A-beginner%27s-question-about-ggplot-tp23336793p23336793.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] Overlaying graphs from different datasets with ggplot

2009-04-30 Thread MUHC-Research

Dear R-users,

I recently began using the ggplot2 package and I am still in the process of
getting used to it.

My goal would be to plot on the same grid a number of curves derived from
two distinct datasets. The first dataset (called molten.data) looks like
this :

Column names : Perc, Week, Weight

P10   21  333.3554
P90   21  486.0480
P10   22  452.6347
P90   22  563.8263
P10   23  575.0960
P90   23  661.6841
P10   24  700.4449
P90   24  779.4067
P10   25  828.4966
P90   25  917.1222

The second dataset (called skj) looks like this:

Column names : Week, Perc, Weight
 
211  317.5
221  392.5
231  467.5
241  542.5
251  617.5
261  697.5
212  535.0
222  632.5
232  737.5
242  855.0
252  980.0
262 1115.0   
213  425.0
223  512.5
233  602.5
243  697.5
253  800.0
263  907.5

Now, I plot my graphs using (with the Perc column in skj being a factor) :

p - ggplot(molten.data, aes(x=Week, y=Weight, group=Perc)) ;
p - p + geom_line(aes(colour = Perc,size=1,linetype=Perc)) ;
p +
geom_line(data=skj,mapping=aes(x=Week,y=Weight,group=Perc,linetype=Perc)) ;

This yields the following error message:
##
Error in data.frame(c(#FF6C91FF, #00C1A9FF), c(solid, 22, 42,  : 
  arguments imply differing number of rows: 2, 5
##

If I remove the linetype=Perc argument, I get a graph, but also a warning:
##
Warning message:
In data$arrow - NULL : Coercing LHS to a list
##

So, what am I doing wrong in this situation?

I thank you sincerely for your help,

Luc
-- 
View this message in context: 
http://www.nabble.com/Overlaying-graphs-from-different-datasets-with-ggplot-tp23322409p23322409.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] lme between-group and within-group covariance

2009-04-03 Thread MUHC-Research

I will try to make this more precise. In the lme() function, the
correlation argument allows the user to specify a within-group correlation
structure, i.e. the structure of the Lambda matrix using the mixed model
notation in Pineiro and Bates. What I want to do is specify a distinct
structure for the Psi matrix (same notation), that is, a correlation
structure for the random effects.

If lme() doesn't allow for this, is there any other function that I could
use?



MUHC-Research wrote:
 
 Dear R users,
 
 I would be interested in using the lme() function to fit a linear mixed
 model to a longitudinal dataset. I know this function allows for the
 specification of a within-group covariance structure. However, does it
 allow for the explicit specification of a between-group covariance
 structure?
 
 Being able to specify both separately would be very important in the
 context of my project since, as might be expected, they have different
 implications/interpretations.
 
 For instance, the mixed procedure in SAS allows users to specify the two
 structures separately by adding a value for the type argument after the
 RANDOM statement and the REPEATED statement.
 
 My question is thus if we can do the same with lme().
 
 I thank you most sincerely for your help. 
 

-- 
View this message in context: 
http://www.nabble.com/lme-between-group-and-within-group-covariance-tp22834748p22868945.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] lme between-group and within-group covariance

2009-04-01 Thread MUHC-Research

Dear R users,

I would be interested in using the lme() function to fit a linear mixed
model to a longitudinal dataset. I know this function allows for the
specification of a within-group covariance structure. However, does it allow
for the explicit specification of a between-group covariance structure?

Being able to specify both separately would be very important in the context
of my project since, as might be expected, they have different
implications/interpretations.

For instance, the mixed procedure in SAS allows users to specify the two
structures separately by adding a value for the type argument after the
RANDOM statement and the REPEATED statement.

My question is thus if we can do the same with lme().

I thank you most sincerely for your help. 
-- 
View this message in context: 
http://www.nabble.com/lme-between-group-and-within-group-covariance-tp22834748p22834748.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] Reflecting correct color and density values in a barplot legend

2008-08-08 Thread Pietrzykowski, Matthew (GE, Research)
Hello-

I am trying to build a barplot with a fairly large number or categories
(65).
I figured out how to plot the bars with solid colors and then with
density lines
to differentiate the 65 items with the following code:

barplot(data,col = seq(2:11))
barplot(data,col = black, density = c(0,seq(10,90,10)))

#The above produces one barplot with densities overlaid on my colored
columns

My question is how do I set up my legend to show the same color/density
pattern?

Thank you,

Matt


[[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] Simulated annealing method with restarts

2008-05-09 Thread Gordon, Bernard (Research)
Hello R-Help,
   I'm using R to do some optimization, specifically using the optim
method with method = 'SANN' (simulated annealing).  I read the help
file, and noticed that this method does not include restarts/reheats,
which I think would help my optimization significantly.  Does anyone
know of an implementation that does this?  I searched both the internet
and the help archives and was unable to find anything.  Thanks in
advance.
 
Bernard Gordon


This is not an offer (or solicitation of an offer) to buy/sell the 
securities/instruments mentioned. Morgan Stanley may deal as principal in or 
own or act as market maker to securities/instruments mentioned or may advise 
the issuers. This may refer to a research analyst/research report. For 
additional information, research reports and important disclosures, contact me 
or see https://secure.ms.com. We do not represent this is accurate or complete 
and we may not update this. Past performance is not indicative of future 
returns. This communication is solely for the addressee(s) and may contain 
confidential information. We do not waive confidentiality by mistransmission. 
Contact me if you do not wish to receive these communications. This 
communication is directed in the UK to those persons who are professional and 
eligible counterparties (as defined in the UK Financial Services Authority's 
rules).

[[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] peak finding

2008-03-24 Thread Research Scholar
Hi all
 Is there a function that can find the start and end position of peaks in a
set of numbers.
eg.
x=c(14,15,12,11,12,13,14,15,16,15,14,13,12,11,14,12)
y=somefunction(x)

y
4 14


Thanks
John

[[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] peak finding

2008-03-24 Thread Research Scholar
Hi
 Thanks for replying. I meant x[4] is the start of a peak shape and x[14] is
the end of that peak and x[9] is the maxima of the peak.
Thanks,
John




On Mon, Mar 24, 2008 at 11:09 PM, [EMAIL PROTECTED] wrote:

 It's hard to see how positions 4 and 14 correspond to 'peaks', they look
 like troughs to me.  So perhaps this is what you mean:

  x - c(14,15,12,11,12,13,14,15,16,15,14,13,12,11,14,12)

  y - which(x == min(x))
  y
 [1]  4 14

 as a function:

 somefunction - function(x) which(x == min(x))


 Bill Venables
 CSIRO Laboratories
 PO Box 120, Cleveland, 4163
 AUSTRALIA
 Office Phone (email preferred): +61 7 3826 7251
 Fax (if absolutely necessary):  +61 7 3826 7304
 Mobile: +61 4 8819 4402
 Home Phone: +61 7 3286 7700
 mailto:[EMAIL PROTECTED]
 http://www.cmis.csiro.au/bill.venables/

 -Original Message-
 From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
 On Behalf Of Research Scholar
 Sent: Tuesday, 25 March 2008 12:54 PM
 To: r-help@r-project.org
 Subject: [R] peak finding

 Hi all
  Is there a function that can find the start and end position of peaks
 in a
 set of numbers.
 eg.
 x - c(14,15,12,11,12,13,14,15,16,15,14,13,12,11,14,12)
 y - somefunction(x)

 y
 4 14


 Thanks
 John

[[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.htmlhttp://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] Replacing text

2008-03-11 Thread Suran, Luciana @ Torto Wheaton Research
Sorry, another newbie question :-(

 

 

I loaded a data set with 10 rows and 30 columns. The first column is
characters for names of car manufacturers:

 

Jeep

Nissan

Toyota1

Toyota2

Etc.

 

How can I replace Toyota2 with Scion?

 

Thanks again

 

 

 

 


[[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] combining/deleting rows

2008-03-10 Thread Suran, Luciana @ Torto Wheaton Research
Hello List,

 

I'm new to R and have some question on combining (and deleting) rows. 

 

I have a dataset that looks like this: 

 

 

msa_id

base_sf.2002.2

compltns.2002.2

absorption.2002.2

avrate.2002.2

1

AKRON

27918

0

-1420

19

24

ALBUQU

20469

77

-23

9.2

100

ALLENT

41490

0

-208

19

129

AARBOR

6264

0

62

18

178

ATLANT

395974

1486

638

16.6

254

AUSTIN

34000

31

153

15

330

BALTIM

121080

361

-3447

17.7

 

 

How can I add row 1 to row 24? Also, how can I delete rows from the
dataframe?

 

 

Thanks so much in advance,

Luciana

 

Luciana Suran | Economist  

CBRE Torto Wheaton Research | Research 

200 High Street, 3rd Floor | Boston, MA 02110 

T 617 912 5204 | F 617 912 5240 

[EMAIL PROTECTED] | www.tortowheatonresearch.com 

 

Please consider the environment before printing this email. 

 

This email may contain information that is confidential or
attorney-client privileged and may constitute inside information. The
contents of this email are intended only for the recipient(s) listed
above. If you are not the intended recipient, you are directed not to
read, disclose, distribute or otherwise use this transmission. If you
have received this email in error, please notify the sender immediately
and delete the transmission. Delivery of this message is not intended to
waive any applicable privileges.

 

 


[[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] linear discriminant analysis / search

2008-03-06 Thread Research Scholar
Dear R help list,

I have a training dataset that looks like Table1.
I have an unknown dataset that looks like Table2.
I want to have a program that should search the training dataset and
identify that the unknown sample belongs to which category (type1, type2 or
type3)
and also if the unknown does not belong to any of the categories, it should
let me know.
The real dataset has 600 variables and 50 sample types.

I tried working with linear discriminant analysis (lda in MASS package) and
its predict function. It works great but I think  lda is supposed to
categorize unknown into one of the types.
Most of my unknowns would not be from any category in the training dataset.
I don't want to have false positive identification.


Table 1: Three types and 10 variables

type1type1type1type2type2type2type3type3
type3
var1242825505146182016
var245498910910
var3777121212966
var445410129222
var545410910323
var6545232135
var7545777333
var834310108424
var9343222222
var10333444312


Table 2

unknown
var123
var24
var37
var44
var54
var66
var75
var83
var93
var103



Thanks

RS

[[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] linear discriminant analysis

2008-03-06 Thread Research Scholar
Dear R help list,

I have a training dataset that looks like Table1.
I have an unknown dataset that looks like Table2.
I want to have a program that should search the training dataset and
identify that the unknown sample belongs to which category (type1, type2 or
type3)
and also if the unknown does not belong to any of the categories, it should
let me know.
The real dataset has 600 variables and 50 sample types.

I tried working with linear discriminant analysis (lda in MASS package) and
its predict function. It works great but I think  lda is supposed to
categorize unknown into one of the types.
Most of my unknowns would not be from any category in the training dataset.
I don't want to have false positive identification.


Table 1: Three types and 10 variables

type1type1type1type2type2type2type3type3
type3
var1242825505146182016
var245498910910
var3777121212966
var445410129222
var545410910323
var6545232135
var7545777333
var834310108424
var9343222222
var10333444312


Table 2

unknown
var123
var24
var37
var44
var54
var66
var75
var83
var93
var103



Thanks

RS

[[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] Object Oriented programming in R

2008-03-06 Thread Research Scholar
You can try this good resource
http://www1.maths.lth.se/help/R/R.oo/

RS



On Thu, Mar 6, 2008 at 9:30 PM, Davood Tofighi [EMAIL PROTECTED] wrote:

 Dear all,

 I was wondering if there a guide/tutorial to the object oriented
 programming
 in R for the beginners.

 Thanks,

 --
 Davood Tofighi
 Department of Psychology
 Arizona State University

[[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] forming a linear discriminant function from the output of lda()

2008-01-18 Thread Pietrzykowski, Matthew (GE, Research)
Hello all-

I am a relatively new user of R and am working through a graduate course
in
Statistics that uses Minitab, SAS and some Matlab.  I like using R but
am 
having some trouble lining up the output from lda() to that of the other
programs'
results.  The dataset below is a modified set of wine data from the
Pinot Noir
data set as an illustration of the 2 group LDA scenario.

MoBa Region
1  0.058 0.225  3
2  0.071 0.105  3
3  0.147 0.301  2
4  0.116 0.166  3
5  0.166 0.132  3
6  0.261 0.078  3
7  0.191 0.085  3
8  0.009 0.072  3
9  0.027 0.094  3
10 0.030 0.349  2
11 0.268 0.099  3
12 0.245 0.071  3
13 0.161 0.181  2
14 0.146 0.328  2
15 0.155 0.081  3
16 0.126 0.299  2
17 0.211 0.206  2
18 0.129 0.281  2
19 0.166 0.292  2
20 0.199 0.292  2
21 0.208 0.087  3

There are various displays from SAS, Minitab and Matlab's Statistics
Toolbox, but
they all agree with the final linear discriminant function: 0 = -19.51 +
21.47*Mo + 84.08*Ba.

When I run the following code in R: 

 library(MASS)
 wine.lda - lda(Region ~ Mo + Ba, data = wine, prior = c(1,1)/2)
 wine.lda
Call:
lda(Region ~ Mo + Ba, data = wine, prior = c(1, 1)/2)

Prior probabilities of groups:
  2   3 
0.5 0.5 

Group means:
 MoBa
2 0.146 0.281
3 0.1479167 0.1079167

Coefficients of linear discriminants:
  LD1
Mo  -5.636024
Ba -22.069187

I am having trouble going from the cofficients derived from the
spherical within group covariance to the
function I am able to obtain in the other programs.

The rest of the problem set up for all programs are: Region = group
assignment, prior = equal priors and 
I do not do any data pretreatment prior to analysis.

Any help would be great.

Thanks,

Matt

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