Re: [R] Cannot subset a specific mean from this function

2015-12-18 Thread Bradley Wolf
David,
  I withdrew from the class because I couldn't understand it. Apologies. I
shall ask no more questions.

Brad

On Fri, Dec 18, 2015 at 3:28 PM, David Winsemius 
wrote:

>
> > On Dec 18, 2015, at 7:23 AM, Bradley Wolf  wrote:
> >
> > Jim,
> >  Thank you for your response.  I am not asking you for you to do my work.
> > I am really new to programming (in any context) and really haven't gotten
> > the grasp of the logic yet. I have used R before but in the context of R
> > Commander and am trying this so I can be a more robust user.
>
> Your question which you have not copied as requested by the posting guide
> is clearly part of a homework assignment for one of the online programming
> classes. I believe you were asked in the course introduction to submit
> questions to a web interface. Rhelp has a no homework policy.
>
> --
> David.
>
> >
> > That being said, I wanted the last 53 file names read. The irony of my
> > problem is, I can do the assignment if it was to get the mean of all the
> > files (I am  reading 332 csv's).
> >
> > Thanks,
> >
> > Brad
> >
> >   [[alternative HTML version deleted]]
> >
> > __
> > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> > and provide commented, minimal, self-contained, reproducible code.
>
> David Winsemius
> Alameda, CA, USA
>
>

[[alternative HTML version deleted]]

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


[R] Help needed in data cleaning

2015-12-18 Thread Web Web
Hello,
   I need some help in data cleaning using R. my CSV file looks as
follows.

"id","gender","age","category1","category2","category3","category4","category5","category6","category7","category8","category9","category10"1,"Male",22,"movies","music","travel","cloths","grocery",2,"Male",28,"travel","books","movies",,,3,"Female",27,"rent","fuel","grocery","cloths",,4,"Female",22,"rent","grocery","travel","movies","cloths",5,"Female",22,"rent","online-shopping","utiliy",,,

I need to reformat as follows.

id gender age categoryrank1 Male22  movies
  11 Male22  music21 Male22  travel
   31 Male22  cloths   41 Male22  grocery
51 Male22  booksNA1 Male22  rent
  NA1 Male22  fuel NA1 Male22  utility
 NA1 Male22  online-shopping  NA
...5 Female22  movies
NA5 Female22  music  NA5 Female22  travel
   NA5 Female22  cloths NA5 Female22  grocery
  NA5 Female22  books  NA5 Female22  rent
 15 Female22  fuel   NA5 Female22  utility
   NA5 Female22  online-shopping2

So far My efforts are as follows.

mini <- read.csv("~/MS/coding/mini.csv", header=FALSE)
mini_clean <- mini[-1,]
df_mini <- melt(df_clean, id.vars=c("V1","V2","V3"))
sqldf('select * from df_mini order by  "V1"')

Now I want to know what is the best way to fill all missing categories for
all users.

Thanks
Nash

[[alternative HTML version deleted]]

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


Re: [R] Missing data in RMark

2015-12-18 Thread Joe Ceradini
Caroline - the phidot forum is an *excellent* spot to post this question.
There is an entire RMark subforum.
www.phidot.org/forum/index.php
Even just searching this forum will probably give you some answers.

Also, this book has a whole section on individual covariates and approaches
for dealing with missing values (it is an amazing MARK resource in general):
www.phidot.org/software/mark/docs/book/

The problem you are having is a fundamental problem with individual
covariates that are unknown for individuals that were not captured.

Joe

On Fri, Dec 18, 2015 at 10:42 AM, Caroline Glidden <
glidd...@science.oregonstate.edu> wrote:

> I am currently trying to run a Known Fates Model in RMark with individual
> time varying covariates. However, for animals that died early in the study
> or were not captured at one capture period I, of course, do not have data
> for all of their time points. I thought that NAs would not matter when the
> LD capture history was 00, and therefore, having no data during the time
> points the animal was unable to be sampled would not be a big deal.
> However, RMark cannot fit my model due to the NAs. I was wondering how I
> should code the individual time varying covariates for time points at which
> the animal has no data due to it not being captured or due to it dying?
> [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



-- 
Cooperative Fish and Wildlife Research Unit
Zoology and Physiology Dept.
University of Wyoming
joecerad...@gmail.com / 914.707.8506
wyocoopunit.org

[[alternative HTML version deleted]]

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


Re: [R] error in vcovNW

2015-12-18 Thread Saba Sehrish via R-help
Thank you. The issue is resolved by scaling the data in millions.
Saba 

On Saturday, 19 December 2015, 15:06, Achim Zeileis 
 wrote:
 

 On Sat, 19 Dec 2015, Saba Sehrish via R-help wrote:

> Hi I am using NeweyWest standard errors to correct lm( ) output. For example:
> lm(A~A1+A2+A3+A4+A5+B1+B2+B3+B4+B5)
> vcovNW<-NeweyWest(lm(A~A1+A2+A3+A4+A5+B1+B2+B3+B4+B5))
>
> I am using package(sandwich) for NeweyWest. Now when I run this command, it 
> gives following error:
> Error in solve.default(diag(ncol(umat)) - apply(var.fit$ar, 2:3, sum)) 
> :system is computationally singular: reciprocal condition number = 7.49468e-18
>
> Attached herewith is data for A&B, A1,A2,A3,A4,A5,B1,B2,B3,B4,B5 are 
> simply lag variables. Can you help me removing this error please?

Without trying to replicate the error, there are at least two issues:

(1) You should scale your data to use more reasonable orders of magnitude, 
e.g., in millions. This will help avoiding numerical problems.

(2) More importantly, you should not employ HAC/Newey-West standard errors 
in autoregressive models. If you use an autoregressive specification, you 
should capture all relevant autocorrelations - and then no HAC estimator 
is necessary. Alternatively, one may treat autocorrelation as a nuisance 
parameter and not model it - but instead capture it in HAC standard 
errors. Naturally, the former strategy will typically perform better if 
the autocorrelations are more substantial.

> Saba

  
[[alternative HTML version deleted]]

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

Re: [R] error in vcovNW

2015-12-18 Thread Achim Zeileis

On Sat, 19 Dec 2015, Saba Sehrish via R-help wrote:


Hi I am using NeweyWest standard errors to correct lm( ) output. For example:
lm(A~A1+A2+A3+A4+A5+B1+B2+B3+B4+B5)
vcovNW<-NeweyWest(lm(A~A1+A2+A3+A4+A5+B1+B2+B3+B4+B5))

I am using package(sandwich) for NeweyWest. Now when I run this command, it 
gives following error:
Error in solve.default(diag(ncol(umat)) - apply(var.fit$ar, 2:3, sum)) :system 
is computationally singular: reciprocal condition number = 7.49468e-18

Attached herewith is data for A&B, A1,A2,A3,A4,A5,B1,B2,B3,B4,B5 are 
simply lag variables. Can you help me removing this error please?


Without trying to replicate the error, there are at least two issues:

(1) You should scale your data to use more reasonable orders of magnitude, 
e.g., in millions. This will help avoiding numerical problems.


(2) More importantly, you should not employ HAC/Newey-West standard errors 
in autoregressive models. If you use an autoregressive specification, you 
should capture all relevant autocorrelations - and then no HAC estimator 
is necessary. Alternatively, one may treat autocorrelation as a nuisance 
parameter and not model it - but instead capture it in HAC standard 
errors. Naturally, the former strategy will typically perform better if 
the autocorrelations are more substantial.



Saba

__
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] error in vcovNW

2015-12-18 Thread Saba Sehrish via R-help
Hi I am using NeweyWest standard errors to correct lm( ) output. For example:
lm(A~A1+A2+A3+A4+A5+B1+B2+B3+B4+B5)
vcovNW<-NeweyWest(lm(A~A1+A2+A3+A4+A5+B1+B2+B3+B4+B5))

I am using package(sandwich) for NeweyWest. Now when I run this command, it 
gives following error:
Error in solve.default(diag(ncol(umat)) - apply(var.fit$ar, 2:3, sum)) :system 
is computationally singular: reciprocal condition number = 7.49468e-18

Attached herewith is data for A&B, A1,A2,A3,A4,A5,B1,B2,B3,B4,B5 are simply lag 
variables. Can you help me removing this error please?
SabaA   B
739171876.1 -30023111.44
487266676   21283768.23
372851476.2 -40442678.43
63229603.27 10656220.9
42006490.16 -11533497.55
190745334.6 -5394116.27
172710138.6 -15091006.48
231059302.6 23568469.87
519602621.8 64131342.59
997358074.8 23623980.29
291864614.4 65303351.45
80844732.71 69354076.9
701170068.3 106386633.8
440463911.3 105165515.5
67256920.87 57943316.76
64101070.8  50209212.89
-71028831.0331292473.88
-197854142.532805225.46
-189290263.34638671.93
-520470164.7962640792.4
-471115277.3-1093666458
-955868238  -102261874.8
-1098715609 -101020121.9
-738546938.5-6916.12
-1085874990 -136045443.9
193157212.1 -2473692.63
-6269415.53 -28891931
199824564.8 5127403.1
302376261.5 6655585.13
-67851220.11-13741489.54
-370952947  -24219268.21
34404761.25 27283468.9
-428849252.4-85765593.88
-924463014  -112574045.5
-495270249.6-2965265.14
-668618574.5-39930551.16
-10436100.7790010638.89
-281751636.5-22157882.66
-385194083  43186980.6
104681563.1 40450660.38
-15283793.5260454998.18
-26567438.3752683189.8
-98612309.0825319905.01
21402708.99 44019777.51
-74846057.0545104511.78
-951203476.39858962.32
-338231274.186293283.74
-424023473.5102767273.6
20027128.13 185851266
-815545.8   163237321.2
46996041.85 194808435
134571135.3 122988858.9
-183703166  53086443.78
212728895.5 73301796.9
-197466304.2-11713239.02
-393762814.711580149.74
-343324235.6-13610112.45
-260888613.910047787.51
-759009960.6-151251490.8
-383721497  -151251490.8
__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Re: [R] Would you please help me to create a table in R?

2015-12-18 Thread Jim Lemon
Hi Marna,
Okay. I think I have a better idea now. I still don't quite get what
"output" represents, but I think the "table" you want is something like
what is produced by this code:

birdlevels<-c("0","SiteA","SiteB","SiteC")
raw.data<-data.frame(T2010=factor(rep("SiteA",11),levels=birdlevels),
 T2011=factor(c("0","SiteC","SiteA","0","SiteA","0","SiteA","0",
 "SiteB","SiteB","SiteB"),levels=birdlevels),
 T2012=factor(c("SiteA","SiteA","SiteA","0","SiteA","0","0",
 "SiteB","SiteB","0","SiteB"),levels=birdlevels))
birdcol<-c("gray","red","green","blue")
library(plotrix)
sizetree(raw.data,col=list(birdcol,birdcol,birdcol),
 main="Counts at release/capture sites")

and attached below. That is, I think what you want is a display of the
spatial transitions of the birds over time. If I'm correct, then maybe a
table like this will help:

20102011 2012
Site A   11 3  4
Site B 0 3  3
Site C 0 1  0
Unknown 0 4  4

Jim


On Sat, Dec 19, 2015 at 4:57 AM, Marna Wagley 
wrote:

> Dear Jim,
> I am sorry for not explaining the question in a clear way. I am trying to
> explain it, let's see how much clear I can make it.
>
> For the given example, (raw.data). Let's say, the 11 birds were marked and
> released at site A in a landscape (a combination of sites siteA, siteB,
> site C) in 2010.
>
> In 2011, we revisited at the sites (siteA, SiteB, SiteC), among the 11
> birds, we recaptured 3 individuals at Site A, 3 at Site B, 1 at site C but
> we could not see 4 individuals at any sites.
>
> Again in 2012, we revisited at the sites (SiteA, SiteB, SiteC), we again
> recaptured 2 individuals which was recaptured at Site A in 2011 but 1
> individual could not seen at any sites (in another words: in 2011 at the
> site A  we had recaptured 3 individuals, among them 2 were again seen at
> site A, but we could not see one individual in any sites).
>
> Similarly,we had recaptured 3 individuals in 2011 at the site B, but in
> 2012, among three individuals, one was again recaptured in Site B but 2
> individuals could not be seen at any sites.
>
> Likewise, for SiteC in 2012, we had recaptured 1 at that site (siteC), but
> in next year (2012), we could not see at any of the sites.
>
> Again, we had not seen 4 individuals in 2011, but later in 2012, among
> these 4 individuals, we recaptured one individual for each site  B and C,
> and 2 individuals could not be seen.
>
> I have given the example dataset. If it is really confusing and takes your
> lots of time, please forget it, I will try to do in Excel manually,but it
> is taking so much time and easily making errors. Your help will be very
> useful.
>
> Sincerely,
>
>
> raw.data<-structure(list(Time1 = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L,
> 1L, 1L, 1L, 1L), .Label = "SiteA", class = "factor"), Time2 =
> structure(c(1L, 4L, 2L, 1L, 2L, 1L, 2L, 1L, 3L, 3L, 3L), .Label = c("0",
> "SiteA",
> "SiteB", "SiteC"), class = "factor"), Time3 = structure(c(2L,
> 2L, 2L, 1L, 2L, 1L, 1L, 3L, 3L, 1L, 3L), .Label = c("0", "SiteA",
> "SiteB"), class = "factor")), .Names = c("Time1", "Time2", "Time3"
> ), class = "data.frame", row.names = c(NA, -11L))
>
> raw.data
>
> #
> table.format<-structure(list(Time1 = structure(c(NA, NA, NA, NA, NA, 1L,
> NA,NA, NA, NA, NA, NA, NA, NA, NA, NA), .Label = "Released A", class =
> "factor"),Time2 = structure(c(NA, NA, 2L, NA, NA, NA, 3L, NA, NA, NA,
> 4L, NA, NA, NA, 1L, NA), .Label = c("NotSeen", "Re-captured.at.A",
> "Re-captured.at.B", "Re-captured.at.C"), class = "factor"),
> Time3 = structure(c(2L, 3L, 4L, 1L, 2L, 3L, 4L, 1L, 2L, 3L,
> 4L, 1L, 2L, 3L, 4L, 1L), .Label = c("NotSeen", "Re-captured.at.A",
> "Re-captured.at.B", "Re-captured.at.C"), class = "factor")), .Names =
> c("Time1","Time2", "Time3"), class = "data.frame", row.names = c(NA, -16L
> ))
>
> table.format
>
> ###
> output<-structure(list(Time1 = c(NA, NA, NA, NA, NA, 11L, NA, NA, NA,
> NA, NA, NA, NA, NA, NA, NA), Time2 = c(NA, NA, 3L, NA, NA, NA,
> 3L, NA, NA, NA, 1L, NA, NA, NA, 4L, NA), Time3 = c(2L, NA, NA,
> 1L, NA, 2L, NA, 1L, 1L, NA, NA, NA, 1L, 1L, NA, 2L)), .Names = c("Time1",
> "Time2", "Time3"), class = "data.frame", row.names = c(NA, -16L
> ))
>
> output
>
> ##
> 
>
>
> On Thu, Dec 17, 2015 at 11:38 PM, Jim Lemon  wrote:
>
>> Hi Marna,
>> A bit hard to understand. If raw.data is a record of 11 individuals
>> released at site A at Time 1 and recaptured at either A or B or neither at
>> Time2 or Time3, it doesn't seem to bear any consistent relationship to the
>> numeric coding in table.format or the output at the bottom. Could you
>> explain what the correspondence between the tables is?
>>
>> Jim
>>
>>
>> On Fri, Dec 18, 2015 at 2:33 PM, Marna Wagley 
>> wrote:
>>
>>> Hi R users,
>>> I am struggling

Re: [R] Would you please help me to create a table in R?

2015-12-18 Thread S Ellison
> I want to get the table like "output". Any possibility to get it in R?

What do the rows represent in 'output'? Places? Times? Individuals?
What do the numbers in the table relate to? Individual bird identifier? Number 
of birds?



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

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


Re: [R] Cannot subset a specific mean from this function

2015-12-18 Thread David Winsemius

> On Dec 18, 2015, at 7:23 AM, Bradley Wolf  wrote:
> 
> Jim,
>  Thank you for your response.  I am not asking you for you to do my work.
> I am really new to programming (in any context) and really haven't gotten
> the grasp of the logic yet. I have used R before but in the context of R
> Commander and am trying this so I can be a more robust user.

Your question which you have not copied as requested by the posting guide is 
clearly part of a homework assignment for one of the online programming 
classes. I believe you were asked in the course introduction to submit 
questions to a web interface. Rhelp has a no homework policy.

-- 
David.

> 
> That being said, I wanted the last 53 file names read. The irony of my
> problem is, I can do the assignment if it was to get the mean of all the
> files (I am  reading 332 csv's).
> 
> Thanks,
> 
> Brad
> 
>   [[alternative HTML version deleted]]
> 
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

David Winsemius
Alameda, CA, USA

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


Re: [R] introduce axis break lattice plot multipanel

2015-12-18 Thread David Winsemius

> On Dec 18, 2015, at 12:32 PM, Luigi Marongiu  wrote:
> 
> Dear all,
> I am plotting some data using lattice's barchart. One of the counts I
> am plotting has a very large value with respect to the other variables
> and I would like to introduce a break in the axis to compensate for
> this 'anomaly' and give more breath to the other bars. In this example
> the high count is for the variable 'b' and I would like to introduce a
> break of 50-100 in the x axis.
> I have seen from the internet that the common approach is to stack
> together two figures but in my case I am using a multipanel plot and I
> think this way won't work for my plot.
> Is there a simple way to introduce a break in the axis of a multipanel
> lattice plot?

If there is, then it's not easy to find. I tried with `sos::findFn("axis break 
lattice")`.

There are base graphic broken axes offered in package:plotrix. If you are 
sticking with lattice, then I would suggest a logged y-axis. Or use an 
annotating up-arrow with a label where the ylim was restricted.

-- 
David.
> Thank you
> L
> 
> the example:
 
> A <- c('a','b','c','d','a','b','c','d',
> 'b','c','d','b','c','d')
> B <- c(1,1,1,1,1,1,1,1,1,1,1,
>  1,1,1)
> C <- c(0,0,0,0,1,1,1,1,0,0,0,
>  1,1,1)
> D <- c(4,120,7,23,4,24,3,12,7,1,
> 1,5,0,0)
> E <- c(0,0,0,0,0,0,0,0,1,1,1,
>  1,1,1)
> DF <- data.frame(A, B, C, D, E, stringsAsFactors = FALSE)
> library(lattice)
> barchart(
>A ~ D|E,
>DF,
>groups = C,
>stack = TRUE,
>main = "Comparison of test results",
>xlab = "Count",
>col = c("yellow", "orange"),
>par.settings = list(
>strip.background = list(col="light grey"),
>superpose.polygon=list(col= c("yellow", "orange"))
>),
>scales = list(
>alternating = FALSE
>),
>key = list(
>space="top",
>columns=2,
>text=list(c("Single infections", "Multiple infections"), col="black"),
>rectangles=list(col=c("yellow", "orange"))
>),
> )
> 
> __
> 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.

David Winsemius
Alameda, CA, USA

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


Re: [R] introduce axis break lattice plot multipanel

2015-12-18 Thread Bert Gunter
Bert Gunter

"The trouble with having an open mind is that people keep coming along
and sticking things into it."
-- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )


On Fri, Dec 18, 2015 at 12:32 PM, Luigi Marongiu
 wrote:
> Dear all,
> I am plotting some data using lattice's barchart. One of the counts I
> am plotting has a very large value with respect to the other variables
> and I would like to introduce a break in the axis to compensate for
> this 'anomaly' and give more breath to the other bars. In this example
> the high count is for the variable 'b' and I would like to introduce a
> break of 50-100 in the x axis.
> I have seen from the internet that the common approach is to stack
> together two figures but in my case I am using a multipanel plot and I
> think this way won't work for my plot.
> Is there a simple way to introduce a break in the axis of a multipanel
> lattice plot?

No. (Thank goodness -- it defeats the purpose of the display).
-- Bert

> Thank you
> L
>
> the example:

> A <- c('a','b','c','d','a','b','c','d',
> 'b','c','d','b','c','d')
> B <- c(1,1,1,1,1,1,1,1,1,1,1,
>   1,1,1)
> C <- c(0,0,0,0,1,1,1,1,0,0,0,
>   1,1,1)
> D <- c(4,120,7,23,4,24,3,12,7,1,
>  1,5,0,0)
> E <- c(0,0,0,0,0,0,0,0,1,1,1,
>   1,1,1)
> DF <- data.frame(A, B, C, D, E, stringsAsFactors = FALSE)
> library(lattice)
> barchart(
> A ~ D|E,
> DF,
> groups = C,
> stack = TRUE,
> main = "Comparison of test results",
> xlab = "Count",
> col = c("yellow", "orange"),
> par.settings = list(
> strip.background = list(col="light grey"),
> superpose.polygon=list(col= c("yellow", "orange"))
> ),
> scales = list(
> alternating = FALSE
> ),
> key = list(
> space="top",
> columns=2,
> text=list(c("Single infections", "Multiple infections"), col="black"),
> rectangles=list(col=c("yellow", "orange"))
> ),
> )
>
> __
> 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-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] lattice strip.custom in plot for multiple groups

2015-12-18 Thread David Winsemius

> On Dec 18, 2015, at 12:22 PM, Luigi Marongiu  wrote:
> 
> Dear all,
> I am plotting the count of some data subdivided in different groups.
> the variables i am using are:
> A = tests performed
> B = positive/negative results (but in this case the results are all
> positive, so all 1)
> C = multiple (1) or single (0) test applied
> D = count of instances
> E = cases (1) or controls (0)
> 
> the plot looks the way I need and it is created with lattice's
> barchart. However the strip should indicate "cases"/"controls" and
> instead only shows "E"/"E" so I think I messed somewhere.
> Would you know what did I missed?
> Thank you
> L
> 
> The example:
 
> A <- c('a','b','c','d','a','b','c','d',
> 'b','c','d','b','c','d')
> B <- c(1,1,1,1,1,1,1,1,1,1,1,
>  1,1,1)
> C <- c(0,0,0,0,1,1,1,1,0,0,0,
>  1,1,1)
> D <- c(4,120,7,23,4,24,3,12,7,1,
> 1,5,0,0)
> E <- c(0,0,0,0,0,0,0,0,1,1,1,
>  1,1,1)
> DF <- data.frame(A, B, C, D, E, stringsAsFactors = FALSE)
> library(lattice)
> barchart(
>A ~ D|E,
>DF,
>groups = C,
>stack = TRUE,
>main = "Comparison of test results",
>xlab = "Count",
>col = c("yellow", "orange"),
>par.settings = list(
>strip.background = list(col="light grey"),
>superpose.polygon=list(col= c("yellow", "orange"))
>),
>scales = list(
>alternating = FALSE
>),
>key = list(
>space="top",
>columns=2,
>text=list(c("Single infections", "Multiple infections"), col="black"),
>rectangles=list(col=c("yellow", "orange"))
>),
>strip = strip.custom(factor.levels = c("Cases","Controls"),

Also need to set the logical flag strip.levels to TRUE.

strip = strip.custom(factor.levels = c("Cases","Controls"), 
  strip.levels=TRUE,
par.strip.text = list(cex = 1)

If you do not want the variable name "E" displayed then set the correct flag to 
FALSE. See: 

?strip.custom

-- 
David


> par.strip.text = list(cex = 1)
>)
> )
> 
> __
> 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.

David Winsemius
Alameda, CA, USA

__
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] introduce axis break lattice plot multipanel

2015-12-18 Thread Luigi Marongiu
Dear all,
I am plotting some data using lattice's barchart. One of the counts I
am plotting has a very large value with respect to the other variables
and I would like to introduce a break in the axis to compensate for
this 'anomaly' and give more breath to the other bars. In this example
the high count is for the variable 'b' and I would like to introduce a
break of 50-100 in the x axis.
I have seen from the internet that the common approach is to stack
together two figures but in my case I am using a multipanel plot and I
think this way won't work for my plot.
Is there a simple way to introduce a break in the axis of a multipanel
lattice plot?
Thank you
L

the example:
>>>
A <- c('a','b','c','d','a','b','c','d',
'b','c','d','b','c','d')
B <- c(1,1,1,1,1,1,1,1,1,1,1,
  1,1,1)
C <- c(0,0,0,0,1,1,1,1,0,0,0,
  1,1,1)
D <- c(4,120,7,23,4,24,3,12,7,1,
 1,5,0,0)
E <- c(0,0,0,0,0,0,0,0,1,1,1,
  1,1,1)
DF <- data.frame(A, B, C, D, E, stringsAsFactors = FALSE)
library(lattice)
barchart(
A ~ D|E,
DF,
groups = C,
stack = TRUE,
main = "Comparison of test results",
xlab = "Count",
col = c("yellow", "orange"),
par.settings = list(
strip.background = list(col="light grey"),
superpose.polygon=list(col= c("yellow", "orange"))
),
scales = list(
alternating = FALSE
),
key = list(
space="top",
columns=2,
text=list(c("Single infections", "Multiple infections"), col="black"),
rectangles=list(col=c("yellow", "orange"))
),
)

__
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] lattice strip.custom in plot for multiple groups

2015-12-18 Thread Luigi Marongiu
Dear all,
I am plotting the count of some data subdivided in different groups.
the variables i am using are:
A = tests performed
B = positive/negative results (but in this case the results are all
positive, so all 1)
C = multiple (1) or single (0) test applied
D = count of instances
E = cases (1) or controls (0)

the plot looks the way I need and it is created with lattice's
barchart. However the strip should indicate "cases"/"controls" and
instead only shows "E"/"E" so I think I messed somewhere.
Would you know what did I missed?
Thank you
L

The example:
>>>
A <- c('a','b','c','d','a','b','c','d',
'b','c','d','b','c','d')
B <- c(1,1,1,1,1,1,1,1,1,1,1,
  1,1,1)
C <- c(0,0,0,0,1,1,1,1,0,0,0,
  1,1,1)
D <- c(4,120,7,23,4,24,3,12,7,1,
 1,5,0,0)
E <- c(0,0,0,0,0,0,0,0,1,1,1,
  1,1,1)
DF <- data.frame(A, B, C, D, E, stringsAsFactors = FALSE)
library(lattice)
barchart(
A ~ D|E,
DF,
groups = C,
stack = TRUE,
main = "Comparison of test results",
xlab = "Count",
col = c("yellow", "orange"),
par.settings = list(
strip.background = list(col="light grey"),
superpose.polygon=list(col= c("yellow", "orange"))
),
scales = list(
alternating = FALSE
),
key = list(
space="top",
columns=2,
text=list(c("Single infections", "Multiple infections"), col="black"),
rectangles=list(col=c("yellow", "orange"))
),
strip = strip.custom(factor.levels = c("Cases","Controls"),
 par.strip.text = list(cex = 1)
)
)

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


Re: [R] multidimensional splines

2015-12-18 Thread Bert Gunter
1. I do not think what the OP requested exists, at least as I
understand her  -- how would one define the "surfaces" where the
piecewise multidimensional polynomials are "joined"? (only 1-d space
is ordered)

2. But, as she has already been told, there are various ways of doing
multivariate smoothing splines. The mars() function in packages mda
and earth is another. Apparently the one in earth adds "extra
features" to the one in mda.

Cheers,
Bert


Bert Gunter

"The trouble with having an open mind is that people keep coming along
and sticking things into it."
-- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )


On Fri, Dec 18, 2015 at 10:52 AM, David Winsemius
 wrote:
>
>> On Dec 18, 2015, at 7:42 AM,  
>>  wrote:
>>
>> Dear all,
>>
>> I am looking for a package which performs splining in more than one 
>> dimension with polynomials of order>1, exactly as the package "splines" does 
>> in 1D.
>> For the moment I was only able to find the package "polspline", whose 
>> function "polymars" performs just piecewise linear splines, so not exactly 
>> what I'm looking for.
>> Do you know of anything else?
>
> I have pleasing experience with the `rcs` function from package 'rms'. One 
> can build such multidimensional splines with the formula interface using the 
> "*" crossing-operator. It is limited to only piecewise cubic splines. You can 
> specify the knots or let them be optimized by the regression function. It's 
> effective use does require that you learn the requirements of the surrounding 
> helper functions and data description methods supplied by the rms/Hmisc 
> packages.
>
>
> --
> David
>
>>
>
> David Winsemius
> Alameda, CA, USA
>
> __
> 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-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] multidimensional splines

2015-12-18 Thread David Winsemius

> On Dec 18, 2015, at 7:42 AM,  
>  wrote:
> 
> Dear all,
> 
> I am looking for a package which performs splining in more than one dimension 
> with polynomials of order>1, exactly as the package "splines" does in 1D.
> For the moment I was only able to find the package "polspline", whose 
> function "polymars" performs just piecewise linear splines, so not exactly 
> what I'm looking for.
> Do you know of anything else?

I have pleasing experience with the `rcs` function from package 'rms'. One can 
build such multidimensional splines with the formula interface using the "*" 
crossing-operator. It is limited to only piecewise cubic splines. You can 
specify the knots or let them be optimized by the regression function. It's 
effective use does require that you learn the requirements of the surrounding 
helper functions and data description methods supplied by the rms/Hmisc 
packages.

 
-- 
David

> 

David Winsemius
Alameda, CA, USA

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


Re: [R] Gather columns based on multiple columns using tidyr

2015-12-18 Thread fahad.usman
Hi David,

I did something similar:

years <- scotland_weather%>%
select(starts_with("Year"))%>%
gather(year.col,year)%>%
select(-year.col)

months <- scotland_weather[seq(1, 24, 2)]%>%
  gather(month,rainfall_mm)


scotland_weather <- cbind(years,months)

However, would have liked more sophisticated solution using tidyr

Regards,

Fahad Usman
Network Engineering | CIO | Openreach 
Web: www.openreach.co.uk

-Original Message-
From: David L Carlson [mailto:dcarl...@tamu.edu] 
Sent: 17 December 2015 20:02
To: Ista Zahn; Usman,F,Fahad,BVG1C3 R
Cc: r-help@r-project.org
Subject: RE: [R] Gather columns based on multiple columns using tidyr

Here's another approach, but it doesn't use tidy or dplyr:

> Rain.col <- seq(1, 24, by=2)
> Year.col <- seq(2, 24, by =2)
> Scotland.lst <- lapply(1:12, function(x) data.frame(Year =
+  scotland_weather[ , Year.col[x]], month = month.abb[x],
+   rainfall_mm = scotland_weather[ , Rain.col[x]]))
> Scotland.df <- do.call(rbind, Scotland.lst)
> head(Scotland.df)
  Year month rainfall_mm
1 1993   Jan   293.8
2 1928   Jan   292.2
3 2008   Jan   275.6
4 2015   Jan   252.3
5 1974   Jan   246.2
6 1975   Jan   245.0
> tail(Scotland.df)
   Year month rainfall_mm
67 2013   Dec   300.7
68 1986   Dec   268.5
69 1929   Dec   267.2
70 2011   Dec   265.4
71 2006   Dec   264.0
72 1912   Dec   261.0

-
David L Carlson
Department of Anthropology
Texas A&M University
College Station, TX 77840-4352


-Original Message-
From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Ista Zahn
Sent: Thursday, December 17, 2015 1:49 PM
To: fahad.us...@openreach.co.uk
Cc: r-help@r-project.org
Subject: Re: [R] Gather columns based on multiple columns using tidyr

Hi Fahad,

Easier than what? You didn't tell us what you tried, nor why you were unhappy 
with it. I'm only passingly familiar with tidyr, but I came up with


library(tidyr)
library(dplyr)

read.table("scotland_rainfall.txt", skip = 7, header=TRUE, fill = TRUE) %>%
  select(-WIN, -SPR, -SUM, -AUT, -ANN) %>%
  gather(junk1, year, starts_with("Year")) %>%
  gather(month, rainfall_mm, one_of(toupper(month.abb))) %>%
  arrange(year, month) %>%
  select(-junk1) -> scotland_weather

Best,
Ista

On Thu, Dec 17, 2015 at 10:24 AM,   wrote:
> Hi,
>
> Sorry for this direct approach but I am stuck with a stupid data that I would 
> like to reformat.
>
> The datafile is location at: fileURL <- 
> http://www.metoffice.gov.uk/pub/data/weather/uk/climate/datasets/Rainf
> all/ranked/Scotland.txt
>
> You can read the data by:
>
> if(!file.exists("scotland_rainfall.txt")){
> #this will download the file in the current working directory
> download.file(fileURL,destfile = "scotland_rainfall.txt")
> dateDownload <- Sys.Date() #15-12-2015
>
> }
>
>> head(scotland_weather)
> Jan Year.1   Feb Year.2   Mar Year.3   Apr Year.4   May Year.5   Jun 
> Year.6   Jul Year.7   Aug Year.8   Sep Year.9   Oct Year.10   Nov Year.11   
> Dec Year.12
> 1 293.8   1993 278.1   1990 238.5   1994 191.1   1947 191.4   2011 155.0   
> 1938 185.6   1940 216.5   1985 267.6   1950 258.11935 262.02009 300.7 
>2013
> 2 292.2   1928 258.8   1997 233.4   1990 149.0   1910 168.7   1986 137.9   
> 2002 181.4   1988 211.9   1992 221.2   1981 254.01954 245.32015 268.5 
>1986
> 3 275.6   2008 244.7   2002 201.3   1992 146.8   1934 155.9   1925 137.8   
> 1948 170.1   1939 202.3   2009 193.9   1982 248.82014 244.81938 267.2 
>1929
> 4 252.3   2015 227.9   1989 200.2   1967 142.1   1949 149.5   2015 137.7   
> 1931 165.8   2010 191.4   1962 189.7   2011 247.71938 242.22006 265.4 
>2011
> 5 246.2   1974 224.9   2014 180.2   1979 133.5   1950 137.4   2003 135.0   
> 1966 162.9   1956 190.3   2014 189.7   1927 242.31983 231.31917 264.0 
>2006
> 6 245.0   1975 195.6   1995 180.0   1989 132.9   1932 129.7   2007 131.7   
> 2004 159.9   1985 189.1   2004 189.6   1985 240.92001 229.91981 261.0 
>1912
>
>
>> tail(scotland_weather)
>
>  Jan Year.1  Feb Year.2  Mar Year.3  Apr Year.4  May Year.5  Jun 
> Year.6  Jul Year.7  Aug Year.8  Sep Year.9  Oct Year.10  Nov Year.11  
> Dec Year.12
>
> 101 71.2   1987 34.4   1947 50.9   1918 44.6   1982 34.1   1978 38.8   1940 
> 49.2   2005 46.2   2003 50.7   2015 76.51973 57.11942 62.72010
>
> 102 57.9   1997 33.7   1917 44.4   1953 38.5   1918 32.1   1919 36.9   1932 
> 47.8   1989 46.1   1983 49.6   1959 74.61922 54.91958 59.91963
>
> 103 57.9   1941 31.8   1963 39.7   1924 31.7   1981 28.8   1994 33.2   1921 
> 45.8   1983 37.6   1955 48.5   1910 69.91972 53.91925 55.01995
>
> 104 57.6   1940 24.2   1930 38.8   1969 29.0   1938 26.1   2008 32.8   1925 
> 39.7   1919 33.0   1995 40.0   1933 62.91914 53.61983 43.41927
>
> 105 51.9   19

[R] Missing data in RMark

2015-12-18 Thread Caroline Glidden
I am currently trying to run a Known Fates Model in RMark with individual time 
varying covariates. However, for animals that died early in the study or were 
not captured at one capture period I, of course, do not have data for all of 
their time points. I thought that NAs would not matter when the LD capture 
history was 00, and therefore, having no data during the time points the animal 
was unable to be sampled would not be a big deal. However, RMark cannot fit my 
model due to the NAs. I was wondering how I should code the individual time 
varying covariates for time points at which the animal has no data due to it 
not being captured or due to it dying?
[[alternative HTML version deleted]]

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


Re: [R] Would you please help me to create a table in R?

2015-12-18 Thread Marna Wagley
Dear Jim,
I am sorry for not explaining the question in a clear way. I am trying to
explain it, let's see how much clear I can make it.

For the given example, (raw.data). Let's say, the 11 birds were marked and
released at site A in a landscape (a combination of sites siteA, siteB,
site C) in 2010.

In 2011, we revisited at the sites (siteA, SiteB, SiteC), among the 11
birds, we recaptured 3 individuals at Site A, 3 at Site B, 1 at site C but
we could not see 4 individuals at any sites.

Again in 2012, we revisited at the sites (SiteA, SiteB, SiteC), we again
recaptured 2 individuals which was recaptured at Site A in 2011 but 1
individual could not seen at any sites (in another words: in 2011 at the
site A  we had recaptured 3 individuals, among them 2 were again seen at
site A, but we could not see one individual in any sites).

Similarly,we had recaptured 3 individuals in 2011 at the site B, but in
2012, among three individuals, one was again recaptured in Site B but 2
individuals could not be seen at any sites.

Likewise, for SiteC in 2012, we had recaptured 1 at that site (siteC), but
in next year (2012), we could not see at any of the sites.

Again, we had not seen 4 individuals in 2011, but later in 2012, among
these 4 individuals, we recaptured one individual for each site  B and C,
and 2 individuals could not be seen.

I have given the example dataset. If it is really confusing and takes your
lots of time, please forget it, I will try to do in Excel manually,but it
is taking so much time and easily making errors. Your help will be very
useful.

Sincerely,


raw.data<-structure(list(Time1 = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L), .Label = "SiteA", class = "factor"), Time2 =
structure(c(1L, 4L, 2L, 1L, 2L, 1L, 2L, 1L, 3L, 3L, 3L), .Label = c("0",
"SiteA",
"SiteB", "SiteC"), class = "factor"), Time3 = structure(c(2L,
2L, 2L, 1L, 2L, 1L, 1L, 3L, 3L, 1L, 3L), .Label = c("0", "SiteA",
"SiteB"), class = "factor")), .Names = c("Time1", "Time2", "Time3"
), class = "data.frame", row.names = c(NA, -11L))

raw.data

#
table.format<-structure(list(Time1 = structure(c(NA, NA, NA, NA, NA, 1L,
NA,NA, NA, NA, NA, NA, NA, NA, NA, NA), .Label = "Released A", class =
"factor"),Time2 = structure(c(NA, NA, 2L, NA, NA, NA, 3L, NA, NA, NA,
4L, NA, NA, NA, 1L, NA), .Label = c("NotSeen", "Re-captured.at.A",
"Re-captured.at.B", "Re-captured.at.C"), class = "factor"),
Time3 = structure(c(2L, 3L, 4L, 1L, 2L, 3L, 4L, 1L, 2L, 3L,
4L, 1L, 2L, 3L, 4L, 1L), .Label = c("NotSeen", "Re-captured.at.A",
"Re-captured.at.B", "Re-captured.at.C"), class = "factor")), .Names =
c("Time1","Time2", "Time3"), class = "data.frame", row.names = c(NA, -16L
))

table.format

###
output<-structure(list(Time1 = c(NA, NA, NA, NA, NA, 11L, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA), Time2 = c(NA, NA, 3L, NA, NA, NA,
3L, NA, NA, NA, 1L, NA, NA, NA, 4L, NA), Time3 = c(2L, NA, NA,
1L, NA, 2L, NA, 1L, 1L, NA, NA, NA, 1L, 1L, NA, 2L)), .Names = c("Time1",
"Time2", "Time3"), class = "data.frame", row.names = c(NA, -16L
))

output

##



On Thu, Dec 17, 2015 at 11:38 PM, Jim Lemon  wrote:

> Hi Marna,
> A bit hard to understand. If raw.data is a record of 11 individuals
> released at site A at Time 1 and recaptured at either A or B or neither at
> Time2 or Time3, it doesn't seem to bear any consistent relationship to the
> numeric coding in table.format or the output at the bottom. Could you
> explain what the correspondence between the tables is?
>
> Jim
>
>
> On Fri, Dec 18, 2015 at 2:33 PM, Marna Wagley 
> wrote:
>
>> Hi R users,
>> I am struggling to create a table in R. I did in Excel but I have a lots
>> of
>> data and thought it might be easy in  R  but  I am new in R. How to get
>> "output table" for this example data?
>>
>> This is an example.
>>
>> #
>> raw.data<-structure(list(Time1 = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L,
>> 1L, 1L, 1L, 1L), .Label = "SiteA", class = "factor"), Time2 =
>> structure(c(1L,
>> 4L, 2L, 1L, 2L, 1L, 2L, 1L, 3L, 3L, 3L), .Label = c("0", "SiteA",
>> "SiteB", "SiteC"), class = "factor"), Time3 = structure(c(2L,
>> 2L, 2L, 1L, 2L, 1L, 1L, 3L, 3L, 1L, 3L), .Label = c("0", "SiteA",
>> "SiteB"), class = "factor")), .Names = c("Time1", "Time2", "Time3"
>> ), class = "data.frame", row.names = c(NA, -11L))
>>
>> raw.data
>>
>> #
>> table.format<-structure(list(Time1 = structure(c(NA, NA, NA, NA, NA, 1L,
>> NA,
>> NA, NA, NA, NA, NA, NA, NA, NA, NA), .Label = "Released A", class =
>> "factor"),
>> Time2 = structure(c(NA, NA, 2L, NA, NA, NA, 3L, NA, NA, NA,
>> 4L, NA, NA, NA, 1L, NA), .Label = c("Dead", "Re-captured.at.A",
>> "Re-captured.at.B", "Re-captured.at.C"), class = "factor"),
>> Time3 = structure(c(2L, 3L, 4L, 1L, 2L, 3L, 4L, 1L, 2L, 3L,
>> 4L, 1L, 2L, 3L, 4L, 1L), .Label = c("Dead", "Re-captured.at.A",
>> "Re-captured.at.B", "Re-captured.at.C"), class = 

Re: [R] Converting from Continuous 2D Points to Continuous 2D Vectors

2015-12-18 Thread David L Carlson
Look at the CRAN Task View: "Handling and Analyzing Spatio-Temporal Data," 
particularly the section on "Moving objects, trajectories." The tools you need 
are probably already available.

https://cran.r-project.org/web/views/SpatioTemporal.html

-
David L Carlson
Department of Anthropology
Texas A&M University
College Station, TX 77840-4352

-Original Message-
From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Sidoti, 
Salvatore A.
Sent: Thursday, December 17, 2015 3:25 PM
To: r-help@r-project.org
Subject: [R] Converting from Continuous 2D Points to Continuous 2D Vectors

Greetings!

I have a fairly large dataframe (df) with pathing information in the form of 
continuous x,y coordinates:

df$x
df$y

With these data, I would like to:
1. Calculate a set of continuous vectors
2. Determine the angle between each of these vectors (in degrees)
3. Count the number of angles in the dataframe that meet a certain threshold 
(i.e. <90°)

Here's what I've come up with so far:

### Function that calculates the angle between two vectors in 2D space:

angle <- function(x,y){ # x and y are vectors
  dot.prod <- x%*%y 
  norm.x <- norm(x,type="2")
  norm.y <- norm(y,type="2")
  theta <- acos(dot.prod / (norm.x * norm.y))
  (180*as.numeric(theta))/pi # returns the angle in degrees
}

### Test the function:
x <- as.matrix(c(2,1))
y <- as.matrix(c(1,2))
angle(t(x),y)
[1] 36.8699

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


Re: [R] multidimensional splines

2015-12-18 Thread William Dunlap via R-help
Have you considered thin plate splines, which are a natural
extension of one-dimensional splines to higher dimensional
spaces, but are not piecewise polynomials?  The Tps function
in the fields package will fit a thin plate spline to irregularly
spaced data.


Bill Dunlap
TIBCO Software
wdunlap tibco.com

On Fri, Dec 18, 2015 at 7:42 AM,  wrote:

> Dear all,
>
> I am looking for a package which performs splining in more than one
> dimension with polynomials of order>1, exactly as the package "splines"
> does in 1D.
> For the moment I was only able to find the package "polspline", whose
> function "polymars" performs just piecewise linear splines, so not exactly
> what I'm looking for.
> Do you know of anything else?
>
> Thanks a lot!
>
> Check out our new brand campaign: www.ubs.com/together
>
> Visit our website at http://www.ubs.com
>
> This message contains confidential information and is ...{{dropped:13}}

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


Re: [R] Cannot subset a specific mean from this function

2015-12-18 Thread Bradley Wolf
Jim,
  Thank you for your response.  I am not asking you for you to do my work.
I am really new to programming (in any context) and really haven't gotten
the grasp of the logic yet. I have used R before but in the context of R
Commander and am trying this so I can be a more robust user.

That being said, I wanted the last 53 file names read. The irony of my
problem is, I can do the assignment if it was to get the mean of all the
files (I am  reading 332 csv's).

Thanks,

Brad

[[alternative HTML version deleted]]

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


[R] multidimensional splines

2015-12-18 Thread francesca.mancini
Dear all,

I am looking for a package which performs splining in more than one dimension 
with polynomials of order>1, exactly as the package "splines" does in 1D.
For the moment I was only able to find the package "polspline", whose function 
"polymars" performs just piecewise linear splines, so not exactly what I'm 
looking for.
Do you know of anything else?

Thanks a lot!
Check out our new brand campaign: www.ubs.com/together

Visit our website at http://www.ubs.com

This message contains confidential information and is in...{{dropped:21}}
__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Re: [R] Gather columns based on multiple columns using tidyr

2015-12-18 Thread fahad.usman
Dear Ista,

Many thanks for your reply. 

Your tidyr solution didn’t work:

> dput(head(scotland_weather,6))
structure(list(Jan = c(293.8, 292.2, 275.6, 252.3, 246.2, 245
), Year.1 = c(1993L, 1928L, 2008L, 2015L, 1974L, 1975L), Feb = c(278.1, 
258.8, 244.7, 227.9, 224.9, 195.6), Year.2 = c(1990L, 1997L, 
2002L, 1989L, 2014L, 1995L), Mar = c(238.5, 233.4, 201.3, 200.2, 
180.2, 180), Year.3 = c(1994L, 1990L, 1992L, 1967L, 1979L, 1989L
), Apr = c(191.1, 149, 146.8, 142.1, 133.5, 132.9), Year.4 = c(1947L, 
1910L, 1934L, 1949L, 1950L, 1932L), May = c(191.4, 168.7, 155.9, 
149.5, 137.4, 129.7), Year.5 = c(2011L, 1986L, 1925L, 2015L, 
2003L, 2007L), Jun = c(155, 137.9, 137.8, 137.7, 135, 131.7), 
Year.6 = c(1938L, 2002L, 1948L, 1931L, 1966L, 2004L), Jul = c(185.6, 
181.4, 170.1, 165.8, 162.9, 159.9), Year.7 = c(1940L, 1988L, 
1939L, 2010L, 1956L, 1985L), Aug = c(216.5, 211.9, 202.3, 
191.4, 190.3, 189.1), Year.8 = c(1985L, 1992L, 2009L, 1962L, 
2014L, 2004L), Sep = c(267.6, 221.2, 193.9, 189.7, 189.7, 
189.6), Year.9 = c(1950L, 1981L, 1982L, 2011L, 1927L, 1985L
), Oct = c(258.1, 254, 248.8, 247.7, 242.3, 240.9), Year.10 = c(1935L, 
1954L, 2014L, 1938L, 1983L, 2001L), Nov = c(262, 245.3, 244.8, 
242.2, 231.3, 229.9), Year.11 = c(2009L, 2015L, 1938L, 2006L, 
1917L, 1981L), Dec = c(300.7, 268.5, 267.2, 265.4, 264, 261
), Year.12 = c(2013L, 1986L, 1929L, 2011L, 2006L, 1912L)), .Names = 
c("Jan", 
"Year.1", "Feb", "Year.2", "Mar", "Year.3", "Apr", "Year.4", 
"May", "Year.5", "Jun", "Year.6", "Jul", "Year.7", "Aug", "Year.8", 
"Sep", "Year.9", "Oct", "Year.10", "Nov", "Year.11", "Dec", "Year.12"
), row.names = c(NA, 6L), class = "data.frame")

> scotland_weather%>%
+ gather(junk1, year, starts_with("Year")) %>%
+ gather(month, rainfall_mm, one_of(toupper(month.abb)))%>%
+ arrange(year, month) %>%
+ select(-junk1)
Error: cannot arrange column of class 'function'
In addition: Warning message:
attributes are not identical across measure variables; they will be dropped
==

I tried:

data.frame(month= names(scotland_weather)[!grepl('Year', 
names(scotland_weather))], 
   year=c(t(scotland_weather[c(FALSE,TRUE)])), 
   rainfall_mm= c(t(scotland_weather[c(TRUE,FALSE)])))

Which works fine...but I am looking for a tidyr solution.

Regards,


Fahad Usman
Network Engineering | CIO | Openreach 
Web: www.openreach.co.uk

-Original Message-
From: Ista Zahn [mailto:istaz...@gmail.com] 
Sent: 17 December 2015 19:49
To: Usman,F,Fahad,BVG1C3 R
Cc: r-help@r-project.org
Subject: Re: [R] Gather columns based on multiple columns using tidyr

Hi Fahad,

Easier than what? You didn't tell us what you tried, nor why you were unhappy 
with it. I'm only passingly familiar with tidyr, but I came up with


library(tidyr)
library(dplyr)

read.table("scotland_rainfall.txt", skip = 7, header=TRUE, fill = TRUE) %>%
  select(-WIN, -SPR, -SUM, -AUT, -ANN) %>%
  gather(junk1, year, starts_with("Year")) %>%
  gather(month, rainfall_mm, one_of(toupper(month.abb))) %>%
  arrange(year, month) %>%
  select(-junk1) -> scotland_weather

Best,
Ista

On Thu, Dec 17, 2015 at 10:24 AM,   wrote:
> Hi,
>
> Sorry for this direct approach but I am stuck with a stupid data that I would 
> like to reformat.
>
> The datafile is location at: fileURL <- 
> http://www.metoffice.gov.uk/pub/data/weather/uk/climate/datasets/Rainf
> all/ranked/Scotland.txt
>
> You can read the data by:
>
> if(!file.exists("scotland_rainfall.txt")){
> #this will download the file in the current working directory
> download.file(fileURL,destfile = "scotland_rainfall.txt")
> dateDownload <- Sys.Date() #15-12-2015
>
> }
>
>> head(scotland_weather)
> Jan Year.1   Feb Year.2   Mar Year.3   Apr Year.4   May Year.5   Jun 
> Year.6   Jul Year.7   Aug Year.8   Sep Year.9   Oct Year.10   Nov Year.11   
> Dec Year.12
> 1 293.8   1993 278.1   1990 238.5   1994 191.1   1947 191.4   2011 155.0   
> 1938 185.6   1940 216.5   1985 267.6   1950 258.11935 262.02009 300.7 
>2013
> 2 292.2   1928 258.8   1997 233.4   1990 149.0   1910 168.7   1986 137.9   
> 2002 181.4   1988 211.9   1992 221.2   1981 254.01954 245.32015 268.5 
>1986
> 3 275.6   2008 244.7   2002 201.3   1992 146.8   1934 155.9   1925 137.8   
> 1948 170.1   1939 202.3   2009 193.9   1982 248.82014 244.81938 267.2 
>1929
> 4 252.3   2015 227.9   1989 200.2   1967 142.1   1949 149.5   2015 137.7   
> 1931 165.8   2010 191.4   1962 189.7   2011 247.71938 242.22006 265.4 
>2011
> 5 246.2   1974 224.9   2014 180.2   1979 133.5   1950 137.4   2003 135.0   
> 1966 162.9   1956 190.3   2014 189.7   1927 242.31983 231.31917 264.0 
>2006
> 6 245.0   1975 195.6   1995 180.0   1989 132.9

Re: [R] Numerical differentiation of a vector of values

2015-12-18 Thread William Dunlap via R-help
You can fit a spline to the points and evaluate the derivative
of the fitted spline where you want.  The built-in splines package
has functions for this, as do other packages on CRAN.

Bill Dunlap
TIBCO Software
wdunlap tibco.com

On Fri, Dec 18, 2015 at 1:09 AM, BARLAS Marios 247554 
wrote:

> Hi everyone,
>
> I have sets of experimental values representing I-V curves. I want to get
> the derivative of such numerical data but in r there doesn' seem to be a
> premade function. I can write something of my own, but I was wondering if
> there is a standard package out there?
>
> Thanks in advance!
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

[[alternative HTML version deleted]]

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


Re: [R] paneling spplot and hist

2015-12-18 Thread Jannes Münchow

Hi Pai,

there are at least two solutions two your problem.

The first solution makes use of R's base graphics instead of using the 
lattice-based spplot function:


library("sp")
library("RColorBrewers")
library("classInt")


# example more or less copied from the Applied Spatial Data Analysis 
with R book


# load the meuse dataset
data(meuse)
# use the xy-columns to transform the data.frame into a
# SpatialPointsDataFrame (SPDF)
coordinates(meuse) <-~ x + y
# specify color palette we are going to use
pal <- RColorBrewer::brewer.pal(5, name = "Blues")
# find fisher class intervals using the fisher-algorithm
q5 <- classIntervals(meuse$zinc, n = 5, style = "fisher")
# find the colors for each point
q5_col <- findColours(q5, pal)

# set up a plot window with one row and two columns (2 panels)
par(mfrow = c(1, 2))
# plot the SPDF into the first panel
plot(meuse, pch = 16, col = q5_col)
# add a legend
legend("topleft", fill = attr(q5Colours, "palette"),
   legend = names(attr(q5Colours, "table")), bty = "n", cex = 0.5)
# plot a histogram into the second panel
hist(meuse@data$copper, main = "Histogram", xlab = "zinc")

The second solution uses the packages lattice, grid and sp.

# using sp, lattice and grid
library("grid")
library("lattice")
grid.newpage()
# set up a plot window with one row and two columns (2 panels)
pushViewport(viewport(layout = grid.layout(1, 2)))
vp1 <- viewport(x = 0, y = 0,
height = 1, width = 0.5,
just = c("left", "bottom"),
name = "left",
layout = grid.layout(nrow = 1, ncol = 2))
pushViewport(vp1)
# plot the SPDF into the first panel
p <- spplot(meuse, "zinc")
print(p, newpage = FALSE)
upViewport(1)
vp2 <- viewport(x = 1, y = 0,
height = 1, width = 0.5,
just = c("right", "bottom"),
name = "right")
pushViewport(vp2)
# plot a lattice histogram into the second panel
print(histogram(meuse@data$copper, main = ""), newpage = FALSE)
upViewport(1)


For more information on the grid package and how to use it with spplot, 
you might want to read the package documentation and this blog 
http://teachpress.environmentalinformatics-marburg.de/2013/06/plotting-multiple-plots-on-one-page-with-the-grid-package-3/


Hope this helps,

Jannes


Dec 14, 2015; 8:20pm Debasish Pai Mazumder 
 
Debasish Pai Mazumder 
 
paneling spplot and hist


Hi all,

I am new in R. I am trying to panel spplot and hist.

spplot(hspdf, "CDP", col = "white", col.regions = blue2red(20), sp.layout =
list(l2), at = seq(1,10,1), colorkey = list(space = "bottom", labels =
list(labels = paste(seq(1,10,1)), cex = 1.5)), sub = list("CDP", cex = 1.5,
font = 2))

hist(cdp.obsc, col="grey", border="grey", main="CDP", probability=T)
lines(c.breaks, obs.cdp.d, col="blue")
lines(c.breaks, obs.cdp.e, col="red")


I have tried with par(mfrow=c(2,1))and layout(matrix, both don't work.

Any advice?

with regards
-Pai

[[alternative HTML version deleted]]

__
[hidden email] 
 
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-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Numerical differentiation of a vector of values

2015-12-18 Thread Jeff Newmiller
Did you really fail to type "R numeric derivative" into Google, or did you do 
it and then not notice the built in numericDeriv function or the contributed 
numderiv package?

-- 
Sent from my phone. Please excuse my brevity.

On December 18, 2015 1:09:06 AM PST, BARLAS Marios 247554 
 wrote:
>Hi everyone,
>
>I have sets of experimental values representing I-V curves. I want to
>get the derivative of such numerical data but in r there doesn' seem to
>be a premade function. I can write something of my own, but I was
>wondering if there is a standard package out there?
>
>Thanks in advance!
>
>__
>R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>https://stat.ethz.ch/mailman/listinfo/r-help
>PLEASE do read the posting guide
>http://www.R-project.org/posting-guide.html
>and provide commented, minimal, self-contained, reproducible code.

[[alternative HTML version deleted]]

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


Re: [R] Changing X axis values

2015-12-18 Thread Amelia Marsh
Dear Sir
Thanks a lot for your great help. I had tried the argument by = 1000, but 
wasn't aware of "seq". Thanks again.
With regards
Amelia 

On Friday, 18 December 2015 5:00 PM, Jim Lemon  wrote:
 

 Hi Amelia,The usual way is:
plot(...,xaxt="n")axis(1,at=seq(0,18000,by=1000)
However, you will get overlapping labels unless you use a small font or a large 
graphics device. You may want to look at the staxlab function in the plotrix 
package.
Jim

On Fri, Dec 18, 2015 at 10:20 PM, Amelia Marsh via R-help 
 wrote:

Dear Forum,

Assuming I need to plot a graph. In the code I have defined X axis range as



xlim=c(0,18000)


In the plot, the values visible w.r.t X axis are 0, 5000, 1, 18000.

To improve the graph clarity, is there any way I can show the values of X axis 
as 0, 1000, 2000, 3000, 4000, 5000 ...18000 i.e. the values increase by 
1000 instead of 5000.

Regards

Amelia

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




   
[[alternative HTML version deleted]]

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


Re: [R] Numerical differentiation of a vector of values

2015-12-18 Thread PIKAL Petr
Hi

I may be completely wrong, but did you consider

?diff

Cheers
Petr

> -Original Message-
> From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of BARLAS
> Marios 247554
> Sent: Friday, December 18, 2015 10:09 AM
> To: r-help@r-project.org
> Subject: [R] Numerical differentiation of a vector of values
>
> Hi everyone,
>
> I have sets of experimental values representing I-V curves. I want to
> get the derivative of such numerical data but in r there doesn' seem to
> be a premade function. I can write something of my own, but I was
> wondering if there is a standard package out there?
>
> Thanks in advance!
>
> __
> 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.


Tento e-mail a jakékoliv k němu připojené dokumenty jsou důvěrné a jsou určeny 
pouze jeho adresátům.
Jestliže jste obdržel(a) tento e-mail omylem, informujte laskavě neprodleně 
jeho odesílatele. Obsah tohoto emailu i s přílohami a jeho kopie vymažte ze 
svého systému.
Nejste-li zamýšleným adresátem tohoto emailu, nejste oprávněni tento email 
jakkoliv užívat, rozšiřovat, kopírovat či zveřejňovat.
Odesílatel e-mailu neodpovídá za eventuální škodu způsobenou modifikacemi či 
zpožděním přenosu e-mailu.

V případě, že je tento e-mail součástí obchodního jednání:
- vyhrazuje si odesílatel právo ukončit kdykoliv jednání o uzavření smlouvy, a 
to z jakéhokoliv důvodu i bez uvedení důvodu.
- a obsahuje-li nabídku, je adresát oprávněn nabídku bezodkladně přijmout; 
Odesílatel tohoto e-mailu (nabídky) vylučuje přijetí nabídky ze strany příjemce 
s dodatkem či odchylkou.
- trvá odesílatel na tom, že příslušná smlouva je uzavřena teprve výslovným 
dosažením shody na všech jejích náležitostech.
- odesílatel tohoto emailu informuje, že není oprávněn uzavírat za společnost 
žádné smlouvy s výjimkou případů, kdy k tomu byl písemně zmocněn nebo písemně 
pověřen a takové pověření nebo plná moc byly adresátovi tohoto emailu případně 
osobě, kterou adresát zastupuje, předloženy nebo jejich existence je adresátovi 
či osobě jím zastoupené známá.

This e-mail and any documents attached to it may be confidential and are 
intended only for its intended recipients.
If you received this e-mail by mistake, please immediately inform its sender. 
Delete the contents of this e-mail with all attachments and its copies from 
your system.
If you are not the intended recipient of this e-mail, you are not authorized to 
use, disseminate, copy or disclose this e-mail in any manner.
The sender of this e-mail shall not be liable for any possible damage caused by 
modifications of the e-mail or by delay with transfer of the email.

In case that this e-mail forms part of business dealings:
- the sender reserves the right to end negotiations about entering into a 
contract in any time, for any reason, and without stating any reasoning.
- if the e-mail contains an offer, the recipient is entitled to immediately 
accept such offer; The sender of this e-mail (offer) excludes any acceptance of 
the offer on the part of the recipient containing any amendment or variation.
- the sender insists on that the respective contract is concluded only upon an 
express mutual agreement on all its aspects.
- the sender of this e-mail informs that he/she is not authorized to enter into 
any contracts on behalf of the company except for cases in which he/she is 
expressly authorized to do so in writing, and such authorization or power of 
attorney is submitted to the recipient or the person represented by the 
recipient, or the existence of such authorization is known to the recipient of 
the person represented by the recipient.
__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Re: [R] Changing X axis values

2015-12-18 Thread Michael Dewey

Dear Amelia


As well as Jim's excellent advice you may want to look at the las 
parameter which enables you to alter the orientation. Of course you then 
have to lie on your side to read them or turn your monitor through pi/2


On 18/12/2015 11:30, Jim Lemon wrote:

Hi Amelia,
The usual way is:

plot(...,xaxt="n")
axis(1,at=seq(0,18000,by=1000)

However, you will get overlapping labels unless you use a small font or a
large graphics device. You may want to look at the staxlab function in the
plotrix package.

Jim


On Fri, Dec 18, 2015 at 10:20 PM, Amelia Marsh via R-help <
r-help@r-project.org> wrote:


Dear Forum,

Assuming I need to plot a graph. In the code I have defined X axis range as



xlim=c(0,18000)


In the plot, the values visible w.r.t X axis are 0, 5000, 1, 18000.

To improve the graph clarity, is there any way I can show the values of X
axis as 0, 1000, 2000, 3000, 4000, 5000 ...18000 i.e. the values
increase by 1000 instead of 5000.

Regards

Amelia

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



[[alternative HTML version deleted]]

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



--
Michael
http://www.dewey.myzen.co.uk/home.html

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


Re: [R] Changing X axis values

2015-12-18 Thread Jim Lemon
Hi Amelia,
The usual way is:

plot(...,xaxt="n")
axis(1,at=seq(0,18000,by=1000)

However, you will get overlapping labels unless you use a small font or a
large graphics device. You may want to look at the staxlab function in the
plotrix package.

Jim


On Fri, Dec 18, 2015 at 10:20 PM, Amelia Marsh via R-help <
r-help@r-project.org> wrote:

> Dear Forum,
>
> Assuming I need to plot a graph. In the code I have defined X axis range as
>
>
>
> xlim=c(0,18000)
>
>
> In the plot, the values visible w.r.t X axis are 0, 5000, 1, 18000.
>
> To improve the graph clarity, is there any way I can show the values of X
> axis as 0, 1000, 2000, 3000, 4000, 5000 ...18000 i.e. the values
> increase by 1000 instead of 5000.
>
> Regards
>
> Amelia
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

[[alternative HTML version deleted]]

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


[R] Changing X axis values

2015-12-18 Thread Amelia Marsh via R-help
Dear Forum,

Assuming I need to plot a graph. In the code I have defined X axis range as 



xlim=c(0,18000)


In the plot, the values visible w.r.t X axis are 0, 5000, 1, 18000.

To improve the graph clarity, is there any way I can show the values of X axis 
as 0, 1000, 2000, 3000, 4000, 5000 ...18000 i.e. the values increase by 
1000 instead of 5000.

Regards

Amelia

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


Re: [R] How to use the options "usecommand" and "command" of tktable?

2015-12-18 Thread Cleber Borges

# only a update the R code (with strange behavior)
library( tcltk ); tclRequire( "Tktable" )
top <- tktoplevel()
tcl('variable', 'myarray')
tcl('array', 'unset', 'myarray')
x <- 0
tabCmd <- function() {
x <<- x + 1
return( as.tclObj( paste(x) ) )
}
tab <- tkwidget( top, 'table', rows=2, cols=2, command=tabCmd )
tcl('pack', tab, expand=TRUE, fill='both' )
tcl( tab, 'index', 'topleft' )
tcl( tab, 'index', 'bottomright' )
tcl( tab, 'get', '0,0' )
tcl( tab, 'get', '0,1' )
tcl( tab, 'get', '1,0' )
tcl( tab, 'get', '1,1' )

x
Em 17/12/2015 22:07, Cleber N.Borges escreveu:
How to capture the output from the "command" option of tktable and how 
to send input to it?


As far as I understand, the most appropriate way to use the tktable is 
through the flag usecommand and command.


It fires the string information and cell coordinates and wait for a 
new string to set a new value.


It's I understood by example in pure TCL given in reference [1].

Is there how to translate this code to R?

I believe that the signs of tktable not reach the level of R and will 
need to be accessed by the lower level commands. But how?


Thank you in advance for dedicated attention.

cleber

###
[1] - http://dbaspot.com/object/showthread.php?t=785221&pagenumber=

### my R code
library( tcltk )
tclRequire( "Tktable" )
tclServiceMode( FALSE )
top <- tktoplevel()

TableCommand <- function( x=NULL ) {
cat( class( x ), '\n' )
cat( x , '\n' )
}

tab <- tkwidget( top, 'table', rows=2, cols=2, usecommand=TRUE, 
command=TableCommand )

tcl('pack', tab, expand=TRUE, fill='both' )
tclServiceMode( TRUE )

### TCL from [1]
package require Tktable

namespace eval ::test {}

proc ::test::build_table {} {

catch {destroy .test}
variable top [toplevel .test]

variable myarray
array unset myarray

variable table [table $top.table \
-rows 5 \
-height 5 \
-cols 2 \
-command "[namespace current]::TableCommand %S %r %c"]

pack $table -expand true -fill both
$table tag config complete -background blue
}

proc ::test::TableCommand {S r c} {

variable table
variable myarray

if {$S != ""} {
# I only want integers in my cells!
puts "\"$S\" into $r,$c ?"

if {[string is integer -strict $S]} {
$table tag cell complete "$r,$c"
set myarray($r,$c) $S
} else {
$table tag cell !complete "$r,$c"
array unset myarray $r,$c
}
}
if {[info exists myarray($r,$c)]} {
return $myarray($r,$c)
}
return "$r,$c"
}

::test::build_table




---
Este email foi escaneado pelo Avast antivírus.
https://www.avast.com/antivirus

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




---
Este email foi escaneado pelo Avast antivírus.
https://www.avast.com/antivirus

__
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] qqPlot vs qqcomp

2015-12-18 Thread mohsen hs via R-help
Hello all
I am using the following two commands and get two completely different qq plots 
while meanlog and sdlog are almost the same. Any help is highly appreciated. 
dev.new() ; qqPlot(serving, dist = "lnorm", estimate.params = TRUE, add.line = 
TRUE)

fitln <- fitdist(serving, "lnorm")
dev.new();qqcomp(fitln)
Many thanksMohsen
[[alternative HTML version deleted]]

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

[R] Numerical differentiation of a vector of values

2015-12-18 Thread BARLAS Marios 247554
Hi everyone,

I have sets of experimental values representing I-V curves. I want to get the 
derivative of such numerical data but in r there doesn' seem to be a premade 
function. I can write something of my own, but I was wondering if there is a 
standard package out there?

Thanks in advance!

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