[R] DOUBT

2023-03-21 Thread Nandini raj
Respected sir/madam
can you please suggest what is an unexpected symbol in the below code for
running a multinomial logistic regression

model <- multinom(adoption ~ age + education + HH size + landholding +
Farmincome + nonfarmincome + creditaccesibility + LHI, data=newdata)

[[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] C stack usage 7970372 is too close to the limit

2020-08-10 Thread Raj kapoor
Hi John,

Only the particular users getting error john. Please help me




On Mon, 10 Aug 2020, 11:43 pm Raj kapoor,  wrote:

> Hi John,
>
> I have 10 user in the instance, 9 user is working and access the R studio
> app, but while access the 10th user it's getting stack usage limit issues,
> then we create the new users its working fine.
>
> On Mon, 10 Aug 2020, 10:21 pm John Harrold, 
> wrote:
>
>> Hello Raj,
>>
>> I've gotten this type of error in the past when I've done things like use
>> while loops that didn't end. Basically, I think this means you're running
>> out of memory. If you want more users, possibly increase the amount of ram
>> in your machine.
>>
>> John
>>
>> On Mon, Aug 10, 2020 at 6:43 AM Raj kapoor 
>> wrote:
>>
>>> Hi Team,
>>>
>>> I have one production instance in aws, in CentoOs linux environment, i
>>> have
>>> 5 user to access the instance for using RStudio, In case R-studio
>>> working 4
>>> users running good, while we access 5th users its getting error,
>>>
>>> First issue : C stack usage 7970372 is too close to the limit
>>>
>>> Second Issue :  no stack overflow
>>>
>>> Please provide the solution.
>>>
>>> [[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.
>>>
>>
>>
>> --
>> John
>> :wq
>>
>

[[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] C stack usage 7970372 is too close to the limit

2020-08-10 Thread Raj kapoor
Hi John,

I have 10 user in the instance, 9 user is working and access the R studio
app, but while access the 10th user it's getting stack usage limit issues,
then we create the new users its working fine.

On Mon, 10 Aug 2020, 10:21 pm John Harrold, 
wrote:

> Hello Raj,
>
> I've gotten this type of error in the past when I've done things like use
> while loops that didn't end. Basically, I think this means you're running
> out of memory. If you want more users, possibly increase the amount of ram
> in your machine.
>
> John
>
> On Mon, Aug 10, 2020 at 6:43 AM Raj kapoor 
> wrote:
>
>> Hi Team,
>>
>> I have one production instance in aws, in CentoOs linux environment, i
>> have
>> 5 user to access the instance for using RStudio, In case R-studio working
>> 4
>> users running good, while we access 5th users its getting error,
>>
>> First issue : C stack usage 7970372 is too close to the limit
>>
>> Second Issue :  no stack overflow
>>
>> Please provide the solution.
>>
>> [[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.
>>
>
>
> --
> John
> :wq
>

[[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] C stack usage 7970372 is too close to the limit

2020-08-10 Thread Raj kapoor
Hi Team,

I have one production instance in aws, in CentoOs linux environment, i have
5 user to access the instance for using RStudio, In case R-studio working 4
users running good, while we access 5th users its getting error,

First issue : C stack usage 7970372 is too close to the limit

Second Issue :  no stack overflow

Please provide the solution.

[[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] (no subject)

2017-03-05 Thread Nikhil Raj
hello Team R,
i have been using R for statistical analysis of phylogeny and i have
installed the required packages phangorn and phytools but whenever i give
the command "pml.fit" the program stops and it appears thatb r for windows
GUI has stopped etc..
previously i thought it was a fault in my computer but it appears to happen
the same when i give the command in any other computer.
can i get a solution for this i have tried it on windows 10 and older
versions can it be fixed?
and also can you please send me the the commands for performing SH test of
phylogeny using phangorn if possible.
please do reply

thank you

[[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] regarding a problem in R

2017-03-05 Thread Nikhil Raj
hello Team R,
i have been using R for statistical analysis of phylogeny and i have
installed the required packages phangorn and phytools but whenever i give
the command "pml.fit" the program stops and it appears thatb r for windows
GUI has stopped etc..
previously i thought it was a fault in my computer but it appears to happen
the same when i give the command in any other computer.
can i get a solution for this i have tried it on windows 10 and older
versions can it be fixed?
and also can you please send me the the commands for performing SH test of
phylogeny using phangorn if possible.
please do reply

thank you

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

2017-03-05 Thread Nikhil Raj
hello Team R,
i have been using R for statistical analysis of phylogeny and i have
installed the required packages phangorn and phytools but whenever i give
the command "pml.fit" the program stops and it appears thatb r for windows
GUI has stopped etc..
previously i thought it was a fault in my computer but it appears to happen
the same when i give the command in any other computer.
can i get a solution for this i have tried it on windows 10 and older
versions can it be fixed?
and also can you please send me the the commands for performing SH test of
phylogeny using phangorn if possible.
please do reply

thank you

[[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] How to take a multidimensional data set to higher dimensions using R?

2016-04-24 Thread Devesh Raj Singh
Hi,

I have a multidimensional data-set( multiple 'x' variables with a target
variable). I want to take it to a higher dimensional space so that I can
apply classification technique with ease . Is there a package in R which
would allow me to take these data points from lower dimensional space to
higher dimensions? so that is that higher dimension I can apply
classification techniques to be effective. My datapoints are highly
inseperable in lower dimension so i want to take the data points to higher
dimension where they can be separable( something similar to kernel trick)

-- 
Warm regards,
Devesh.

[[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] Replace a column value on condition

2015-03-23 Thread Kuma Raj
I want to replace column c3 with values from column c2 whenever values
of column Id are 2. In stata I could use replace c3 = c2 if id ==2.
How could I do that in R?

Thanks


Sample data found below:

 dput(df4)
structure(list(c2 = c(42L, 42L, 47L, 47L, 55L, 55L, 36L, 36L,
61L, 61L), c3 = c(68L, 59L, 68L, 50L, 62L, 50L, 63L, 45L, 65L,
45L), id = c(1, 2, 1, 2, 1, 2, 1, 2, 1, 2)), datalabel = Written by
R.  , time.stamp = 23 Mar 2015 13:54, .Names = c(c2,
c3, id), formats = c(%9.0g, %9.0g, %9.0g), types = c(253L,
253L, 255L), val.labels = c(, , ), var.labels = c(, ,
), row.names = c(1, 2, 3, 4, 5, 6, 7, 8, 9,
10), version = 12L, class = data.frame)

__
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] Aggegate minutes data to hourly data

2015-03-11 Thread Kuma Raj
I have a measurement that was taken in 15 minutes or more and want to
aggregate it by hour. How could I do that?

Sample data is found below
date_time concentration
26/11/2013 15:46 529.25
26/11/2013 16:03 1596
26/11/2013 16:23 1027.111
26/11/2013 16:39 1001.9
26/11/2013 16:54 -80.25
26/11/2013 17:12 1064.125
26/11/2013 11:14 7969.7
26/11/2013 11:32 522
26/11/2013 11:58 845.111
26/11/2013 12:12 1166.875
26/11/2013 12:30 473.375
26/11/2013 12:42 466.2
26/11/2013 07:47 4358.833
26/11/2013 08:05 1257.545
26/11/2013 08:24 828.6
26/11/2013 08:45 942
26/11/2013 08:58 758.111
26/11/2013 09:13 832.333
26/11/2013 15:45 1876.909
26/11/2013 16:07 574.25
26/11/2013 16:27 1736.846
26/11/2013 16:43 1024.857
26/11/2013 16:59 858.538
26/11/2013 17:15 912.455
26/11/2013 11:18 2086.143
26/11/2013 11:39 2078.667
26/11/2013 12:03 1619.072
26/11/2013 12:16 1197.583
26/11/2013 12:35 619.308
26/11/2013 12:51 1222.571
26/11/2013 07:49 1357.929
26/11/2013 08:08 1120
26/11/2013 08:29 1381.6
26/11/2013 08:48 1493.429
26/11/2013 09:03 1113.786
26/11/2013 09:18 1217.143

__
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] rename columns with pattern

2015-01-12 Thread Kuma Raj
I want to rename columns 1 to 6 in the sample data set as  bp_1 to
bp_6. How could I do that in R?

Thanks

 dput(dff)
structure(list(one = c(1.00027378507871, 0.982313483915127, 1.1531279945243,
1.07400410677618, 1.22710472279261, 1.19762271047046, 1.10904859685147,
1.32060232717317), two = c(1.04707392197125, 1.00998288843258,
1.17598904859685, 1.09595482546201, 1.28599589322382, 1.26632675564591,
1.12986995208761, 1.30704654346338), three = c(1.06301619895049,
1.02743782797171, 1.1977093315081, 1.11466803559206, 1.2949441022131,
1.28365657768591, 1.1305452886151, 1.32089436459046), four = c(1.06994010951403,
1.03489904175222, 1.19799452429843, 1.1172022587269, 1.28742984257358,
1.27650013346977, 1.12265058179329, 1.30723134839151), five =
c(1.07019712525667,
1.03722792607803, 1.19174811772758, 1.11514168377823, 1.26594387405886,
1.25720010677582, 1.11339630390144, 1.29178507871321), six = c(1.1909650924,
1.08407027150354, 1.24785877253023, 1.16373032169747, 1.31150581793292,
1.31042514031455, 1.16205338809035, 1.37122975131189), idd = 1:8),
.Names = c(one,
two, three, four, five, six, idd), row.names = c(NA,
-8L), class = c(tbl_df, data.frame))


__
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] Create previous dates from date with consideration of leap year

2014-12-11 Thread Kuma Raj
Dear R Community,

I wish to create 5 preceding dates from the date variable by ID. How
could I create such dates? The code should consider leap year.

Thanks

Sample data follows:


structure(list(id = 1:12, date = structure(c(9L, 6L, 11L, 8L,
7L, 5L, 4L, 3L, 12L, 1L, 10L, 2L), .Label = c(01feb2003, 03mar2008,
04feb2008, 07jul1991, 07jun2010, 13feb2005, 18dec1991,
22sep2005, 27apr1993, 29jan2009, 29may2002, 31jan2005
), class = factor), case = c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L)), .Names = c(id, date, case), class =
data.frame, row.names = c(NA,
-12L))

__
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] How to update R without losing packages

2014-10-31 Thread Kuma Raj
A solution on the link below  provides the steps of updating R without
losing packages in Unix.
http://zvfak.blogspot.se/2012/06/updating-r-but-keeping-your-installed.html

How could I do that on windows 7 platform?

Thanks

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


[R] How can I merge data with differing length?

2014-10-30 Thread Kuma Raj
How can I merge  data frame df and tem shown below by filling the
head of tem  with missing values?


a- rnorm(1825, 20)
b- rnorm(1825, 30)
date-seq(as.Date(2000/1/1), by = day, length.out = 1825)

df-data.frame(date,a,b)


tem- rpois(1095,  lambda=21)

Thanks

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


[R] How to sum some columns based on their names

2014-10-13 Thread Kuma Raj
I want to sum columns based on their names. As an exampel how could I
sum columns which contain 6574, 7584 and 85 as column names?  In
addition, how could I sum those which contain 6574, 7584 and 85 in
ther names and have a prefix f. My data contains several variables
with

I want to sum columns based on their names. As an exampel how could I
sum columns which contain 6574, 7584 and 85 as column names?  In
addition, how could I sum those which contain 6574, 7584 and 85 in
ther names and have a prefix f. My data contains several variables
with

dput(df1)
structure(list(date = structure(c(1230768000, 1230854400, 1230940800,
1231027200, 1231113600, 123120, 1231286400, 1231372800, 1231459200,
1231545600, 1231632000), class = c(POSIXct, POSIXt), tzone = UTC),
f014card = c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), f1534card = c(0,
1, 1, 0, 0, 1, 0, 0, 1, 0, 1), f3564card = c(1, 6, 1, 5,
5, 4, 4, 7, 6, 4, 6), f6574card = c(3, 6, 4, 5, 5, 2, 10,
3, 4, 2, 4), f7584card = c(13, 6, 1, 4, 10, 6, 8, 12, 10,
4, 3), f85card = c(5, 3, 1, 0, 2, 10, 7, 9, 1, 7, 3), m014card = c(0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0), m1534card = c(0, 0, 1, 0,
0, 0, 0, 1, 1, 1, 0), m3564card = c(12, 7, 4, 7, 12, 13,
12, 7, 12, 2, 11), m6574card = c(3, 4, 8, 8, 8, 10, 7, 6,
7, 7, 5), m7584card = c(8, 10, 5, 4, 12, 7, 14, 11, 9, 1,
11), m85card = c(1, 4, 3, 0, 3, 4, 5, 5, 4, 5, 0)), .Names = c(date,
f014card, f1534card, f3564card, f6574card, f7584card,
f85card, m014card, m1534card, m3564card, m6574card,
m7584card, m85card), class = data.frame, row.names = c(1,
2, 3, 4, 5, 6, 7, 8, 9, 10, 11))

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Generate sequence of date based on a group ID

2014-10-08 Thread Kuma Raj
I want to generate a sequence of date based on a group id(similar IDs
should have same date). The id variable contains unequal observations
and the length of the data set also varies.  How could I create a
sequence that starts on specific date (say January 1, 2000 onwards)
and continues until the end without specifying length?


Sample data follows:

df-structure(list(id = c(1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L,

3L, 3L, 3L, 3L, 3L, 4L, 4L, 4L, 4L, 5L, 5L, 5L, 5L), out1 = c(0L,

0L, 0L, 0L, 1L, 0L, 0L, 0L, 0L, 1L, 0L, 0L, 0L, 0L, 1L, 0L, 0L,

0L, 1L, 0L, 0L, 0L, 1L)), .Names = c(id, out1), class =
data.frame, row.names = c(NA,

-23L))

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


[R] How to combine character month and year columns into one column

2014-09-23 Thread Kuma Raj
Dear R users,

I have a data with  month and year columns which are both characters
and wanted to create a new column like Jan-1999
with the following code. The result is all NA for the month part. What
is wrong with the and what is the right way to combine the two?

ddf$MonthDay - paste(month.abb[ddf$month], ddf$Year, sep=- )


Thanks

 dput(ddf)
structure(list(month = c(01, 02, 03, 04, 05, 06,
07, 08, 09, 10, 11, 12), Year = c(1999, 1999,
1999, 1999, 1999, 1999, 1999, 1999, 1999, 1999,
1999, 1999), views = c(42, 49, 44, 38, 37, 35, 38, 39, 38,
39, 38, 46), MonthDay = c(NA-1999, NA-1999, NA-1999, NA-1999,
NA-1999, NA-1999, NA-1999, NA-1999, NA-1999, NA-1999,
NA-1999, NA-1999)), .Names = c(month, Year, views,
MonthDay), row.names = 109:120, class = data.frame)


__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 combine character month and year columns into one column

2014-09-23 Thread Kuma Raj
Many thanks for your quick answer which has created what I wished. May
I ask followup question on the same issue. I failed to convert the new
column into date format with this code. The class of MonthDay is still
character

df$MonthDay - format(df$MonthDay, format=c(%b %Y))
I would appreciate if you could suggest a working solution
Thanks


On 23 September 2014 18:03, Marc Schwartz marc_schwa...@me.com wrote:
 On Sep 23, 2014, at 10:41 AM, Kuma Raj pollar...@gmail.com wrote:

 Dear R users,

 I have a data with  month and year columns which are both characters
 and wanted to create a new column like Jan-1999
 with the following code. The result is all NA for the month part. What
 is wrong with the and what is the right way to combine the two?

 ddf$MonthDay - paste(month.abb[ddf$month], ddf$Year, sep=- )


 Thanks

 dput(ddf)
 structure(list(month = c(01, 02, 03, 04, 05, 06,
 07, 08, 09, 10, 11, 12), Year = c(1999, 1999,
 1999, 1999, 1999, 1999, 1999, 1999, 1999, 1999,
 1999, 1999), views = c(42, 49, 44, 38, 37, 35, 38, 39, 38,
 39, 38, 46), MonthDay = c(NA-1999, NA-1999, NA-1999, NA-1999,
 NA-1999, NA-1999, NA-1999, NA-1999, NA-1999, NA-1999,
 NA-1999, NA-1999)), .Names = c(month, Year, views,
 MonthDay), row.names = 109:120, class = data.frame)





 Since you are trying to use ddf$month as an index into month.abb, you will 
 either need to coerce ddf$month to numeric in your code, or adjust how the 
 data frame is created.

 In the case of the former approach:

 paste(month.abb[as.numeric(ddf$month)], ddf$Year, sep=- )
  [1] Jan-1999 Feb-1999 Mar-1999 Apr-1999 May-1999 Jun-1999
  [7] Jul-1999 Aug-1999 Sep-1999 Oct-1999 Nov-1999 Dec-1999


 Regards,

 Marc Schwartz


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


[R] How to identify outliers with values five times 99th percentile

2014-09-09 Thread Kuma Raj
I have a data frame with some extreme values which I wish to identify
and repeat an analysis without these extreme values. How could I
identify several columns with values which are 5 times higher than the
99th percentile?

Sample data is pasted below.

 dput(df)

structure(list(ad1 = c(98, 6.9, 8.1, 56, 3.9, 6.9, 6.9, 5.8,

7.2, 20.5, 9.4, 7.6, 5.3, 7.9, 62.2, 9.2, 11.9, 8.8, 23.1, 5.4,

9.4, 56, 8.6, 20.7, 21, 10.5, 5.5, 4.3, 15.8, 6.8, 10.4, 5.1),

ad2 = c(14.9, 19.7, 1, 17.7, 14.9, 13.6, 18.8, 20.9, 46,

16.5, 11.7, 1, 9.2, 23.6, 19.7, 1, 11.4, 11, 23.1, 1, 1,

8.9, 11.3, 6.4, 15.2, 1, 17.3, 10.1, 13.3, 21.3, 12.3, 15.4

), ad3 = c(0.91, 0.95, 10.7, 4.4, 0.43, 0.8, 3.1, 1.9, 2.3,

5.6, 3.9, 7.3, 0.37, 4.1, 15.1, 21.8, 3, 0.79, 1, 4.6, 0.61,

0.46, 0.87, 23.5, 3.8, 3.1, 0.33, 1.9, 3.2, 1.7, 0.53, 62.5

), ad4 = c(225.5, 269.7, 326, 485.4, 193.2, 274.1, 553.2,

166.8, 435.9, 433.2, 187.1, 660.4, 235.4, 356.5, 378.8, 500.5,

323.5, 327.1, 289.5, 301.2, 291.7, 333.5, 351.7, 384.1, 347,

1354, 440.4, 189.2, 381, 252.7, 391.1, 255.1), ad5 = c(337.9,

355.6, 419.5, 798.5, 225, 355.9, 394.4, 340.6, 463.9, 291.9,

312.3, 491, 290.5, 231.9, 358, 386.4, 306.7, 440.6, 297.9,

339.3, 341.1, 366.2, 325.4, 357, 412.2, 370.2, 421.3, 346.3,

289.1, 257.4, 368, 322.6), ad6 = c(64.5, 130.6, 76, 167.8,

47.3, 117, 60.7, 91.9, 221.9, 91.1, 105.1, 110.8, 64.5, 184.5,

191.6, 259.4, 879.5, 142.1, 55.3, 123.1, 62.2, 75.2, 154.6,

100.7, 93.1, 136.7, 74.3, 41.8, 110.1, 109.1, 172.5, 87.7

), ad7 = c(128L, 987L, 158L, 124L, 137L, 215L, 141L, 98L,

291L, 261L, 106L, 137L, 141L, 159L, 221L, 108L, 123L, 107L,

137L, 175L, 257L, 97L, 168L, 145L, 147L, 188L, 145L, 128L,

153L, 187L, 123L, 354L), ad8 = c(3.26, 3.98, 2.88, 2.85,

4.17, 3.16, 3.09, 4.35, 3.46, 3.81, 3.78, 3.81, 4.17, 4.27,

4.27, 2.97, 3.43, 3.48, 3.78, 3.86, 3.11, 3.12, 3.16, 4.24,

3.81, 3.11, 5.31, 3.75, 3.78, 3.55, 4.08, 3.5), ad9 = c(433L,

211L, 66L, 173L, 224L, 466L, 224L, 273L, 94L, 321L, 160L,

107L, 121L, 186L, 455L, 80L, 897L, 186L, 285L, 134L, 107L,

355L, 261L, 249L, 332L, 107L, 273L, 107L, 160L, 535L, 160L,

121L)), .Names = c(ad1, ad2, ad3, ad4, ad5, ad6,

ad7, ad8, ad9), class = data.frame, row.names = c(NA,

-32L))

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Obtain coefficients of several nlme objects

2014-09-05 Thread Kuma Raj
I have several lme objects like the ones shown below and I wish to
combine the coefficients and confidence intervals of fixed effects of
several models.  Is there a function that could do that job?

m1 - lme(mark1 ~   pm10  + temp +   + age  + gender + bmi   + statin
+ smoke + dow +  season

  , data =  df , random = ~ 1 | id,na.action=na.exclude, method=ML)

m2 - lme(mark2 ~   pm10  + temp +   + age  + gender + bmi   + statin
+ smoke + dow +  season

  , data =  df , random = ~ 1 | id,na.action=na.exclude, method=ML)

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Subset a column with specific characters

2014-09-04 Thread Kuma Raj
This post has NOT been accepted by the mailing list yet.
I would like to subset a column based on the contents of a column with
specific character. In the sample data I wish to do the following:

First keep the data based on column prog if prog contains ca, and
secondly to drop if race contains ic

Thanks

library(foreign)
hsb2 - read.dta('http://www.ats.ucla.edu/stat/stata/notes/hsb2.dta')

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

2013-11-12 Thread Kuma Raj
I have asked this question on SO, but it attracted no response, thus I am
cross- posting it here with the hope that someone would help.

I want to estimate the effect of  pm10 and o3 on three outcome(death, cvd
and resp). What I want to do is run one model for each of the main
predictors  (pm10 and o3) and each outcome(death, cvd and resp). Thus I
expect to obtain 6 models. The script below works for one outcome (death)
and I wish to use it for more dependent variables.



library(quantmod)
library(mgcv)
library(dlnm)
df - chicagoNMMAPS
outcomes- c(death, cvd, resp )
varlist0 - c(pm10, o3)

m1 - lapply(varlist0,function(v) {
f - sprintf(death~ s(time,bs='cr',k=200)+s(temp,bs='cr') +
Lag(%s,0:6),v)
gam(as.formula(f),family=quasipoisson,na.action=na.omit,data=df)
  })

Thanks

[[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] Loop through columns of outcomes

2013-11-12 Thread Kuma Raj
Thanks for the script which works perfectly. I am interested to do
model checking and also interested to extract the coefficients for
linear and spline terms. For model checkup I could run this script
which will give different plots to test model fit: gam.check(m2[[1]]).
Thanks to mnel from SO I could also extract the linear terms with the
following script:

m2 - unlist(m1, recursive = FALSE)   ## unlist

First extract the model elements:

mod1-m2[[1]]
mod2-m2[[2]]
mod3-m2[[3]]
mod4-m2[[4]]
mod5-m2[[5]]
mod6-m2[[6]]

And run the following:

mlist - list(mod1, mod2, mod3,mod4,mod5,mod6)  ##  Creates a list of models
names(mlist) - list(mod1, mod2, mod3,mod4,mod5,mod6)

 slist - lapply(mlist, summary)   ## obtain summaries

plist - lapply(slist, `[[`, 'p.table')   ## list of the coefficients
linear terms

For 6 models this is relatively easy to do, but how could I shorten
the process if I have large number of models?

Thanks


On 12 November 2013 12:32, Rui Barradas ruipbarra...@sapo.pt wrote:
 Hello,

 Use nested lapply(). Like this:



 m1 - lapply(varlist0,function(v) {
 lapply(outcomes, function(o){
 f - sprintf(%s~ s(time,bs='cr',k=200)+s(temp,bs='cr') +
 Lag(%s,0:6), o, v)

 gam(as.formula(f),family=quasipoisson,na.action=na.omit,data=df)
   })})

 m1 - unlist(m1, recursive = FALSE)
 m1


 Hope this helps,

 Rui Barradas


 Em 12-11-2013 09:53, Kuma Raj escreveu:

 I have asked this question on SO, but it attracted no response, thus I am
 cross- posting it here with the hope that someone would help.

 I want to estimate the effect of  pm10 and o3 on three outcome(death, cvd
 and resp). What I want to do is run one model for each of the main
 predictors  (pm10 and o3) and each outcome(death, cvd and resp). Thus I
 expect to obtain 6 models. The script below works for one outcome (death)
 and I wish to use it for more dependent variables.



 library(quantmod)
 library(mgcv)
 library(dlnm)
 df - chicagoNMMAPS
 outcomes- c(death, cvd, resp )
 varlist0 - c(pm10, o3)

  m1 - lapply(varlist0,function(v) {
  f - sprintf(death~ s(time,bs='cr',k=200)+s(temp,bs='cr') +
 Lag(%s,0:6),v)
  gam(as.formula(f),family=quasipoisson,na.action=na.omit,data=df)
})

 Thanks

 [[alternative HTML version deleted]]

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



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


Re: [R] Loop through columns of outcomes

2013-11-12 Thread Kuma Raj
Very helpful, many thanks.

On 12 November 2013 16:09, Rui Barradas ruipbarra...@sapo.pt wrote:
 Hello,

 Once again, use lapply.

 mlist - lapply(seq_along(m2), function(i) m2[[i]])
 names(mlist) - paste0(mod, seq_along(mlist))

 slist - lapply(mlist, summary)


 plist - lapply(slist, `[[`, 'p.table')


 Hope this helps,

 Rui Barradas

 Em 12-11-2013 13:28, Kuma Raj escreveu:

 Thanks for the script which works perfectly. I am interested to do
 model checking and also interested to extract the coefficients for
 linear and spline terms. For model checkup I could run this script
 which will give different plots to test model fit: gam.check(m2[[1]]).
 Thanks to mnel from SO I could also extract the linear terms with the
 following script:

 m2 - unlist(m1, recursive = FALSE)   ## unlist

 First extract the model elements:

 mod1-m2[[1]]
 mod2-m2[[2]]
 mod3-m2[[3]]
 mod4-m2[[4]]
 mod5-m2[[5]]
 mod6-m2[[6]]

 And run the following:

 mlist - list(mod1, mod2, mod3,mod4,mod5,mod6)  ##  Creates a list of
 models
 names(mlist) - list(mod1, mod2, mod3,mod4,mod5,mod6)

   slist - lapply(mlist, summary)   ## obtain summaries

 plist - lapply(slist, `[[`, 'p.table')   ## list of the coefficients
 linear terms

 For 6 models this is relatively easy to do, but how could I shorten
 the process if I have large number of models?

 Thanks


 On 12 November 2013 12:32, Rui Barradas ruipbarra...@sapo.pt wrote:

 Hello,

 Use nested lapply(). Like this:



 m1 - lapply(varlist0,function(v) {
  lapply(outcomes, function(o){
  f - sprintf(%s~ s(time,bs='cr',k=200)+s(temp,bs='cr')
 +
 Lag(%s,0:6), o, v)

 gam(as.formula(f),family=quasipoisson,na.action=na.omit,data=df)
})})

 m1 - unlist(m1, recursive = FALSE)
 m1


 Hope this helps,

 Rui Barradas


 Em 12-11-2013 09:53, Kuma Raj escreveu:


 I have asked this question on SO, but it attracted no response, thus I
 am
 cross- posting it here with the hope that someone would help.

 I want to estimate the effect of  pm10 and o3 on three outcome(death,
 cvd
 and resp). What I want to do is run one model for each of the main
 predictors  (pm10 and o3) and each outcome(death, cvd and resp). Thus I
 expect to obtain 6 models. The script below works for one outcome
 (death)
 and I wish to use it for more dependent variables.



 library(quantmod)
 library(mgcv)
 library(dlnm)
 df - chicagoNMMAPS
 outcomes- c(death, cvd, resp )
 varlist0 - c(pm10, o3)

   m1 - lapply(varlist0,function(v) {
   f - sprintf(death~ s(time,bs='cr',k=200)+s(temp,bs='cr') +
 Lag(%s,0:6),v)

 gam(as.formula(f),family=quasipoisson,na.action=na.omit,data=df)
 })

 Thanks

  [[alternative HTML version deleted]]

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




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


[R] Remove a column of a matrix with unnamed column header

2013-11-08 Thread Kuma Raj
I have a matrix names test which I want to convert to a data frame. When I
use a command  test2-as.data.frame(test) it is executed without a problem.
But when I want to browse the content I receive an error message Error in
data.frame(outcome = c(cardva, respir, cereb, neoplasm,  :
 duplicate row.names: Estimate . The problem is clearly due to a duplicate
in  row name . But I am unable to remove this column. I need help on how to
remove this specific column that has essentially no column header name.
dput of the matrix is here:

 dput(test)
structure(c(cardva, respir, cereb, neoplasm, ami, ischem,
heartf, pneumo, copd, asthma, dysrhy, diabet,
0.00259492159959046,
0.00979775441709427, 0.00103414632535868, 0.00486468139227382,
0.0164825543879707, 0.0116647168053943, -0.0012137908515233,
0.00730433232907741, 0.00355583994565985, 0.000712387285735019,
-0.00103763671307935, 0.00981500221106926, 0.00325476724733837,
0.0049232113728293, 0.00520118026087645, 0.00386848394426742,
0.00688121694253705, 0.00585772614064902, 0.00564983058883797,
0.0061328202328586, 0.0108212194251692, 0.0173804438930357,
0.00867931407250442, 0.0106638104533486, 0.425323120845664,
0.0466180768654915, 0.842402292743715, 0.208609687427072,
0.0166336682608816, 0.0464833846710956, 0.8299010611324,
0.233685747699204, 0.742469001175026, 0.967306766450795,
0.904840885401235, 0.357394700741248), .Dim = c(12L, 4L), .Dimnames =
list(
c(Estimate, Estimate, Estimate, Estimate, Estimate,
Estimate, Estimate, Estimate, Estimate, Estimate,
Estimate, Estimate), c(outcome, beta, se, pval
)))

 test2-as.data.frame(test)
 test2
Error in data.frame(outcome = c(cardva, respir, cereb, neoplasm,  :
  duplicate row.names: Estimate

[[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] Remove a column of a matrix with unnamed column header

2013-11-08 Thread Kuma Raj
Beend, Thanks for that. Conversion of test to a data frame resulted in a
factor. Is there a possibility to selectively convert to numeric?   I have
tried this code and that has not produced the intended result.
test[, c(2:4)] - sapply(test[, c(2:4)], as.numeric)



On 8 November 2013 11:31, Berend Hasselman b...@xs4all.nl wrote:


 On 08-11-2013, at 10:40, Kuma Raj pollar...@gmail.com wrote:

  I have a matrix names test which I want to convert to a data frame. When
 I
  use a command  test2-as.data.frame(test) it is executed without a
 problem.
  But when I want to browse the content I receive an error message Error
 in
  data.frame(outcome = c(cardva, respir, cereb, neoplasm,  :
  duplicate row.names: Estimate . The problem is clearly due to a
 duplicate
  in  row name . But I am unable to remove this column. I need help on how
 to
  remove this specific column that has essentially no column header name.
  dput of the matrix is here:
 
  dput(test)
  structure(c(cardva, respir, cereb, neoplasm, ami, ischem,
  heartf, pneumo, copd, asthma, dysrhy, diabet,
  0.00259492159959046,
  0.00979775441709427, 0.00103414632535868, 0.00486468139227382,
  0.0164825543879707, 0.0116647168053943, -0.0012137908515233,
  0.00730433232907741, 0.00355583994565985, 0.000712387285735019,
  -0.00103763671307935, 0.00981500221106926, 0.00325476724733837,
  0.0049232113728293, 0.00520118026087645, 0.00386848394426742,
  0.00688121694253705, 0.00585772614064902, 0.00564983058883797,
  0.0061328202328586, 0.0108212194251692, 0.0173804438930357,
  0.00867931407250442, 0.0106638104533486, 0.425323120845664,
  0.0466180768654915, 0.842402292743715, 0.208609687427072,
  0.0166336682608816, 0.0464833846710956, 0.8299010611324,
  0.233685747699204, 0.742469001175026, 0.967306766450795,
  0.904840885401235, 0.357394700741248), .Dim = c(12L, 4L), .Dimnames =
  list(
 c(Estimate, Estimate, Estimate, Estimate, Estimate,
 Estimate, Estimate, Estimate, Estimate, Estimate,
 Estimate, Estimate), c(outcome, beta, se, pval
 )))
 
  test2-as.data.frame(test)
  test2
  Error in data.frame(outcome = c(cardva, respir, cereb, neoplasm,
  :
   duplicate row.names: Estimate

 rownames(test) - NULL

 Berend



[[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] Subject: Regress multiple independent variables on multiple dependent variables

2013-11-04 Thread Kumar Raj
I want to estimate the effect of several independent variables on several
dependent
variables. In the example below I wanted to estimate the
effect of three independent variables on ozone and temperature.  My aim is
to create a list of dependent and independent variables and automate the
process rather than writing every dependent and independent variable in
each model as I have done below.

Example data is provided by the following library:
library(faraway)

data(ozone)

mo3 - glm(O3 ~ humidity + ibh + ibt, data=ozone)

mtemp- glm(temp ~  humidity + ibh + ibt, data=ozone)


Thanks

[[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] Logistic Regression - Variable Selection Methods With Prediction

2011-10-26 Thread RAJ
Can I atleast get help with what pacakge to use for logistic
regression with all possible models and do prediction. I know i can
use regsubsets but i am not sure if it has any prediction functions to
go with it.

Thanks

On Oct 25, 6:54 pm, RAJ dheerajathr...@gmail.com wrote:
 Hello,

 I am pretty new to R, I have always used SAS and SAS products. My
 target variable is binary ('Y' and 'N') and i have about 14 predictor
 variables. My goal is to compare different variable selection methods
 like Forward, Backward, All possible subsests. I am using
 misclassification rate to pick the winner method.

 This is what i have as of now,

 Reg - glm (Graduation ~., DFtrain,family=binomial(link=logit))
                 step - extractAIC(Reg, direction=forward)
                 pred - predict(Reg, DFtest,type=response)
                 mis - mean({pred  0.5} != {DFtest[,Graduation] == Y})
 This program actually works but I needed to check to make sure am
 doing this right. Also, I am getting the same misclassification rates
 for all different methods.

 I also tried to use

 Reg - leaps(Graduation ~., DFtrain)
                 pred - predict(Reg, DFtest,type=response)
                 mis - mean({pred  0.5} != {DFtest[,Graduation] == Y})
                 #print(summary(mis))
 which doesnt work

 and

 Reg - regsubsets(Graduation ~., DFtrain)
                 pred - predict(Reg, DFtest,type=response)
                 mis - mean({pred  0.5} != {DFtest[,Graduation] == Y})
                 #print(summary(mis))

 The Regsubsets will work but the 'predict' function does not work with
 it. Is there any other way to do predictions when using regsubsets

 Any help is appreciated.

 Thanks,

 __
 r-h...@r-project.org mailing listhttps://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guidehttp://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] Logistic Regression - Variable Selection Methods With Prediction

2011-10-25 Thread RAJ
Hello,

I am pretty new to R, I have always used SAS and SAS products. My
target variable is binary ('Y' and 'N') and i have about 14 predictor
variables. My goal is to compare different variable selection methods
like Forward, Backward, All possible subsests. I am using
misclassification rate to pick the winner method.

This is what i have as of now,

Reg - glm (Graduation ~., DFtrain,family=binomial(link=logit))
step - extractAIC(Reg, direction=forward)
pred - predict(Reg, DFtest,type=response)
mis - mean({pred  0.5} != {DFtest[,Graduation] == Y})
This program actually works but I needed to check to make sure am
doing this right. Also, I am getting the same misclassification rates
for all different methods.

I also tried to use

Reg - leaps(Graduation ~., DFtrain)
pred - predict(Reg, DFtest,type=response)
mis - mean({pred  0.5} != {DFtest[,Graduation] == Y})
#print(summary(mis))
which doesnt work

and

Reg - regsubsets(Graduation ~., DFtrain)
pred - predict(Reg, DFtest,type=response)
mis - mean({pred  0.5} != {DFtest[,Graduation] == Y})
#print(summary(mis))

The Regsubsets will work but the 'predict' function does not work with
it. Is there any other way to do predictions when using regsubsets

Any help is appreciated.

Thanks,

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


Re: [R] Contingency table in R

2011-03-02 Thread Antony Raj
Hi Laura and R users,

I would like to know whether we can do siginificance test between Column Yes
and Column No.

Any one tried? I have seen it in Tabulaiton software packages from our
vendors and in SPSS Custom Table.

Thanks,

On Wed, Mar 2, 2011 at 7:43 PM, Laura Clasemann violagirl...@msn.comwrote:


 Hi,

 I have a table in R with data I needed and need to create a contingency
 table out of it. The table I have so far looks like this:


   Binger
 r
 DietType No Yes
  Dangerous  15  12
  Healthy52   9
  None  134  24
  Unhealthy  72  23

 These are the error messages that I keep getting whenever I try to get a
 contingency table. I'm not sure why it won't work for me, any help would be
 appreciated!
  nametable-table(excat,recat)
 Error in table(excat, recat) : object 'excat' not found

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


Re: [R] sapply, lattice functions

2010-03-20 Thread Sundar Dorai-Raj
You're right. It's necessary for xyplot though to prevent grouping.

On Mar 20, 2010 10:43 AM, Dieter Menne dieter.me...@menne-biomed.de
wrote:



Sundar Dorai-Raj-2 wrote:

 Or perhaps more clearly,

 histogram(~a1 + b1 + c1, data = aa, o...
Why outer=TRUE? Looks same for me without:
Dieter

library(lattice)

aa - data.frame(a1=rnorm(20),b1=rnorm(20,0.8),c1=rnorm(20,0.5))
histogram(~a1 + b1 + c1, data = aa)


--
View this message in context:
http://n4.nabble.com/sapply-lattice-functions-tp1618134p1676043.html
Sent from the R help mailing list archive at Nabble.com.


__
R-help@r-project.org mailing list
https://stat.ethz

[[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] sapply, lattice functions

2010-03-19 Thread Sundar Dorai-Raj
Or perhaps more clearly,

histogram(~a1 + b1 + c1, data = aa, outer = TRUE)

--sundar

On Fri, Mar 19, 2010 at 3:50 PM, Gabor Grothendieck ggrothendi...@gmail.com
 wrote:

 Try this:

 histogram(~ values | ind, stack(aa))


 On Fri, Mar 19, 2010 at 5:44 PM, Santosh santosh2...@gmail.com wrote:
  Dear R-gurus
 
  aa - data.frame(a1=rnorm(20),b1=rnorm(20,0.8),c1=rnorm(20,0.5))
  sapply(aa,function(x) histogram(x,breaks=NULL))
 
  or px - sapply(aa,function(x) histogram(x,breaks=NULL))
  print(px,split=c(1,1,1,1),more=F)
 
  The above code does not seem to work. am I missing something?
 
  Thanks,
  Santosh
 
 [[alternative HTML version deleted]]
 
  __
  R-help@r-project.org mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
  and provide commented, minimal, self-contained, reproducible code.
 

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


[[alternative HTML version deleted]]

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


Re: [R] Source code for the t-distribution

2010-03-09 Thread Sundar Dorai-Raj
Here it is.

https://svn.r-project.org/R/trunk/src/nmath/pt.c

--sundar

On Tue, Mar 9, 2010 at 4:24 AM, Ravi Kulkarni ravi.k...@gmail.com wrote:


 I have tried looking for the source code for the pt() function in

 https://svn.r-project.org/R/trunk/src/library/stats/

 and am unable to find it there. Can someone please tell me where to find
 it?

 Thanks,
  Ravi Kulkarni
 --
 View this message in context:
 http://n4.nabble.com/Source-code-for-the-t-distribution-tp1585875p1585875.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.


[[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] capturing errors in Sweave

2010-03-02 Thread Sundar Dorai-Raj
Thanks, Berwin. That works just great!

--sundar

On Tue, Mar 2, 2010 at 12:57 AM, Berwin A Turlach
ber...@maths.uwa.edu.auwrote:

 G'day Sundar,

 On Mon, 1 Mar 2010 23:46:55 -0800
 Sundar Dorai-Raj sdorai...@gmail.com wrote:

  Thanks for the input, but I don't want try in the Sweave output. I
  want the output to look just like it does in the console, as if an
  uncaptured error really did occur.

 I don't think that you will get around using try; and you will have
 to work moderately hard to make the output appear as it does on the
 console.  Probably somewhere along the lines:

  Sweave code start ++
 Function-4a=
 MySqrt - function(x) {
  if (missing(x)) {
stop('x' is missing with no default)
  }
  if (!is.numeric(x)) {
stop('x' should only be numeric)
  }
  if (x  0) {
stop('x' should be non-negative)
  }
  return(sqrt(x))
 }
 @

 echo=FALSE=
 tmp - try(MySqrt())
 @
 eval=FALSE=
 MySqrt()
 @
 echo=FALSE=
  cat(tmp[1])
 @

 echo=FALSE=
 tmp - try(MySqrt(a))
 @
 eval=FALSE=
 MySqrt(a)
 @
 echo=FALSE=
  cat(tmp[1])
 @

 echo=FALSE=
 tmp - try(MySqrt(-2))
 @
 eval=FALSE=
 MySqrt(-2)
 @
 echo=FALSE=
  cat(tmp[1])
 @

 =
 MySqrt(4)
 @
 +++ Sweave code end ++

 Now what I would like to know is how to include easily warning messages
 in my Sweave output without having to try whether Jean Lobry's [1] hack
 still works. :)

 HTH.

 Cheers,

Berwin

 [1]
 https://www.stat.math.ethz.ch/pipermail/r-help/2006-December/121975.html

 == Full address 
 Berwin A Turlach  Tel.: +61 (8) 6488 3338 (secr)
 School of Maths and Stats (M019)+61 (8) 6488 3383 (self)
 The University of Western Australia   FAX : +61 (8) 6488 1028
 35 Stirling Highway
 Crawley WA 6009e-mail: ber...@maths.uwa.edu.au
 Australiahttp://www.maths.uwa.edu.au/~berwin


[[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] capturing errors in Sweave

2010-03-02 Thread Sundar Dorai-Raj
What I ended up using was:

cat(unclass(tmp))

--sundar

On Tue, Mar 2, 2010 at 8:58 AM, Berwin A Turlach ber...@maths.uwa.edu.auwrote:

 G'day Sundar,

 On Tue, 2 Mar 2010 01:03:54 -0800
 Sundar Dorai-Raj sdorai...@gmail.com wrote:

  Thanks, Berwin. That works just great!

 You are welcome.

 I noticed by now that cat(tmp) is sufficient; the tmp[1] in
 cat(tmp[1]) was a left over from earlier attempts to get the output
 to look correct.

 Cheers,

Berwin


[[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] capturing errors in Sweave

2010-03-01 Thread Sundar Dorai-Raj
Hi,

I'm writing a manual using Sweave and I want to be able to print errors from
bad code. Here's an example:

Function-4a=
MySqrt - function(x) {
  if (missing(x)) {
stop('x' is missing with no default)
  }
  if (!is.numeric(x)) {
stop('x' should only be numeric)
  }
  if (x  0) {
stop('x' should be non-negative)
  }
  return(sqrt(x))
}
MySqrt()
MySqrt(a)
MySqrt(-2)
MySqrt(4)
@

And I would like the output to be:

MySqrt - function(x) {
...
}
 MySqrt()
Error in MySqrt() : 'x' is missing with no default
 MySqrt(a)
Error in MySqrt(a) : 'x' should only be numeric
 MySqrt(-2)
Error in MySqrt(-2) : 'x' should be non-negative
 MySqrt(2)
[1] 1.414214

I.e. I want the Error statements to print in the tex file and not just make
Sweave to bomb.

Thanks,

--sundar

[[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] capturing errors in Sweave

2010-03-01 Thread Sundar Dorai-Raj
Thanks for the input, but I don't want try in the Sweave output. I want
the output to look just like it does in the console, as if an uncaptured
error really did occur.

--sundar

On Mon, Mar 1, 2010 at 11:42 PM, Sharpie ch...@sharpsteen.net wrote:



 Sundar Dorai-Raj-2 wrote:
 
  Hi,
 
  I'm writing a manual using Sweave and I want to be able to print errors
  from
  bad code. Here's an example:
 
  Function-4a=
  MySqrt - function(x) {
if (missing(x)) {
  stop('x' is missing with no default)
}
if (!is.numeric(x)) {
  stop('x' should only be numeric)
}
if (x  0) {
  stop('x' should be non-negative)
}
return(sqrt(x))
  }
  MySqrt()
  MySqrt(a)
  MySqrt(-2)
  MySqrt(4)
  @
 
  And I would like the output to be:
 
  MySqrt - function(x) {
  ...
  }
  MySqrt()
  Error in MySqrt() : 'x' is missing with no default
  MySqrt(a)
  Error in MySqrt(a) : 'x' should only be numeric
  MySqrt(-2)
  Error in MySqrt(-2) : 'x' should be non-negative
  MySqrt(2)
  [1] 1.414214
 
  I.e. I want the Error statements to print in the tex file and not just
  make
  Sweave to bomb.
 
  Thanks,
 
  --sundar
 

 You can catch errors in R using the try() function:

  foo - try( log(A), silent = TRUE )

  if( class( foo ) == 'try-error' ){

print( unclass( foo ) )

  }

 [1] Error in log(\A\) : Non-numeric argument to mathematical function\n


 There might be a more clever way to override the default error handling
 that
 would save you from wrapping everything in try()-- but this method should
 work.

 Hope it helps!

 -Charlie

 -
 Charlie Sharpsteen
 Undergraduate-- Environmental Resources Engineering
 Humboldt State University
 --
 View this message in context:
 http://n4.nabble.com/capturing-errors-in-Sweave-tp1574642p1574686.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.


[[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] How do I juxtapose two lattice graphs with common X axes such that the X axes line up?

2010-01-20 Thread Sundar Dorai-Raj
Try googling latticeExtra x.same for some examples. Here's one:

http://www.mail-archive.com/r-help@r-project.org/msg39048.html

On Wed, Jan 20, 2010 at 9:44 AM, George Chen glc...@stanford.edu wrote:

 Hello,

 I would like to juxtapose two lattice graphs with common X axes such that
 the X axes line up.  I am using plot right now but the edges are not neat
 and it would be nice if I could just draw 1 X axis and not both of them.

 Here is my code:



 upper-bwplot(SignalUsed~as.factor(AllNormalHitsNamesCount),data=NmlOverviewArray2,
xlab=,
ylab=Intensity of Individual Antibody Responses,
main=Intensity, Frequency, Distribution,  Quantity of Normal
 Antibody Responses,
box.ratio=1,
panel = function (AllNormalHitsNamesCount,...) {
panel.bwplot(...)
}
)

 lower-barchart(as.vector(table(NmlOverviewArray2$AllNormalHitsNamesCount))

  
 ~as.factor(as.numeric(names(table(NmlOverviewArray2$AllNormalHitsNamesCount,
data=NmlOverviewArray2,
ylab=Number of Individual Antibody Responses,
xlab=Occurrence of Individual Antibody Responses
 (Out of 45 Normals),
box.ratio=1)

 plot (upper, newpage=TRUE, more=TRUE, position = c(0,.15,1,1))
 plot (lower, newpage=FALSE, more=TRUE, position = c(0,0,1,.3))


 George

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


[[alternative HTML version deleted]]

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


Re: [R] Dynamic arguments in rbind function

2010-01-04 Thread Sundar Dorai-Raj
Use a list instead of assign then do.call(rbind, thelist).

import.files - c(a.txt, b.txt,  c.txt,  d.txt,  e.txt)
imp - vector(list, length(import.files))
for (i in 1:length(import.files)) {
  imp[[i]] - read.delim(import.files[i], sep = , header = TRUE)
}

combined - do.call(rbind, imp)

HTH,

--sundar

On Mon, Jan 4, 2010 at 4:31 PM, Steven Kang stochastick...@gmail.comwrote:

 Hi, all

 Basically, I have unknown number of data that need to be imported and
 collapsed row-wisely.

 The code below works fine, however the rbind function may require 50
 arguments if there are 50 data files...

 Thus, I would like to explore whether there are any methods in using
 dynamic
 objects (i.e from the resulting objects in the for loop) as an argument in
 the *rbind* function.



 setwd(.)

 import.files - c(a.txt, b.txt,  c.txt,  d.txt,  e.txt)
 for (i in 1:length(import.files)) {
  assign(paste(imp, i, sep = .), read.delim(eval(paste(.\\,
 import.files[i], sep = )), header = TRUE))
 }

 combined - rbind(*imp.1, imp.2, imp.3, imp.4, imp.5, imp.6*)



 Your expertise in resolving this issue would be greatly appreciated.



 Steve

[[alternative HTML version deleted]]

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


[[alternative HTML version deleted]]

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


Re: [R] makefile for sweave

2009-11-26 Thread Sundar Dorai-Raj
Is texi2dvi in your PATH? What happens if you open a CMD window and
type texi2dvi at the prompt?

--sundar

On Thu, Nov 26, 2009 at 6:14 AM, Wolfgang Raffelsberger wr...@igbmc.fr wrote:
 Dear all,

 I can't get texi2dvi working right. Basically I'd like to convert a .lex to
 .pdf without having to fiddle with the issue Sweave.sty not being in my
 current directory (as this was sugested in other posts on this list).

 When I'm in the R-Gui I can get the help via
 ?texi2dvi
 (So I conclude its installed.)

 However, when I try to use it to concert a .tex to .pdf I get trouble ...

 For example :
 A)
 The file test02.r contains :
 Sweave(Sweave_test01.rnw)
 library(tools)
 texi2dvi(Sweave_test01.tex, pdf =T)

 Now, when I run on the linux command line :
 R --vanilla -q  test02.r

 I get :
 Sweave(Sweave_test01.rnw)
 Writing to file Sweave_test01.tex
 Processing code chunks ...
 1 : term hide (label=chunk_ini)
 2 : term verbatim eps pdf (label=Fig01)
 3 : term tex (label=packageVersionInfo)
 Loading required package: xtable

 You can now run LaTeX on 'Sweave_test01.tex'
 library(tools)
 texi2dvi(Sweave_test01.tex, pdf =T)
 Error in texi2dvi(Sweave_test01.tex, pdf = T) :
  Running 'texi2dvi' on 'Sweave_test01.tex' failed.
 Messages:
 sh: texi2dvi: command not found
 Execution halted


 B)
 In a previous message on this list I found the following command line(s)
 suggested, but I my case it won't work

 star5_R_test_ R CMD texi2dvi --help
 /usr/local/lib64/R/bin/Rcmd: line 62: exec: texi2dvi: not found

 similarly, when execute (as sugested) I get the same error message

 star5_R_test_ R CMD texi2dvi -p Sweave_test01.tex
 /usr/local/lib64/R/bin/Rcmd: line 62: exec: texi2dvi: not found


 I don't understand how can a command can be present (= installed) and still
 not being found as the error messages suggest ?

 For completeness :
 sessionInfo()
 R version 2.10.0 (2009-10-26)
 x86_64-unknown-linux-gnu

 locale:
 [1] C

 attached base packages:
 [1] stats     graphics  grDevices utils     datasets  methods   base
 other attached packages:
 [1] xtable_1.5-6         mouse4302probe_2.5.0 AnnotationDbi_1.8.1
 [4] mouse4302cdf_2.5.0   MASS_7.3-3           fdrtool_1.2.5      [7]
 limma_3.2.1          affyPLM_1.22.0       preprocessCore_1.8.0
 [10] gcrma_2.18.0         affy_1.24.2          Biobase_2.6.0
 loaded via a namespace (and not attached):
 [1] Biostrings_2.14.3 DBI_0.2-4         IRanges_1.4.4     RSQLite_0.7-3
 [5] affyio_1.14.0     splines_2.10.0    tools_2.10.0



 Thank's in advance,
 Wolfgang


 Charles C. Berry a écrit :

 On Tue, 8 Sep 2009, Welma Pereira wrote:

 Hello, I have the following makefile. The problem is that the
 bibliography
 doesn t work. Any help would be appreciated! I really don t don t what to
 do..:-(



 # The sources of the report (tex, Rnw and other files (e.g. bib, idx))
 TEX_CMPS = Report problem
 RNW_CMPS = prop1 prop2 ExeExps
 OTHER =  Report.bib

 # The name of the report to produce
 all: Report.pdf

 code: $(RNW_CMPS:=.R)

 clean:
   rm -f  *.log *.dvi *~

 # On what does the report depends?
 Report.pdf: $(TEX_CMPS:=.tex) $(RNW_CMPS:=.tex) ${OTHER} makefile
   TEXINPUTS=${TPUTS} pdflatex $
   TEXINPUTS=${TPUTS} pdflatex $

 IIRC

    R CMD texi2dvi -p target.tex

 takes care of finding sweave.sty and running latex thru all the iterations
 needed to build cross-references and a usable pdf.

 Try

    R CMD texi2dvi --help

 at the shell prompt.

 HTH,

 Chuck


   rm *.log
 #    mv *.aux  $(dir $)

 # How to build the tex files from the Rnw (Sweave) files
 %.tex: %.Rnw
   echo library(utils); options(width=60);  Sweave('$') | ${R_PRG}
 --no-save --vanilla
   mv $(notdir $*.tex)  $(dir $)


 # How to build the R code files from the Rnw (Sweave) files
 %.R: %.Rnw
   echo library(utils); Stangle('$') | ${R_PRG} --no-save --vanilla

 %.bib:
   TEXINPUTS=${TPUTS} pdflatex $
   bibtex $

 %.aux:
   TEXINPUTS=${TPUTS} pdflatex $
   bibtex $

 %.idx:
   TEXINPUTS=${TPUTS} pdflatex $
   makeindex $

 cheers!

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


 Charles C. Berry                            (858) 534-2098
                                            Dept of Family/Preventive
 Medicine
 E mailto:cbe...@tajo.ucsd.edu                UC San Diego
 http://famprevmed.ucsd.edu/faculty/cberry/  La Jolla, San Diego 92093-0901

 __

 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
 Wolfgang Raffelsberger, PhD
 Laboratoire de BioInformatique et Génomique Intégratives
 IGBMC,  1 rue Laurent Fries,  67404 Illkirch  Strasbourg,  France
 Tel (+33) 388 65 3300         Fax (+33) 388 65 3276
 wolfgang.raffelsberger (at) igbmc.fr

 

Re: [R] Why F value and Pr are not show in summary() of an aov() result?

2009-11-22 Thread Sundar Dorai-Raj
It's hard to read your code, so I won't comment on your specific
example. So when all else fails read the documentation for
?summary.aov:

They have columns ‘Df’, ‘Sum Sq’, ‘Mean
 Sq’, as well as ‘F value’ and ‘Pr(F)’ if there are non-zero
 residual degrees of freedom.

So if you do df.residual(afit), is it 0?

--sundar

On Sun, Nov 22, 2009 at 7:19 AM, Peng Yu pengyu...@gmail.com wrote:
 I have the following code. I'm wondering why summary() doesn't show F
 value and Pr?

 Rscript multi_factor.R
 a=3
 b=4
 c=5
 d=6
 e=7

 A=1:a
 B=1:b
 C=1:c
 D=1:d
 E=1:e

 X=matrix(nr=a*b*c*d*e,nc=5)
 colnames(X)=LETTERS[1:5]

 for(i_a in 1:a-1) {
 +   for(i_b in 1:b-1) {
 +     for(i_c in 1:c-1) {
 +       for(i_d in 1:d-1) {
 +         for(i_e in 1:e-1) {
 +           X[(((i_a * b + i_b) * c + i_c) * d + i_d) * e + i_e + 1, ]
 = c(i_a+1, i_b+1, i_c+1, i_d+1, i_e+1)
 +         }
 +       }
 +     }
 +   }
 + }

 Y=matrix(nr=a*b*c*d*e,nc=1)
 for(i in 1:(a*b*c*d*e)) {
 +   fa=X[i,'A']
 +   fb=X[i,'B']
 +   fc=X[i,'C']
 +   fd=X[i,'D']
 +   fe=X[i,'E']
 +
 +   Y[i,1]= fa +fb +fc +fe +fa*fb +fa*fc +fb*fc +fa*fe +fc*fe
 +fa*fb*fc +fa*fc*fe + rnorm(1)
 + }

 aframe = data.frame(
 +     A=as.factor(X[,'A'])
 +     , B=as.factor(X[,'B'])
 +     , C=as.factor(X[,'C'])
 +     , D=as.factor(X[,'D'])
 +     , E=as.factor(X[,'E'])
 +     ,Y)

 afit=aov(Y ~ A * B * C * D * E, aframe)

 summary(afit)
             Df  Sum Sq Mean Sq
 A             2 1512240  756120
 B             3  453324  151108
 C             4 2549895  637474
 D             5       2  0.3693
 E             6 1451057  241843
 A:B           6   33875    5646
 A:C           8  189839   23730
 B:C          12   56024    4669
 A:D          10       7       1
 B:D          15      25       2
 C:D          20      18       1
 A:E          12  107574    8964
 B:E          18      21       1
 C:E          24  180413    7517
 D:E          30      16       1
 A:B:C        24    4167     174
 A:B:D        30      37       1
 A:C:D        40      42       1
 B:C:D        60      63       1
 A:B:E        36      30       1
 A:C:E        48   13298     277
 B:C:E        72      62       1
 A:D:E        60      79       1
 B:D:E        90      87       1
 C:D:E       120     122       1
 A:B:C:D     120     140       1
 A:B:C:E     144     131       1
 A:B:D:E     180     145       1
 A:C:D:E     240     225       1
 B:C:D:E     360     398       1
 A:B:C:D:E   720     713       1

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


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


Re: [R] denoting max value in ylim

2009-11-20 Thread Sundar Dorai-Raj
ylim = c(0, max(log10(D10$Part.P)))

Make sure you remove any 0s or NAs before computing the max though.

--sundar

On Fri, Nov 20, 2009 at 6:12 AM, helene frigstad
helenefrigs...@hotmail.com wrote:

 Hi,

 is there any way to set the ylim range from zero to whatever is the max
 value in that dataset? I am plotting many similar plots to the one below,
 and would like to avoid having to find the max value each time.


 plot (D10$Part.P ~ D10$Klorofyll,pch=16,log = xy, xlab = (Chla), ylab =
 (POP), ylim = c (0, ???))
        abline(m3, untf=TRUE, lty=1,col=blue)
        text(5, 0.05,paste(round(glm(D10$Part.P ~ D10$Klorofyll, data = D10, 
 family
 = Gamma(link =      identity))$coef, 2),collapse =  ))

 thank you very much for your time and help.

 Best regards,
 Helene Frigstad
 --
 View this message in context: 
 http://old.nabble.com/denoting-max-value-in-ylim-tp26441590p26441590.html
 Sent from the R help mailing list archive at Nabble.com.

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


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


Re: [R] lapply() not converting columns to factors (no error message)

2009-11-16 Thread Sundar Dorai-Raj
Works for me:

x - 
read.csv(url(http://dc170.4shared.com/download/153147281/a5c78386/Testvcomp10.csv?tsid=20091116-075223-c3093ab0;))
names(x)
x[2:13] - lapply(x[2:13], factor)

 levels(x$P1L55)
[1] 0 1
 is.factor(x$P1L96)
[1] TRUE

 sessionInfo()
R version 2.10.0 (2009-10-26)
i386-apple-darwin9.8.0

locale:
[1] en_US.UTF-8/en_US.UTF-8/C/C/en_US.UTF-8/en_US.UTF-8

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

other attached packages:
[1] lattice_0.17-26

loaded via a namespace (and not attached):
[1] grid_2.10.0  tools_2.10.0

On Mon, Nov 16, 2009 at 4:50 AM, A Singh aditi.si...@bristol.ac.uk wrote:
 Sorry, my file is at:


 http://www.4shared.com/file/153147281/a5c78386/Testvcomp10.html


 --
 A Singh
 aditi.si...@bristol.ac.uk
 School of Biological Sciences
 University of Bristol

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


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


Re: [R] lapply() not converting columns to factors (no error message)

2009-11-16 Thread Sundar Dorai-Raj
Could it be you have factor redefined in your workspace? Have you
tried it in a clean directory? I.e. a directory where no .RData
exists?

On Mon, Nov 16, 2009 at 5:07 AM, A Singh aditi.si...@bristol.ac.uk wrote:
 Oh, strange!

 I thought it might be a problem with the 'base' package installation,
 because the same thing's worked for me too before but won't do now.

 I tried to reinstall it (base), but R says its there already which I
 expected it to be anyway.

 I don't quite know where the issue is. Very odd.


 --On 16 November 2009 04:59 -0800 Sundar Dorai-Raj sdorai...@gmail.com
 wrote:

 Works for me:

 x -
 read.csv(url(http://dc170.4shared.com/download/153147281/a5c78386/Testvc
 omp10.csv?tsid=20091116-075223-c3093ab0)) names(x)
 x[2:13] - lapply(x[2:13], factor)

 levels(x$P1L55)

 [1] 0 1

 is.factor(x$P1L96)

 [1] TRUE

 sessionInfo()

 R version 2.10.0 (2009-10-26)
 i386-apple-darwin9.8.0

 locale:
 [1] en_US.UTF-8/en_US.UTF-8/C/C/en_US.UTF-8/en_US.UTF-8

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

 other attached packages:
 [1] lattice_0.17-26

 loaded via a namespace (and not attached):
 [1] grid_2.10.0  tools_2.10.0

 On Mon, Nov 16, 2009 at 4:50 AM, A Singh aditi.si...@bristol.ac.uk
 wrote:

 Sorry, my file is at:


 http://www.4shared.com/file/153147281/a5c78386/Testvcomp10.html


 --
 A Singh
 aditi.si...@bristol.ac.uk
 School of Biological Sciences
 University of Bristol

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




 --
 A Singh
 aditi.si...@bristol.ac.uk
 School of Biological Sciences
 University of Bristol






__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Trellis settings get lost when printing to pdf

2009-11-13 Thread Sundar Dorai-Raj
Did you make the changes before or after starting the device:

library(lattice)
## before doesn't change the settings on the device:
trellis.par.set(plot.symbol = list(col = red))
trellis.device(pdf, file = tmp.pdf)
xyplot(1 ~ 1)
dev.off()

## after does
trellis.device(pdf, file = tmp.pdf)
trellis.par.set(plot.symbol = list(col = red))
xyplot(1 ~ 1)
dev.off()

I never do things like this, though. I would suggest creating a theme
instead and supplying it to xyplot (or whatever plot you're using)
using par.settings:

my.theme - list(plot.symbol = list(col = red))
trellis.device(pdf, file = tmp.pdf)
xyplot(1 ~ 1, par.settings = my.theme)
dev.off()

HTH,

--sundar


2009/11/13 Joel Fürstenberg-Hägg joel_furstenberg_h...@hotmail.com:

 Hi all,



 I've got some problems when changing the trellis settings for the lattice 
 plots. The plots look exactly as I want them to when calling show.settings() 
 as well as when plotting them in the graphical window. But when printing to a 
 pdf file, none of the settings are used!? Does anyone know what might have 
 happened? Because the when changing the trellis settings, these should remain 
 in the new state until you close R right..?



 # Change settings for the boxplot appearance
 new.dot=trellis.par.get(box.dot)
 new.rectangle=trellis.par.get(box.rectangle)
 new.umbrella=trellis.par.get(box.umbrella)
 new.symbol=trellis.par.get(plot.symbol)
 new.strip.background=trellis.par.get(strip.background)
 new.strip.shingle=trellis.par.get(strip.shingle)
 new.dot$pch=|
 new.dot$col=black
 new.rectangle$col=black
 new.rectangle$fill=grey65
 new.umbrella$col=black
 new.umbrella$lty=1 # Continous line, not dotted
 new.symbol$col=black
 new.strip.background$col=grey87 # Background colour in the upper label
 new.strip.shingle$col=black # Border colour around the upper label
 trellis.par.set(box.dot=new.dot, box.rectangle=new.rectangle, 
 box.umbrella=new.umbrella, plot.symbol=new.symbol, 
 strip.background=new.strip.background, strip.shingle=new.strip.shingle)



 Best regards,



 Joel

 _
 Nya Windows 7 - Hitta en dator som passar dig! Mer information.
 http://windows.microsoft.com/shop
        [[alternative HTML version deleted]]

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


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


Re: [R] tapply function

2009-11-03 Thread Sundar Dorai-Raj
you must have missing values in data. Try

tapply(data, group, mean, na.rm = TRUE)

If that's not the case, read the bottom of this email about the posting guide.

HTH,

--sundar

On Tue, Nov 3, 2009 at 5:28 AM, FMH kagba2...@yahoo.com wrote:
 Hi,

 I tried to use tapply function to find the mean of the data in each group as 
 the following command, but the result are NA, as there are several missing 
 values in each group.

 tapply(data,group,mean)

 Could someone please advice me the way to  ignore the missing data in order 
 for the fucntion to run successfully?

 Thanks

 Fir




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


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


Re: [R] Issue with %in% - not matching identical rows in data frames

2009-11-03 Thread Sundar Dorai-Raj
?%in% says x and table must be vectors. You supplied
data.frames. So %in% is coercing your today.sequence to a vector using

as.character(today.sequence)

Perhaps you should paste the columns together first:

x - do.call(paste, c(sequence, sep = ::))
table - do.call(paste, c(today.sequence, sep = ::))
x[7] %in% table

I'm not sure if this is what you want/need, but it does match your example.

HTH,

--sundar

On Tue, Nov 3, 2009 at 7:53 AM, Kaushik Krishnan
kaushik.s.krish...@gmail.com wrote:
 Hi folks

 I have two data frames.  I know that the nth (let's say the 7th) row
 in the first data frame (sequence) is there in the second
 (today.sequence).  When I try to check that by doing 'sequence[7,]
 %in% today.sequence', I get all FALSE when it should be all TRUE.

 I'm certain I'm making some trivial mistake.  Any solutions?

 The code to recreate the data frames and see for yourself is:
 
 sequence - structure(list(DATE = structure(c(14549, 14549, 14553, 14550,
 14557, 14550, 14551, 14550), class = Date), DATASET = c(1L,
 2L, 1L, 2L, 2L, 3L, 3L, 4L), REP = c(1L, 0L, 2L, 2L, 3L, 0L,
 1L, 0L), WRONGS_ABS = c(0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L), WRONGS_RATIO = c(0L,
 0L, 0L, 0L, 0L, 0L, 0L, 0L), DONE = c(1L, 1L, 0L, 1L, 0L, 1L,
 0L, 0L)), .Names = c(DATE, DATASET, REP, WRONGS_ABS,
 WRONGS_RATIO, DONE), class = data.frame, row.names = c(NA,
 -8L))

 today.sequence - structure(list(DATE = structure(c(14551, 14550),
 class = Date),
    DATASET = 3:4, REP = c(1L, 0L), WRONGS_ABS = c(0L, 0L),
 WRONGS_RATIO = c(0L,
    0L), DONE = c(0L, 0L)), .Names = c(DATE, DATASET, REP,
 WRONGS_ABS, WRONGS_RATIO, DONE), row.names = 7:8, class = data.frame)

 sequence[7,] #You should see '2009-11-03       3   1          0
    0    0'

 today.sequence #You can clearly see that sequence [7,] is the first
 row in today.sequence

 sequence[7,] %in% today.sequence #This should show 'TRUE TRUE TRUE
 TRUE TRUE TRUE'.  Instead
 # it shows 'FALSE FALSE FALSE FALSE FALSE FALSE'
 

 Thanks

 --
 Kaushik Krishnan
 (kaushik.s.krish...@gmail.com)

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


__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 can I run a function to a piece of text?

2009-10-16 Thread Sundar Dorai-Raj
Based solely on what you told us, this can be done using eval(parse(text=...))

cmd - sprintf(mean(%s), script)
eval(parse(text = cmd))

However, with more context, there may be a better solution. See, for example,

install.packages(fortunes)
library(fortunes)
fortune(parse())

HTH,

--sundar

On Fri, Oct 16, 2009 at 11:39 AM, Javier PB
j.perez-barbe...@macaulay.ac.uk wrote:

 Dear users,

 I got really stuck trying to apply a function to a piece of code that I
 created using different string functions.

 To make things really easy, this is a wee example:

 x-c(1:10)
 script-x, trim = 0, na.rm = FALSE        ##script created by a number of
 paste() and rep() steps
 mean(script)                                       ##function that I want to
 apply: doesn't work

 Is there any way to convert the script class so that the function mean()
 can read it as if it were text typed in the console?

 Thanks and have a superb day

 Javier



 --
 View this message in context: 
 http://www.nabble.com/How-can-I-run-a-function-to-a-piece-of-text--tp25930315p25930315.html
 Sent from the R help mailing list archive at Nabble.com.

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


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


Re: [R] Error in family$family : $ operator is invalid for atomic vectors

2009-10-11 Thread Sundar Dorai-Raj
Check to see if you have an old workspace being loaded. You might have an
object called 'family' which you might need to remove.

--sundar

On Oct 11, 2009 12:15 PM, romunov romu...@gmail.com wrote:

Thank you Jorge and Barry for your input.

I've fiddled around a bit and as a result, am even more confused. If I start
R console via Notepad++ (I use Npp2R) and execute the model1, it goes
through just fine. Here is the sessionInfo() for this working session:

 sessionInfo()
R version 2.9.2 (2009-08-24)
i386-pc-mingw32

locale:
LC_COLLATE=Slovenian_Slovenia.1250;LC_CTYPE=Slovenian_Slovenia.1250;LC_MONETARY=Slovenian_Slovenia.1250;LC_NUMERIC=C;LC_TIME=Slovenian_Slovenia.1250

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

loaded via a namespace (and not attached):
[1] tools_2.9.2

And if I run R normally, via an icon from the desktop (Rgui.exe) it gives
the aforementioned error. Here is the sessionInfo() for non-working
session. Is it possible that grid, reshape, plyr, ggplot2 and proto could be
causing this? If so, how can I prevent them from loading automatically or
unloading from a live session?

 sessionInfo()
R version 2.9.2 (2009-08-24)
i386-pc-mingw32

locale:
LC_COLLATE=Slovenian_Slovenia.1250;LC_CTYPE=Slovenian_Slovenia.1250;LC_MONETARY=Slovenian_Slovenia.1250;LC_NUMERIC=C;LC_TIME=Slovenian_Slovenia.1250

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

other attached packages:
[1] reshape_0.8.3 plyr_0.1.9proto_0.3-8

loaded via a namespace (and not attached):
[1] ggplot2_0.8.3


Cheers,
Roman



On Sun, Oct 11, 2009 at 6:32 PM, Jorge Ivan Velez
jorgeivanve...@gmail.comwrote:

 Hi Romain,  It works for me:   model1 - glm(as.vector(x)
~dept*sex*admit,poisson)  model1  ...

[[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] How to speed up R with version 2.9.2?

2009-10-02 Thread Sundar Dorai-Raj
Another possibility is a very large .RData file in the directory where
you're starting R. You can try

Rgui --no-restore

(I don't have windows, so I'm not sure if this an option with RGui,
though I know it is with R.)

--sundar

On Fri, Oct 2, 2009 at 8:50 AM, Gabor Grothendieck
ggrothendi...@gmail.com wrote:
 Its under 5 seconds on my Vista laptop.  Do you have any startup files?  If
  Rgui --vanilla
 is much faster then your startup files are the problem.

 On Fri, Oct 2, 2009 at 11:45 AM, FMH kagba2...@yahoo.com wrote:
 Thank you for your answer. I'm using Win XP with 2GB RAM in memory.

 Cheers
 Fir



 - Original Message 
 From: stephen sefick ssef...@gmail.com
 To: FMH kagba2...@yahoo.com
 Cc: r-help@r-project.org
 Sent: Fri, October 2, 2009 4:38:10 PM
 Subject: Re: [R] How to speed up R with version 2.9.2?

 You're fine, but please do read the posting guide.  What OS etc.
 Where you doing anything else on the computer?  Is this a RAM
 limitation?  I have 2.9.2 running on two flavours of linux, mac os x
 and windows all 2.9.2 and there doesn't seem to be a problem.
 regards,

 Stephen

 On Fri, Oct 2, 2009 at 10:35 AM, FMH kagba2...@yahoo.com wrote:
 Dear All,

 I'm sorry if my question does not suit with this R group.

 I have recently installed R software with version 2.9.2, but i found the 
 program took almost 1 minute as soon as it was opened, before it can be 
 used. However, the previous version 2.9.1 only take few seconds after the 
 menu bar was clicked. This circumstance has caused me to wait for couple of 
 minutes as several R windows were opened simultaneously.

 Are there any ways to speed up on this 2.9.2 version? Could someone give 
 some hints, please?

 Thank you
 Fir




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




 --
 Stephen Sefick

 Let's not spend our time and resources thinking about things that are
 so little or so large that all they really do for us is puff us up and
 make us feel like gods.  We are mammals, and have not exhausted the
 annoying little problems of being mammals.

                                 -K. Mullis





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


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


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


Re: [R] Skipping missing files when importing data

2009-09-20 Thread Sundar Dorai-Raj
Try ?file.exists.

if (file.exists(fxxx)) {
  read.table(fxxx)
} else {
  cat(\, fxxx, \ is missing\n, sep = )
}

HTH,

--sundar

On Sun, Sep 20, 2009 at 9:28 PM, jiangrm jian...@gmail.com wrote:
 Trying to import a bunch of data files named like f001, f002, f999. Some 
 of the files may be
 missing and the missing files vary from time to time.

 Used for loop and read.table. When it reaches the missing file (say f100), it 
 shows:

 Error in file(file, r) : cannot open the connection
 In addition: Warning message:
 In file(file, r) :
  cannot open file 'f100': No such file or directory

 and the program stops.

 How can I skip the missing ones and keep the program running? Guess either 
 checking the validity of
 filenames, or ignore the error message may work. Which functions should be 
 used or any better ideas?


 -RJ

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


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


Re: [R] xyplot: Can I identify groups but not use them for regression?

2009-09-18 Thread Sundar Dorai-Raj
I think this ought to work for you:

library(lattice)
set.seed(42)
d - data.frame(year  = c(rep(2007,12), rep(2008,12)),
treatment = rep(LETTERS[1:3], each = 4, times = 2))
d$cover - rnorm(nrow(d))
d$variable - rnorm(nrow(d))

xyplot(variable ~ cover | year, d,
   panel = function(x, y, ...) {
 panel.superpose(x, y, ...)
 panel.lmline(x, y, ...)
   },
   groups = treatment)

HTH,

--sundar

On Fri, Sep 18, 2009 at 3:42 PM, Seth W Bigelow sbige...@fs.fed.us wrote:
 I wish to identify groups representing different treatments, but to plot
 them and do a regression using a continuous variable (cover)
 ignoring the groupings.

 d$year - NA
 d$year -c(rep(2007,12), rep(2008,12))
 d$treatment - c(rep(A,4),rep(B,4),rep(C,4), rep(A,4), rep(B,4),
 rep(C,4))
 d$cover - rnorm(24)
 d$variable - rnorm(24)

 xyplot(variable ~ cover | year, d,
        type=c(p,r),
        groups=treatment
        )

 As it stands, a different regression line is plotted for each treatment.
 Oh, and how do I display the actual numeric value of year (e.g., 2007)
 in the strip, rather than the word year?

 --Seth



 Dr. Seth  W. Bigelow
 Biologist, USDA-FS Pacific Southwest Research Station
 1731 Research Park Drive, Davis California
        [[alternative HTML version deleted]]

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


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


Re: [R] Lattice graph tweaking

2009-08-25 Thread Sundar Dorai-Raj
A reproducible example would be nice.

Try grid = FALSE for the first question, though I'm unaware which
lattice plot you are using where the default is TRUE. So I can't
guarantee that will even work.

For your second question, add

par.settings = list(strip.background = list(col = white))

to your call (e.g. xyplot(..., par.settings = ...)).

To see what other parameters you can set in par.settings, try:

str(trellis.par.get())

HTH,

--sundar

On Tue, Aug 25, 2009 at 6:14 AM, Wallis,
Daviddavid.walli...@imperial.ac.uk wrote:
 To: silwood-r
 Subject: Removing lattice graph gridlines and editing label box colour

 Hi,

 Is it possible to remove the background gridlines from a lattice graph (ie 
 graph made up of multiple individual graphs with annoying blue grid in the 
 backgroun)?

 Also, Is it possible to change the colour of the individual graph label 
 boxes? - ie the default pink boxes above the individual graphs

 Thanks

        [[alternative HTML version deleted]]

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


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


Re: [R] Help with nls and error messages singular gradient

2009-08-25 Thread Sundar Dorai-Raj
Hi, Michael,

I think the SPSS answer is wrong. Your starting values are way off.
Look at this plot for verification:

con - textConnection(time  bod
11 0.47
22 0.74
33 1.17
44 1.42
55 1.60
67 1.84
79 2.19
8   11 2.17)
mydata - read.table(con, header = TRUE)
close(con)

beta - c(3, -0.1) # your initial values
beta - c(2.4979, -2.02456)  # SPSS answer
mycurve - function(x) {
  beta[1]/(1 - exp(beta[1] * x))
}
curve(mycurve, from = 1, to = 11,
  ylim = range(mydata$bod, mycurve(mydata$time)))
points(mydata$time, mydata$bod)

You might want to look at package nls2 which allows a brute force grid
search to find some starting values. Or rethink the equation you're
trying to fit.

HTH,

--sundar

On Tue, Aug 25, 2009 at 9:10 AM, Michael Pearmainmpearm...@google.com wrote:
 Hi All,

 I'm trying to run nls on the data from the study by Marske (Biochemical
 Oxygen Demand Interpretation Using Sum of Squares Surface. M.S. thesis,
 University of Wisconsin, Madison, 1967) and was reported in Bates and Watts
 (1988).

 Data is as follows, (stored as mydata)

  time  bod
 1    1 0.47
 2    2 0.74
 3    3 1.17
 4    4 1.42
 5    5 1.60
 6    7 1.84
 7    9 2.19
 8   11 2.17

 I then run the following;
 #Plot initial curve
 plot(mydata$time, mydata$bod,xlab=Time (in days),ylab=biochemical oxygen
 demand (mg/l) )

 model - nls(bod ~ beta1/(1 - exp(beta2*time)), data =
 mydata, start=list(beta1 = 3, beta2 = -0.1),trace=T)

 The start values are recommended, (I have used these values in SPSS without
 any problems, SPSS returns values of Beta1 = 2.4979 and Beta2 = -2.02 456)

 but return the error message,
 Error in nls(bod ~ beta1/(1 - exp(beta2 * time)), data = mydata, start =
 list(beta1 = 3,  : singular gradient

 Can anyone offer any advice?

 Thanks in advance

 Mike









 --
 Michael Pearmain
 Senior Analytics Research Specialist

 “Statistics are like women; mirrors of purest virtue and truth, or like
 whores to use as one pleases”

 Google UK Ltd
 Belgrave House
 76 Buckingham Palace Road
 London SW1W 9TQ
 United Kingdom
 t +44 (0) 2032191684
 mpearm...@google.com

 If you received this communication by mistake, please don't forward it to
 anyone else (it may contain confidential or privileged information), please
 erase all copies of it, including all attachments, and please let the sender
 know it went to the wrong person. Thanks.

        [[alternative HTML version deleted]]


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



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


Re: [R] Help with nls and error messages singular gradient

2009-08-25 Thread Sundar Dorai-Raj
Another alternative is to use SSlogis which is very similar to the
model you're fitting except with one additional parameter:

Asym - 3
xmid - 0
scal - 10
model - nls(bod ~ SSlogis(time, Asym, xmid, scal), data = mydata)
summary(model)
plot(bod ~ time, mydata)
newdata - data.frame(time = seq(1, 11, length = 100))
lines(newdata$time, predict(model, newdata))

HTH,

--sundar

On Tue, Aug 25, 2009 at 10:05 AM, Sundar Dorai-Rajsdorai...@gmail.com wrote:
 Hi, Michael,

 I think the SPSS answer is wrong. Your starting values are way off.
 Look at this plot for verification:

 con - textConnection(time  bod
 1    1 0.47
 2    2 0.74
 3    3 1.17
 4    4 1.42
 5    5 1.60
 6    7 1.84
 7    9 2.19
 8   11 2.17)
 mydata - read.table(con, header = TRUE)
 close(con)

 beta - c(3, -0.1) # your initial values
 beta - c(2.4979, -2.02456)  # SPSS answer
 mycurve - function(x) {
  beta[1]/(1 - exp(beta[1] * x))
 }
 curve(mycurve, from = 1, to = 11,
      ylim = range(mydata$bod, mycurve(mydata$time)))
 points(mydata$time, mydata$bod)

 You might want to look at package nls2 which allows a brute force grid
 search to find some starting values. Or rethink the equation you're
 trying to fit.

 HTH,

 --sundar

 On Tue, Aug 25, 2009 at 9:10 AM, Michael Pearmainmpearm...@google.com wrote:
 Hi All,

 I'm trying to run nls on the data from the study by Marske (Biochemical
 Oxygen Demand Interpretation Using Sum of Squares Surface. M.S. thesis,
 University of Wisconsin, Madison, 1967) and was reported in Bates and Watts
 (1988).

 Data is as follows, (stored as mydata)

  time  bod
 1    1 0.47
 2    2 0.74
 3    3 1.17
 4    4 1.42
 5    5 1.60
 6    7 1.84
 7    9 2.19
 8   11 2.17

 I then run the following;
 #Plot initial curve
 plot(mydata$time, mydata$bod,xlab=Time (in days),ylab=biochemical oxygen
 demand (mg/l) )

 model - nls(bod ~ beta1/(1 - exp(beta2*time)), data =
 mydata, start=list(beta1 = 3, beta2 = -0.1),trace=T)

 The start values are recommended, (I have used these values in SPSS without
 any problems, SPSS returns values of Beta1 = 2.4979 and Beta2 = -2.02 456)

 but return the error message,
 Error in nls(bod ~ beta1/(1 - exp(beta2 * time)), data = mydata, start =
 list(beta1 = 3,  : singular gradient

 Can anyone offer any advice?

 Thanks in advance

 Mike









 --
 Michael Pearmain
 Senior Analytics Research Specialist

 “Statistics are like women; mirrors of purest virtue and truth, or like
 whores to use as one pleases”

 Google UK Ltd
 Belgrave House
 76 Buckingham Palace Road
 London SW1W 9TQ
 United Kingdom
 t +44 (0) 2032191684
 mpearm...@google.com

 If you received this communication by mistake, please don't forward it to
 anyone else (it may contain confidential or privileged information), please
 erase all copies of it, including all attachments, and please let the sender
 know it went to the wrong person. Thanks.

        [[alternative HTML version deleted]]


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




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


[R] Reg: Creation of own Package and Permanent Dataset in R

2009-07-28 Thread RAJ
Hi,

This is Raj from ClinAsia and we have a small query with respect to R 
Statistical Package. 

Our Query:

Actually while opening R console and R commander we see some packages like car 
and datasets. In these packages we have default datasets. 
For example: Women and Prestige so on. Now we created a Sales dataset 
importing either from excel, xml or text file. Now we are trying to store that 
dataset permanently  in any one of the packages mentioned above (car or 
datasets). I am able to create them temporarily untill that pirticular session.

But once we close the session and try to log into R Console and R Commander. We 
are not able to find the earlier created datasets Sales in the packages (Car 
and Datasets). Kindly suggest how to create permanent datasets in packages and 
also suggest how to create our own packages. 

If possible please send us the code it will be very helpful for us. 

Thanks and Regards,
Raj
ClinAsia
91-40-20010112


[[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] how to check if ... is empty

2009-07-16 Thread Sundar Dorai-Raj
Try

dots - list(...)
if (length(dots) == 0) {
  ## do something
}

On Thu, Jul 16, 2009 at 6:46 AM, Thomas Roth (geb.
Kaliwe)hamstersqu...@web.de wrote:
 Hi,

 I was wondering what would be the best way to check if the three dots
 argument contains any arguments (i.e. does ... contain any arguments or not?
 )

 #Example

 test = function(x,y, ...)
 {
   #Wanted R-Code
   # if(empty(...))
   #    do some calculation


   plot(x,y,...)

 }

 Thanks

 Thomas Roth

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


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


Re: [R] Lattice group colors?

2009-06-22 Thread Sundar Dorai-Raj
Look at show.settings() and str(trellis.par.get()). This will show you
what the default settings are. The group colors are set by the
superpose.* elements (e.g. superpose.line is for group lines). To set
them, I usually create a list and pass it to par.settings. For
example,

my.theme - list(superpose.line = list(col = c(darkred, darkblue),
lty = 1:2))
xyplot(y ~ x, data = mydata, groups = g, par.settings = my.theme,
  auto.key = list(points = FALSE, lines = TRUE))

HTH,

--sundar

On Mon, Jun 22, 2009 at 6:30 AM, Fredrik Karlssondargo...@gmail.com wrote:
 Dear list,

 I have been struggling to find how I would go about changing the
 bakground colors of groups in a lattice barchart in a way so that the
 auto.key generated also does the right thing and pick it up for the
 key.
 I have used the col argument (which I guess is sent to par()) in a
 way so that the colors are like I would want them, but now I guess I
 need to know which part part of the theme I need to change in order to
 make this change permanent for all the plots, and all the keys.

 I am of course thankful for all the help I can get.

 (Also, how does one know these things about the theme variables? Is
 there some documentation somewhere?)

 /Fredrik

 --
 Life is like a trumpet - if you don't put anything into it, you don't
 get anything out of it.

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


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


Re: [R] reading in multiple files

2009-06-09 Thread Sundar Dorai-Raj
You could try:

do.call(rbind, lapply(list.files(path/to/files, full = TRUE), read.csv))

And add more arguments to lapply if the files are not csv, have no header, etc.

--sundar

On Tue, Jun 9, 2009 at 11:18 AM, Erin Hodgesserinm.hodg...@gmail.com wrote:
 Dear R People:

 I have about 6000 files to be read in that I'd like to go to one
 matrix.  There are two columns, 1 line in each file.

 Is there a way to bring them in to produce one matrix or data frame, please?

 Thanks,
 Erin


 --
 Erin Hodgess
 Associate Professor
 Department of Computer and Mathematical Sciences
 University of Houston - Downtown
 mailto: erinm.hodg...@gmail.com

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


__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] find a sequence of characters in a vector

2009-06-05 Thread Sundar Dorai-Raj
use gregexpr and paste

 aze - paste(c(a, z, e), collapse = )
 sequence - paste(c(a,z,e,r,t,a,z,a,z,e,c), collapse = 
 )
 gregexpr(aze, sequence, fixed = TRUE)
[[1]]
[1] 1 8
attr(,match.length)
[1] 3 3

HTH,

--sundar

On Fri, Jun 5, 2009 at 6:22 AM, Ptit_Bleuptit_b...@yahoo.fr wrote:

 Hello,

 I'm just looking for an easy way to find the positions of a complete
 sequence in a bigger vector.
 For example :
 c(a,z,e) in c(a,z,e,r,t,a,z,a,z,e,c)
 and the result should be
 1 8
 that is the positions of the beginning of the complete sequence.

 I tried with %in%, match, is.element but all I get is, for example
 which(c(a,z,e) in c(a,z,e,r,t,a,z,a,z,e,c))
 1 2 3
 meaning that each character is in the bigger vector.

 It must be easy, except for me. Sorry.

 If you have a solution, thanks in advance to share it.
 Have a good week-end,
 Ptit Bleu.

 --
 View this message in context: 
 http://www.nabble.com/find-a-sequence-of-characters-in-a-vector-tp23888063p23888063.html
 Sent from the R help mailing list archive at Nabble.com.

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


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


Re: [R] error message re: max(i), but code and output seen O.K.

2009-05-20 Thread Sundar Dorai-Raj
This error is thrown if the argument to max is either NULL or length zero:

[~] Rscript -e max(NULL)
[1] -Inf
Warning message:
In max(NULL) : no non-missing arguments to max; returning -Inf
[~] Rscript -e max(numeric(0))
[1] -Inf
Warning message:
In max(numeric(0)) : no non-missing arguments to max; returning -Inf

HTH,

--sundar

On Wed, May 20, 2009 at 11:23 AM, Kirsten Miles sirole@gmail.com wrote:
 I have a researcher who is consistently get the warning message:

 In max(i) : no non-missing arguments to max; returning -Inf

 Best as I can tell the code is working properly and the output is as
 expected. I would like some help in understanding why he is getting this
 error message and what its implications are.  I have his code.

 Sincerely,
 Kirsten Miles
 Support Specialist
 Research Computing Lab
 Charles L. Brown Science and Engineering Library

 kd...@virginia.edu

        [[alternative HTML version deleted]]

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


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


Re: [R] what is wrong with this code?

2009-05-19 Thread Sundar Dorai-Raj
You're missing a ) off end of the first line. You should consider
using an editor (e.g. ESS/Emacs) that does parentheses matching. I
found this in less than 5 sec (less time than I'm taking to write you
a note) by cut and pasting in Emacs.

--sundar

On Tue, May 19, 2009 at 12:52 PM, deanj2k dl...@le.ac.uk wrote:

 dlogl - -(n/theta)-sum((y/(theta)^2)*((1-exp(y/theta))/(1+exp(y/theta)))

 d2logl - (n/theta^2) - sum((-2y/theta^3)*(1-exp(y/theta))/(1+exp(y/theta)))
 - sum(((2*y/theta^4)*exp(y/theta))/((1+exp(y/theta))^2))

 returns the error message:
 Error: unexpected symbol in:
 dlogl - -(n/theta)-sum((y/(theta)^2)*((1-exp(y/theta))/(1+exp(y/theta)))
 d2logl

 do you know what i have done wrong
 --
 View this message in context: 
 http://www.nabble.com/what-is-wrong-with-this-code--tp23623227p23623227.html
 Sent from the R help mailing list archive at Nabble.com.

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


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


Re: [R] convert large integers to hex

2009-05-07 Thread Sundar Dorai-Raj
Thanks for both answers. In the end I decided to use Gabor's bc package.

Thanks,

--sundar

On Thu, May 7, 2009 at 5:10 AM, Gabor Grothendieck
ggrothendi...@gmail.com wrote:
 There is an interface between R and bc -- not on CRAN but available
 from its home page here:
 http://r-bc.googlecode.com

 source(http://r-bc.googlecode.com/svn/trunk/R/bc.R;)
 bc(obase = 16; 123456789123456789, retclass = character)
 [1] 1B69B4BACD05F15


 On Wed, May 6, 2009 at 9:59 PM, jim holtman jholt...@gmail.com wrote:
 You can use the 'bc' command (use Cygwin if on Windows);

 /cygdrive/c: bc
 bc 1.06
 Copyright 1991-1994, 1997, 1998, 2000 Free Software Foundation, Inc.
 This is free software with ABSOLUTELY NO WARRANTY.
 For details type `warranty'.
 x=6595137340052185552
 obase=16
 x
 5B86A277DEB9A1D0

 You can call this from R.

 On Wed, May 6, 2009 at 3:26 PM, Sundar Dorai-Raj sdorai...@gmail.comwrote:

 Hi,

 I'm wondering if someone has solved the problem of converting very
 large integers to hex. I know about format.hexmode and as.hexmode, but
 these rely on integers. The numbers I'm working with are overflowing
 and losing precision. Here's an example:

 x - 6595137340052185552 # stored as character
 as.integer(x) # warning about inaccurate conversion
 format.hexmode(as.numeric(x)) # warnings about loss of precision
 as.hexmode(x) # more warnings and does not do what I expected

 I'm planning on writing a function that will do this, but would like
 to know if anybody already has a solution. Basically, I would like the
 functionality of format.hexmode on arbitrarily large integers.

 Thanks,

 --sundar

 __
 R-help@r-project.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.




 --
 Jim Holtman
 Cincinnati, OH
 +1 513 646 9390

 What is the problem that you are trying to solve?

        [[alternative HTML version deleted]]

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



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


[R] convert large integers to hex

2009-05-06 Thread Sundar Dorai-Raj
Hi,

I'm wondering if someone has solved the problem of converting very
large integers to hex. I know about format.hexmode and as.hexmode, but
these rely on integers. The numbers I'm working with are overflowing
and losing precision. Here's an example:

x - 6595137340052185552 # stored as character
as.integer(x) # warning about inaccurate conversion
format.hexmode(as.numeric(x)) # warnings about loss of precision
as.hexmode(x) # more warnings and does not do what I expected

I'm planning on writing a function that will do this, but would like
to know if anybody already has a solution. Basically, I would like the
functionality of format.hexmode on arbitrarily large integers.

Thanks,

--sundar

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] setting trellis auto.key color values

2009-05-05 Thread Sundar Dorai-Raj
Set the colors in graph.sets and not auto.key.

graph.sets - list(axis.text = list(cex = 0.65),
  par.ylab.text = list(cex = 1.25),
  par.xlab.text = list(cex = 1.25),
  superpose.polygon = list(col = 3:5))

Then remove the col = 3:5 from auto.key and barchart.

Also, you can simplify your code by removing gator_IR$ and including
data = gator_IR. I.e.

 barchart(MEAN ~ Hydro | as.factor(IR_ID),
 data = gator_IR, layout = c(4, 1),
 groups = Rain, ylim = c(0, 1), ...)

HTH,

--sundar

On Tue, May 5, 2009 at 8:32 AM,  steve_fried...@nps.gov wrote:


 I'm working with Lattice graphics and I would like very much to color code
 the auto.key fill color with the same corresponding colors that I use in
 the panels.  I've looked on the web for clues, and on the CRAN-R help sites
 searching on trellis auto.key color and variations, unfortunately the
 responses there are not very specific.

  Would someone please explain   I have the Book, if you can point me to the
 pages that explain this I'd appreciate that too



 graph.sets - list(axis.text = list(cex = 0.65),
              par.ylab.text = list(cex = 1.25),
              par.xlab.text = list(cex = 1.25))


   barchart(gator_IR$MEAN ~ gator_IR$Hydro |
 as.factor(gator_IR$IR_ID),layout=c(4,1),col = c(3:5),
                 groups=gator_IR$Rain, ylim=c(0,1), par.settings =
 graph.sets,
                 main = Alligator Nesting Performance, ylab= Mean HSI,
                 auto.key = list(top, columns=3, col=c(3:5))


 this script creates the graph nicely, with the qualification that the color
 for the key titles are the correct, but the filling colors are default
 pastels.  Where do I change them ?


 Windows XP  with R 2.8.1

 Thank you.

 Steve

 Steve Friedman Ph. D.
 Spatial Statistical Analyst
 Everglades and Dry Tortugas National Park
 950 N Krome Ave (3rd Floor)
 Homestead, Florida 33034

 steve_fried...@nps.gov
 Office (305) 224 - 4282
 Fax     (305) 224 - 4147

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


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


Re: [R] evaluate a expression

2009-05-02 Thread Sundar Dorai-Raj
Hi, Ning,

Try: eval(parse(text = expr))

HTH,

--sundar

On Sat, May 2, 2009 at 5:39 AM, Ning Ma pnin...@gmail.com wrote:
 Hi,

 I am new to R. Can anyone tell me how to evaluate an expression stored
 in a string?
 such as:
 expr - 3*5
 I want to get the result 15.

 Thanks in advance.

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


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

2009-04-26 Thread Sundar Dorai-Raj
Try (re)reading ?qqnorm. Use datax = TRUE.

--sundar

On Sun, Apr 26, 2009 at 4:37 PM, Chris_d dewhurstch...@gmail.com wrote:

 Hi all,
       I have just started using R to produce qqnorm plots. I am trying to
 switch the x and y axes so that the theoretical values are plotted on the y
 axis and my data on the x axis. Can anyone help me with this?

 Thanks
 --
 View this message in context: 
 http://www.nabble.com/Flipping-axes-of-qqnorm-tp23248007p23248007.html
 Sent from the R help mailing list archive at Nabble.com.

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


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


Re: [R] Cannot clean infinite values

2009-04-26 Thread Sundar Dorai-Raj
Use ?is.infinite

inf - is.infinite(data)
data[inf] - 0.3 * sign(data[inf])

On Sun, Apr 26, 2009 at 5:44 PM, Nigel Birney na...@cam.ac.uk wrote:

 Hello all,

 I have to import numeric data from file but found it contains Infinite
 values which need to be eliminated. I tried to replace them in this way:

        data[which(data==-Inf)] - -0.3
        data[which(data==+Inf)] -  0.3

 But, somehow, the Infinite values stayed there. Any suggestions?

 regards,

 N.
 --
 View this message in context: 
 http://www.nabble.com/Cannot-clean-infinite-values-tp23248409p23248409.html
 Sent from the R help mailing list archive at Nabble.com.

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


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


Re: [R] Setting lattice par parameters

2009-04-23 Thread Sundar Dorai-Raj
Because you're not calling trellis.par.set correctly. It should be:

trellis.par.set(par.ylab.text = list(cex = 0.65), par.xlab.text =
list(cex = 0.65))

However, I usually do things like this:

my.theme - list(par.ylab.text = list(cex = 0.65), par.xlab.text =
list(cex = 0.65))
barchart(..., par.settings = my.theme)

so the settings are only changed for the current plot and not globally.

HTH,

--sundar

On Thu, Apr 23, 2009 at 6:25 AM,  steve_fried...@nps.gov wrote:

 Hello

 I'm plotting a large suite of barcharts and need to modify the size of the
 text for both the yaxis and xaxis labels.

 I've tried using the following:

 trellis.par.set(list(par.ylab.text = list(cex = 0.65)),
 trellis.par.set(list = par.xlab.text = list(cex = 0.65

 On inspection,  however after I invoke this line,

  trellis.par.get(par.ylab.text)
  trellis.par.get(par.xlab.text)

 It looks like the parameters have not been modified.

 Do I need to do something different than this approach ?

 Thank you very much in advance.

 Steve

 Steve Friedman Ph. D.
 Spatial Statistical Analyst
 Everglades and Dry Tortugas National Park
 950 N Krome Ave (3rd Floor)
 Homestead, Florida 33034

 steve_fried...@nps.gov
 Office (305) 224 - 4282
 Fax     (305) 224 - 4147

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


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


Re: [R] question on using lattice panel plots

2009-04-16 Thread Sundar Dorai-Raj
Try:

z - cbind(rep(c(BIC, hist), each = 150), rep(rep(c(5, 10, 30),
each = 50),2))

z - as.data.frame(z)

z - cbind(z, runif(300))
names(z) - c(Method, sigma, Error)
z$sigma - factor(z$sigma, c(5, 10, 30))
library(lattice)

sigma - as.numeric(levels(z$sigma))
sigmaExprList - lapply(sigma, function(s) bquote(sigma == .(s)))
sigmaExpr - as.expression(sigmaExprList)
bwplot(Error~Method | sigma, data = z,
   horiz = F, xlab = Method,
   strip = strip.custom(var.name = sigmaExpr,
 strip.levels = FALSE, strip.names = TRUE),
   layout = c(3,1))

HTH,

--sundar

On Thu, Apr 16, 2009 at 12:43 PM, Ranjan Maitra mai...@iastate.edu wrote:
 Hi,

 I think this question is best explained using the following
 self-contained toy example:




 ## cut code here and paste to R window

 z - cbind(rep(c(BIC, hist), each = 150), rep(rep(c(5, 10, 30),
 each = 50),2))

 z - as.data.frame(z)

 z - cbind(z, runif(300))

 names(z) - c(Method, sigma, Error)

 library(lattice)

 bwplot(Error~Method | sigma, data = z, horiz = F, xlab = Method,
 layout = c(3,1))


 ## end code




 Now the question:

 I would like the panels to be in the order of sigma, i. e. 5, 10, 30
 and not 10, 30 and 5 as is currently the case. Is this possible?

 Not to seek too much indulgence, but to ask anyway, I wonder if it is
 possible to have a Greek sigma = 5, a Greek sigma = 10 and a Greek
 sigma = 30. (Sort of what we would get using expression(sigma == 5),
 expression(sigma == 10), expression(sigma == 10) on base R figures).

 Please let me know if my question is not clear.

 Many thanks for any suggestions and help and best wishes!
 Ranjan

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


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


Re: [R] question on using lattice panel plots

2009-04-16 Thread Sundar Dorai-Raj
Sorry, that should be:

sigma - as.numeric(levels(z$sigma))
sigmaExprList - lapply(sigma, function(s) bquote(sigma == .(s)))
sigmaExpr - as.expression(sigmaExprList)
bwplot(Error~Method | sigma, data = z,
   horiz = F, xlab = Method,
   strip = function(which.given, which.panel, var.name,
strip.levels = FALSE,
strip.names = TRUE, ...) {
 strip.default(which.given, which.panel,
   var.name = sigmaExpr[which.panel],
   strip.levels = FALSE,
   strip.names = TRUE, ...)
   },
   layout = c(3,1))

Not sure how to do this with strip.custom.

--sundar

On Thu, Apr 16, 2009 at 1:20 PM, Sundar Dorai-Raj sdorai...@gmail.com wrote:
 Try:

 z - cbind(rep(c(BIC, hist), each = 150), rep(rep(c(5, 10, 30),
 each = 50),2))

 z - as.data.frame(z)

 z - cbind(z, runif(300))
 names(z) - c(Method, sigma, Error)
 z$sigma - factor(z$sigma, c(5, 10, 30))
 library(lattice)

 sigma - as.numeric(levels(z$sigma))
 sigmaExprList - lapply(sigma, function(s) bquote(sigma == .(s)))
 sigmaExpr - as.expression(sigmaExprList)
 bwplot(Error~Method | sigma, data = z,
       horiz = F, xlab = Method,
       strip = strip.custom(var.name = sigmaExpr,
         strip.levels = FALSE, strip.names = TRUE),
       layout = c(3,1))

 HTH,

 --sundar

 On Thu, Apr 16, 2009 at 12:43 PM, Ranjan Maitra mai...@iastate.edu wrote:
 Hi,

 I think this question is best explained using the following
 self-contained toy example:




 ## cut code here and paste to R window

 z - cbind(rep(c(BIC, hist), each = 150), rep(rep(c(5, 10, 30),
 each = 50),2))

 z - as.data.frame(z)

 z - cbind(z, runif(300))

 names(z) - c(Method, sigma, Error)

 library(lattice)

 bwplot(Error~Method | sigma, data = z, horiz = F, xlab = Method,
 layout = c(3,1))


 ## end code




 Now the question:

 I would like the panels to be in the order of sigma, i. e. 5, 10, 30
 and not 10, 30 and 5 as is currently the case. Is this possible?

 Not to seek too much indulgence, but to ask anyway, I wonder if it is
 possible to have a Greek sigma = 5, a Greek sigma = 10 and a Greek
 sigma = 30. (Sort of what we would get using expression(sigma == 5),
 expression(sigma == 10), expression(sigma == 10) on base R figures).

 Please let me know if my question is not clear.

 Many thanks for any suggestions and help and best wishes!
 Ranjan

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



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


Re: [R] Changing the y-axis units of a lattice histogram

2009-04-03 Thread Sundar Dorai-Raj
Try:

library(lattice)
histogram( ~ height | voice.part,
  data = singer, type = c,
  scales = list(y =
list(at = seq(0, 20, 5),
 labels = seq(0, 200, 50

HTH,

--sundar

On Fri, Apr 3, 2009 at 2:01 PM, Judith Flores jur...@yahoo.com wrote:

 Hello,

   I need to multiply the number of counts in the y-axis of a lattice 
 histogram by a constant factor, such that the plot would represent a 
 different type of variable plotted in the y-axis, not counts. Can this be 
 done?

 Thank you,

 Judith

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


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


Re: [R] labeling panels in lattice plots

2009-03-31 Thread Sundar Dorai-Raj
Try converting year to a factor

xyplot(min + max + ave ~ month | factor(year), data = rain.stats, ...)

Also, notice the inclusion of the data argument.

HTH,

--sundar

On Tue, Mar 31, 2009 at 6:28 AM,  steve_fried...@nps.gov wrote:

 I am using windows XP with R 2.8.1


 I am generating a lattice plot of annual rain patterns using the following
 function:


  xyplot(rain.stats$min+ rain.stats$max + rain.stats$ave ~
 rain.stats$month |rain.stats$year,
            lty = 1,  data = rain.stats,  type = c(l,l, l), col =
 c(red, blue, green), distribute.type = TRUE,
            main = Annual Monthly Minimum, Average and Maximum PPT)


 Each panel is labels with rain.stats$year  instead of the actual value
 referenced by this variable.

 the data.frame I'm using has the following form (year values range from
 1965 to 2000 and month from 1 to 12).

 dim(rain.stats)
 432 6

rain.stats[1:10,]
   year month X2    min    max       ave
 1  1965     1  1 0. 1.9196 0.3650112
 2  1966     1  1 2.1483 4.9615 3.5247034
 3  1967     1  1 0.4038 3.9145 1.7133045
 4  1968     1  1 0.2033 3.2119 1.1844769
 5  1969     1  1 1.2533 5.6226 2.9505545
 6  1970     1  1 0.9142 3.8861 2.6248453
 7  1971     1  1 0.1191 1.6109 0.6570289
 8  1972     1  1 0.2309 2.9380 0.9259674
 9  1973     1  1 0.9471 3.6342 1.9019848
 10 1974     1  1 0.1739 9.0225 1.0672980


 The plot illustrates exactly what I'm after with the exception of the panel
 labels.  I'm following an example in the Lattice Book by Deepayan Sarkar
 (which I find very informative  - thanks), but I'm not getting the results
 as per the example.

 Can anyone offer a solution?

 Thanks in advance.

 Steve






 Steve Friedman Ph. D.
 Spatial Statistical Analyst
 Everglades and Dry Tortugas National Park
 950 N Krome Ave (3rd Floor)
 Homestead, Florida 33034

 steve_fried...@nps.gov
 Office (305) 224 - 4282
 Fax     (305) 224 - 4147

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


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


Re: [R] Can not get a prediction interval from Predict

2009-03-31 Thread Sundar Dorai-Raj
?predict.glm has no interval argument. Perhaps you're thinking of
?predict.lm, which is different.

To get intervals in glm, I've used:

example(predict.glm)
pr - predict(budworm.lg, se.fit = TRUE)
family - family(budworm.lg)
lower - family$linkinv(pr$fit - qnorm(0.95) * pr$se.fit)
upper - family$linkinv(pr$fit + qnorm(0.95) * pr$se.fit)

Note that these are confidence limits and not prediction limits.
The latter would require more thought.

You could also try RSiteSearch(glm interval).

HTH,

--sundar

On Tue, Mar 31, 2009 at 9:58 AM, Taylor Davis
taylor.da...@klasresearch.com wrote:
 I am trying to get a prediction interval from a glm regression.

 With newdat being my set of values to be fitted, and glmreg the name of my
 regression, I am using the following code.

 predict(glmreg, newdat, se.fit = TRUE, interval = confidence, level =
 0.90)

 The problem is that I am only getting the standard error and the fitted
 value, not a prediction interval.

 Any help would be great! Thanks so much.

 ___
 TAYLOR DAVIS    |
 KLAS
 taylor.da...@klasresearch.com    |    801.734.6279

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


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


Re: [R] use R Group SFBA April meeting reminder; video of Feb k

2009-03-30 Thread Sundar Dorai-Raj
Could be that you have some sort of ad filter in your browser that's
blocking the video? It appears just fine for me in Firefox 3.

On Mon, Mar 30, 2009 at 3:55 PM, Ted Harding
ted.hard...@manchester.ac.uk wrote:
 On 30-Mar-09 22:13:04, Jim Porzak wrote:
 Next week Wednesday evening, April 8th, Mike Driscoll will be talking
 about Building Web Dashboards using R
 see: http://www.meetup.com/R-Users/calendar/9718968/ for details  to
 RSVP.

 Also of interest, our member Ron Fredericks has just posted a well
 edited video of the February kickoff panel discussion at Predictive
 Analytics World The R and Science of Predictive Analytics: Four Case
 Studies in R with
     * Bo Cowgill, Google
     * Itamar Rosenn, Facebook
     * David Smith, Revolution Computing
     * Jim Porzak, The Generations Network
 and chaired by Michael Driscoll, Dataspora LLC

 see: http://www.lecturemaker.com/2009/02/r-kickoff-video/

 Best,
 Jim Porzak

 It could be very interesting to watch that video! However, I have
 had a close look at the web page you cite:

  http://www.lecturemaker.com/2009/02/r-kickoff-video/

 and cannot find a link to a video. Lots of links to non-video
 things, but none that I could see to a video.

 There is a link on that page at:
  How Google and Facebook are using R
  by Michael E. Driscoll | February 19, 2009
  http://dataspora.com/blog/predictive-analytics-using-r/

 Following that link leads to a page, on which the first link, in:

  (March 26th Update: Video now available)
  Last night, I moderated our Bay Area R Users Group kick-off
  event with a panel discussion entitled The R and Science of
  Predictive Analytics, co-located with the Predictive Analytics
  World conference here in SF.

 leads you back to where you came from, and likewise the link at
 the bottom of the page:

  A video of the event is now available courtesy of Ron Fredericks
  and LectureMaker.

 Could you help by describing where on that web page it can be found?
 With thanks,
 Ted.

 
 E-Mail: (Ted Harding) ted.hard...@manchester.ac.uk
 Fax-to-email: +44 (0)870 094 0861
 Date: 30-Mar-09                                       Time: 23:55:07
 -- XFMail --

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


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

2009-03-25 Thread Sundar Dorai-Raj
For the first question, add a groups argument. E.g.

barchart(HSI ~ Scenario | Region, Wbirdsm, groups = HydroState)

Also note that using Wbirdsm$HSI makes your call less readable, so I
added the data argument.

For your second question, setting the key does not set the color
theme. You want to set the colors using par.setting. E.g.

dotplot(HSI ~ Scenario | Region, Wbirdsm,
groups = HydroState,
par.settings = list(superpose.symbol =
  list(col = c(red, green, blue))),
auto.key = list(space = right))

Then use auto.key instead of key.

HTH,

--sundar

On Wed, Mar 25, 2009 at 7:02 AM,  steve_fried...@nps.gov wrote:

 Hello, this is a request for assistance that I submitted earlier, this time
 with the dataset. My mistake for taking up bandwidth.  I've also rephrased
 the question to address an additional concern.

 I'm working on a windows XP machine with R 2.8.1

 1).  I'd like a barchart (or other lattice type display) HSI ~ of the three
 factors (Region, Scenario and HydroState).
      However barchart complains

 library(reshape)
 library(lattice)

  barchart(Wbirdsm$HSI ~ WBirdsm$Scenario | WBridsm$Region)

  # This works, but only marginally.  I'd like specify the interaction
 between the variables ( Scenario and HydroState)
    What is the best way to combine these factors so they can be treated
 as a single variable and rewrite the barchart call?

  barchart(Wbirdsm$HSI ~ WBirdsm$interaction between Scenario and
 HydroState) ~ Wbirdsm$Region)



 The second question refers back to my original posting.
 2)  #  using dotplot instead of barchart I use the following code.

 key.variable - list(space = right, text =
 list(levels(wbirdm$variable)), points = list(pch = 1:3,
 col=c(red,green, blue)))
 dotplot(wbirdm$value  ~ wbirdm$variable | wbirdm$Region, col=c(1:9), pch=
 rep(c(1:3), key = key.variable,  groups=wbirdm$variable,     ylab= Mean
 HSI))

 # However the key legend doesn't appear in the plot with this sequence
 and the labels are too along the panels.  Is there a way to address this?


 thank you very much for the assistance.

 Steve


 This is part of the larger data base, after I passed it thru melt.



                                Region Species Scenario HydroState
 HSI
 1                    Eastern Panhandle  WBLong      NSM        Ave
 0.165945170
 2                    Eastern Panhandle  WBLong      NSM        Dry
 0.056244263
 3                    Eastern Panhandle  WBLong      NSM        Wet
 0.290692607
 4                    Eastern Panhandle  WBLong      ECB        Ave
 0.165945170
 5                    Eastern Panhandle  WBLong     ECB         Dry
 0.056244263
 6                    Eastern Panhandle  WBLong     ECB         Wet
 0.290692607
 7                    Eastern Panhandle  WBLong     CERP        Ave
 0.165945170
 8                    Eastern Panhandle  WBLong     CERP        Dry
 0.056244263
 9                    Eastern Panhandle  WBLong     CERP        Wet
 0.290692607
 10 Long Pine Key / South Taylor Slough  WBLong      NSM        Ave
 0.151159734
 11 Long Pine Key / South Taylor Slough  WBLong      NSM        Dry
 0.067348863
 12 Long Pine Key / South Taylor Slough  WBLong      NSM        Wet
 0.20738
 13 Long Pine Key / South Taylor Slough  WBLong      ECB        Ave
 0.151159734
 14 Long Pine Key / South Taylor Slough  WBLong     ECB         Dry
 0.067348863
 15 Long Pine Key / South Taylor Slough  WBLong     ECB         Wet
 0.20738
 16 Long Pine Key / South Taylor Slough  WBLong     CERP        Ave
 0.151159734
 17 Long Pine Key / South Taylor Slough  WBLong     CERP        Dry
 0.067348863
 18 Long Pine Key / South Taylor Slough  WBLong     CERP        Wet
 0.20738
 19              Northern Taylor Slough  WBLong      NSM        Ave
 0.115503291
 20              Northern Taylor Slough  WBLong      NSM        Dry
 0.005617136
 21              Northern Taylor Slough  WBLong      NSM        Wet
 0.252428530
 22              Northern Taylor Slough  WBLong      ECB        Ave
 0.115503291
 23              Northern Taylor Slough  WBLong     ECB         Dry
 0.005617136
 24              Northern Taylor Slough  WBLong     ECB         Wet
 0.252428530
 25              Northern Taylor Slough  WBLong     CERP        Ave
 0.115503291
 26              Northern Taylor Slough  WBLong     CERP        Dry
 0.005617136
 27              Northern Taylor Slough  WBLong     CERP        Wet
 0.252428530
 28                         East Slough  WBLong      NSM        Ave
 0.313215457
 29                         East Slough  WBLong      NSM        Dry
 0.046917053
 30                         East Slough  WBLong      NSM        Wet
 0.447002596
 31                         East Slough  WBLong      ECB        Ave
 0.313215457
 32                         East Slough  WBLong     ECB         Dry
 0.046917053
 33                         East Slough  WBLong     ECB         Wet
 0.447002596
 34                         East Slough  WBLong     CERP        

Re: [R] XYplot simple question

2009-03-16 Thread Sundar Dorai-Raj
Convert Plot to factor:

xyplot(AbvBioAnnProd ~ Year | Plot, type = c(b, r), pch = 16)

Also note that using the type argument with multiple values prevents
the necessity of a custom panel function.

HTH,

--sundar

On Mon, Mar 16, 2009 at 5:54 AM, AllenL allen.laroc...@gmail.com wrote:

 Hello R friends,
 Simple question today: I am desiring to do an xyplot with the below code,
 which graphs time series across different experimental Plots-

 xyplot(AbvBioAnnProd~Year|Plot)        ### Plots each monoculture biomass vs
 time
 xyplot(AbvBioAnnProd~Year|Plot,panel=function(x,y){
 panel.xyplot(x,y,type=b,pch=16)
 panel.abline(lm(y~x))
 })

 What I want to add are unique labels for each panel, where instead of all
 labeled plot with the slide-bar visual (although that is okay) I want
 the Plot number to appear (i.e. the value of Plot for that panel).

 This should be easy, right?
 -Al
 --
 View this message in context: 
 http://www.nabble.com/XYplot-simple-question-tp22537350p22537350.html
 Sent from the R help mailing list archive at Nabble.com.

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


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


Re: [R] XYplot simple question

2009-03-16 Thread Sundar Dorai-Raj
Sorry, I should have

xyplot(AbvBioAnnProd ~ Year | factor(Plot), type = c(b, r), pch = 16)

On Mon, Mar 16, 2009 at 6:17 AM, Sundar Dorai-Raj sdorai...@gmail.com wrote:
 Convert Plot to factor:

 xyplot(AbvBioAnnProd ~ Year | Plot, type = c(b, r), pch = 16)

 Also note that using the type argument with multiple values prevents
 the necessity of a custom panel function.

 HTH,

 --sundar

 On Mon, Mar 16, 2009 at 5:54 AM, AllenL allen.laroc...@gmail.com wrote:

 Hello R friends,
 Simple question today: I am desiring to do an xyplot with the below code,
 which graphs time series across different experimental Plots-

 xyplot(AbvBioAnnProd~Year|Plot)        ### Plots each monoculture biomass vs
 time
 xyplot(AbvBioAnnProd~Year|Plot,panel=function(x,y){
 panel.xyplot(x,y,type=b,pch=16)
 panel.abline(lm(y~x))
 })

 What I want to add are unique labels for each panel, where instead of all
 labeled plot with the slide-bar visual (although that is okay) I want
 the Plot number to appear (i.e. the value of Plot for that panel).

 This should be easy, right?
 -Al
 --
 View this message in context: 
 http://www.nabble.com/XYplot-simple-question-tp22537350p22537350.html
 Sent from the R help mailing list archive at Nabble.com.

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



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


Re: [R] Get user system name

2009-03-16 Thread Sundar Dorai-Raj
Assuming USER is defined on your system then

Sys.getenv(USER)

ought to work.

--sundar

On Mon, Mar 16, 2009 at 3:04 PM, Etienne Bellemare Racine
etienn...@gmail.com wrote:
 I would like to get the name of the user form the system. Is it possible ?
 Something like
  system.user()
 returning something like
 [1] etber12

 Thanks,
 Etienne

        [[alternative HTML version deleted]]

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


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


Re: [R] Get user system name

2009-03-16 Thread Sundar Dorai-Raj
If that's the case, it's best to post the output from version to
this thread. Type version from the R command prompt and paste the
results here.

On Mon, Mar 16, 2009 at 3:14 PM, Etienne Bellemare Racine
etienn...@gmail.com wrote:
 It seems like it is not defined. I get an empty string. Is there a
 workaround or another solution ?

 --
 Etienne

 Sundar Dorai-Raj a écrit :

 Assuming USER is defined on your system then

 Sys.getenv(USER)

 ought to work.

 --sundar

 On Mon, Mar 16, 2009 at 3:04 PM, Etienne Bellemare Racine
 etienn...@gmail.com wrote:


 I would like to get the name of the user form the system. Is it possible ?
 Something like
  system.user()
 returning something like
 [1] etber12

 Thanks,
 Etienne

        [[alternative HTML version deleted]]

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



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


Re: [R] Matrix Construction; Subdiagonal

2009-03-11 Thread Sundar Dorai-Raj
Does this help?

A - matrix(0, 6, 6)
vec - 1:5
A[row(A) == col(A) + 1] - vec

--sundar

On Wed, Mar 11, 2009 at 4:42 PM, Stu Field s...@colostate.edu wrote:
 I'm trying to enter a vector into the subdiagonal of a matrix but
 cannot find a command in R which corresponds to the MatLab version of
 diag(vec, k), where vec = the vector of interest, and k = the diagonal
 (k=0 for the diagonal; k=-1 for the subdiagonal; k=1 for
 superdiagonal, etc.)
 Is there an equivalent command in R?

 I'm looking for something like this:
 vec = seq(1, 5, 1)        # vector of interest

 A = xyz(vec,-1)           # creates a 6x6 matrix with vec on the
 subdiagonal
 where xyz is some function similar to diag, but with differing
 arguments.

 I can't believe there is not a simple way to do this...
 Thanks for your help,

 ~~
 Stu Field, PhD
 Postdoctoral Fellow
 Department of Biology
 Colorado State University
 1878 Campus Delivery
 Fort Collins, CO 80523-1878
 Office: E208 Anatomy/Zoology
 Phone: (970) 491-5744
 ~~





        [[alternative HTML version deleted]]

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


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


Re: [R] Matrix Construction; Subdiagonal

2009-03-11 Thread Sundar Dorai-Raj
You can always write your own function:

myDiag - function(x, vec, k) {
  x[row(x) == col(x) - k] - vec
  x
}

myDiag(A, vec, -1)

Of course, you should probably do some input checking too.

--sundar

On Wed, Mar 11, 2009 at 4:57 PM, Stu Field s...@colostate.edu wrote:
 Sure, that'll work fine, thanks.
 But I guess I was looking for something more similar to MatLab, I'm really
 surprised R doesn't have a preset command for this (?)
 Thanks again,
 Stu
 On 11 • Mar • 2009, at 5:49 PM, Sundar Dorai-Raj wrote:

 Does this help?

 A - matrix(0, 6, 6)
 vec - 1:5
 A[row(A) == col(A) + 1] - vec

 --sundar

 On Wed, Mar 11, 2009 at 4:42 PM, Stu Field s...@colostate.edu wrote:

 I'm trying to enter a vector into the subdiagonal of a matrix but

 cannot find a command in R which corresponds to the MatLab version of

 diag(vec, k), where vec = the vector of interest, and k = the diagonal

 (k=0 for the diagonal; k=-1 for the subdiagonal; k=1 for

 superdiagonal, etc.)

 Is there an equivalent command in R?

 I'm looking for something like this:

 vec = seq(1, 5, 1)        # vector of interest

 A = xyz(vec,-1)           # creates a 6x6 matrix with vec on the

 subdiagonal

 where xyz is some function similar to diag, but with differing

 arguments.

 I can't believe there is not a simple way to do this...

 Thanks for your help,

 ~~

 Stu Field, PhD

 Postdoctoral Fellow

 Department of Biology

 Colorado State University

 1878 Campus Delivery

 Fort Collins, CO 80523-1878

 Office: E208 Anatomy/Zoology

 Phone: (970) 491-5744

 ~~





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


 ~~
 Stu Field, PhD
 Postdoctoral Fellow
 Department of Biology
 Colorado State University
 1878 Campus Delivery
 Fort Collins, CO 80523-1878
 Office: E208 Anatomy/Zoology
 Phone: (970) 491-5744
 ~~





__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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: Customizing point-sizes with groups

2009-03-10 Thread Sundar Dorai-Raj
Try this:

xyplot(y ~ x, temp, groups = groups,
   par.settings = list(
 superpose.symbol = list(
   cex = c(1, 3),
   pch = 19,
   col = c(blue, red

See:

str(trellis.par.get())

for other settings you might want to change.

Also, you should drop the ; from all your scripts.

HTH,

--sundar

On Mon, Mar 9, 2009 at 6:49 PM, Paul Boutros paul.bout...@utoronto.ca wrote:
 Hello,

 I am creating a scatter-plot in lattice, and I would like to customize the
 size of each point so that some points are larger and others smaller.
  Here's a toy example:

 library(lattice);

 temp - data.frame(
        x = 1:10,
        y = 1:10,
        cex = rep( c(1,3), 5),
        groups = c( rep(A, 5), rep(B, 5) )
        );

 xyplot(y ~ x, temp, cex = temp$cex, pch = 19);

 This works just fine if I create a straight xy-plot, without groups.
  However when I introduce groupings the cex argument specifies the
 point-size for the entire group.  For example:

 xyplot(y ~ x, temp, cex = temp$cex, pch = 19, group = groups);

 Is it possible to combine per-spot sizing with groups in some way?  One
 work-around is to manually specify all graphical parameters, but I thought
 there might be a better way than this:

 temp$col - rep(blue, 10);
 temp$col[temp$groups == B] - red;
 xyplot(y ~ x, temp, cex = temp$cex, pch = 19, col = temp$col);

 Any suggestions/advice is much appreciated!
 Paul

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


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


Re: [R] Lattice: Customizing point-sizes with groups

2009-03-10 Thread Sundar Dorai-Raj
Sorry, I missed your point the first time. Why not create a group for
each subset then?

xyplot(y ~ x, temp, groups = interaction(cex, groups),
   par.settings = list(
 superpose.symbol = list(
   cex = c(1, 2, 3, 4),
   pch = 19,
   col = c(blue, red, green, purple


On Tue, Mar 10, 2009 at 8:11 AM, Paul C. Boutros
paul.bout...@utoronto.ca wrote:
 Hi Sundar,

 Thanks for your help!  Unfortunately your code seems to give the same
 result.  Compare this:

 temp - data.frame(
       x = 1:10,
       y = 1:10,
       cex = rep( c(1,3), 5),
       col = c( rep(blue, 5), rep(red, 5) ),
       groups = c( rep(A, 5), rep(B, 5) )
       );

 xyplot(y ~ x, temp, groups = groups,
       par.settings = list(
         superpose.symbol = list(
           cex = c(1, 3),
           pch = 19,
           col = c(blue, red

 And this:
 xyplot(y ~ x, temp, cex = temp$cex, col = temp$col, pch = 19);

 Once I introduce groups, I lose the ability to customize individual
 data-points and seem only to be able to customize entire groups.

 Paul

 -Original Message-
 From: Sundar Dorai-Raj [mailto:sdorai...@gmail.com]
 Sent: Tuesday, March 10, 2009 5:49 AM
 To: paul.bout...@utoronto.ca
 Cc: r-help@r-project.org
 Subject: Re: [R] Lattice: Customizing point-sizes with groups

 Try this:

 xyplot(y ~ x, temp, groups = groups,
       par.settings = list(
         superpose.symbol = list(
           cex = c(1, 3),
           pch = 19,
           col = c(blue, red

 See:

 str(trellis.par.get())

 for other settings you might want to change.

 Also, you should drop the ; from all your scripts.

 HTH,

 --sundar

 On Mon, Mar 9, 2009 at 6:49 PM, Paul Boutros paul.bout...@utoronto.ca
 wrote:
 Hello,

 I am creating a scatter-plot in lattice, and I would like to customize the
 size of each point so that some points are larger and others smaller.
  Here's a toy example:

 library(lattice);

 temp - data.frame(
        x = 1:10,
        y = 1:10,
        cex = rep( c(1,3), 5),
        groups = c( rep(A, 5), rep(B, 5) )
        );

 xyplot(y ~ x, temp, cex = temp$cex, pch = 19);

 This works just fine if I create a straight xy-plot, without groups.
  However when I introduce groupings the cex argument specifies the
 point-size for the entire group.  For example:

 xyplot(y ~ x, temp, cex = temp$cex, pch = 19, group = groups);

 Is it possible to combine per-spot sizing with groups in some way?  One
 work-around is to manually specify all graphical parameters, but I thought
 there might be a better way than this:

 temp$col - rep(blue, 10);
 temp$col[temp$groups == B] - red;
 xyplot(y ~ x, temp, cex = temp$cex, pch = 19, col = temp$col);

 Any suggestions/advice is much appreciated!
 Paul

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




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


Re: [R] 2 Simple Lattice Plot Questions

2009-03-10 Thread Sundar Dorai-Raj
Convert Year to a factor and both problems will be solved.

--sundar

On Tue, Mar 10, 2009 at 3:48 PM, jimdare jamesdar...@gmail.com wrote:

 Hi,

 I have created the plot below and have a few questions about changes.

 1) How do I change the Year title of each plot so it reads from the top
 2006,2007,2008,2009.
 2) How do I get rid of those vertical grey bars in the title bar of each
 plot?

 I apologise for my ignorance... one of those days :(

 James


 http://www.nabble.com/file/p22445242/PLOT.jpg
 --
 View this message in context: 
 http://www.nabble.com/2-Simple-Lattice-Plot-Questions-tp22445242p22445242.html
 Sent from the R help mailing list archive at Nabble.com.

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


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


Re: [R] 2 Simple Lattice Plot Questions

2009-03-10 Thread Sundar Dorai-Raj
I don't believe Elena's suggestion will work. However, the following will:

xyplot(..., scales = list(y = list(at = seq(5, 25, 5

though you may need to extend the limits a little as well:

xyplot(..., ylim = lattice:::extend.limits(c(0, 30)))

and add the scales argument from the first example to place explicit
tick marks rather than let xyplot do so.

HTH,

--sundar

On Tue, Mar 10, 2009 at 7:04 PM, Elena Wilson ewil...@dbmcons.com.au wrote:
 Have you tried specifying the levels of y's you want to display, e.g. 
 ylim=c(0,5,10,15,20,30)?

  -Original Message-
 From:   r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]  
 On Behalf Of jimdare
 Sent:   Wednesday, 11 March 2009 12:50 PM
 To:     r-help@r-project.org
 Subject:        Re: [R] 2 Simple Lattice Plot Questions


 Thanks very much.    One other thing... see how the Y axis begins before 0.
 At first glance it appears that the 0's are actually worth something.  When
 I use ylim=c(0,30) I get the graph I want, but the tick marks show only
 5,10,15,20,25.  I want them to show 0,5,10,15,20,30.  Does anyone know how
 to change this setting?

 Cheers,






 jimdare wrote:

 Hi,

 I have created the plot below and have a few questions about changes.

 1) How do I change the Year title of each plot so it reads from the top
 2006,2007,2008,2009.
 2) How do I get rid of those vertical grey bars in the title bar of each
 plot?

 I apologise for my ignorance... one of those days :(

 James


  http://www.nabble.com/file/p22445242/PLOT.jpg


 --
 View this message in context: 
 http://www.nabble.com/2-Simple-Lattice-Plot-Questions-tp22445242p22447415.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.
 --
 Message  protected by MailGuard: e-mail anti-virus, anti-spam and content 
 filtering.
 http://www.mailguard.com.au/mg


 https://login.mailguard.com.au/report/1x1TEaABIw/4soNUVnBh04s1coMEHC4LA/7.998

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


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


Re: [R] Date conversion

2009-03-05 Thread Sundar Dorai-Raj
Hi,

There are possibly several ways to do this. My approach would be:

dates - strptime(as.character(DATE), %d%b%Y)
year - dates$year + 1900
week - floor(dates$yday/365 * 52)

HTH,

--sundar

On Thu, Mar 5, 2009 at 8:58 AM, Pele drdi...@yahoo.com wrote:

 Hi R users,

 I have a factor variable called date as shown below:  Can anyone share the
 best / most efficient way to extract year and week (e.g.  year = 2006, week
 = 52 for first record, etc..)?  My data set has 1 million records.

 DATE
 11DEC2006
 11SEP2006
 01APR2007
 02DEC2007


 Thanks in advance for any help!
 --
 View this message in context: 
 http://www.nabble.com/Date-conversion-tp22355788p22355788.html
 Sent from the R help mailing list archive at Nabble.com.

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


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


Re: [R] lattice: remove box around a wireframe

2009-03-04 Thread Sundar Dorai-Raj
(Sorry for the repeat. Forgot to copy R-help)

Try,

test = data.frame(expand.grid(c(1:10), c(1:10)))
z = test[,1] + test[,2]
test = cbind(test, z)
names(test) = c(x, y, z)
require(lattice)
wireframe(z ~ x*y, data = test,
 par.settings = list(axis.line = list(col = transparent)),
 par.box = c(col = transparent) )

--sundar

On Wed, Mar 4, 2009 at 8:17 AM, Thomas Roth (geb. Kaliwe)
hamstersqu...@web.de wrote:
 #Hi,
 #
 #somebody knows how to  remove the outer box around a wireframe and reduce
 the height
 #
 #

 test = data.frame(expand.grid(c(1:10), c(1:10)))
 z = test[,1] + test[,2]
 test = cbind(test, z)
 names(test) = c(x, y, z)
 require(lattice)
 wireframe(z ~ x*y, data = test, par.box = c(col = transparent) )  #not
 this one but the remaining outer box.

 Thanks in advance

 Thomas Roth

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


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


Re: [R] levelplot help needed

2009-02-27 Thread Sundar Dorai-Raj
To reorder the y-labels, simply reorder the factor levels:

df - data.frame(x_label = factor(x_label),
 y_label = factor(y_label, rev(y_label)),
 values = as.vector(my.data))

Not sure about putting the strips at the bottom. A quick scan of
?xyplot and ?strip.default suggests that this is not possible, but I'm
sure Deepayan will correct me if I'm wrong (he often does).

--sundar

On Fri, Feb 27, 2009 at 5:51 AM, Antje niederlein-rs...@yahoo.de wrote:
 Hi there,

 I'm looking for someone who can give me some hints how to make a nice
 levelplot. As an example, I have the following code:

 # create some example data
 # --
 xl - 4
 yl - 10

 my.data - sapply(1:xl, FUN = function(x) { rnorm( yl, mean = x) })

 x_label - rep(c(X Label 1, X Label 2, X Label 3, X Label 4), each =
 yl)
 y_label - rep(paste(Y Label , 1:yl, sep=), xl)

 df - data.frame(x_label = factor(x_label),y_label = factor(y_label), values
 = as.vector(my.data))

 df1 - data.frame(df, group = rep(Group 1, xl*yl))
 df2 - data.frame(df, group = rep(Group 2, xl*yl))
 df3 - data.frame(df, group = rep(Group 3, xl*yl))

 mdf - rbind(df1,df2,df3)

 # plot
 # --

 graph - levelplot(mdf$values ~ mdf$x_label * mdf$y_label | mdf$group,
                                aspect = xy, layout = c(3,1),
                                scales = list(x = list(labels =
 substr(levels(factor(mdf$x_label)),0,5), rot = 45)))
            print(graph)

 # --


 (I need to put this strange x-labels, because in my real data the values of
 the x-labels are too long and I just want to display the first 10 characters
 as label)

 My questions:

 * I'd like to start with Y Label 1 in the upper row (that's a more general
 issue, how can I have influence on the order of x,y, and groups?)
 * I'd like to put the groups at the bottom

 Can anybody give me some help?

 Antje

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


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


Re: [R] lattice contourplot line types

2009-02-22 Thread Sundar Dorai-Raj
The only way I can figure out to do this is to use two calls to
panel.contourplot:

library(lattice)
x - seq(-2, 2, length = 20)
y - seq(-2, 2, length = 20)
grid - expand.grid(x=x, y=y)
grid$z - dnorm(grid$x) * dnorm(grid$y)
contourplot(z ~ x * y, grid,
panel = function(at, lty, col, ...) {
  at.o - at[seq(1, length(at), 2)]
  at.e - at[seq(2, length(at), 2)]
  panel.contourplot(at = at.o, lty = 1, col = blue, ...)
  panel.contourplot(at = at.e, lty = 4, col = red, ...)
},
at = pretty(grid$z, 10))

HTH,

--sundar

On Sun, Feb 22, 2009 at 12:45 PM, Andrew Beckerman
a.becker...@sheffield.ac.uk wrote:
 Dear all -

 I would like to adjust the line type of specific contours in contourplot
 from the lattice package, but it seems like lty does not take a list in the
 call.

 Here is my call to contourplot:

 contourplot(preds~size+trt|Size.Name,
data=pred.dat,layout=c(2,4),
at=c(0.025,0.5,0.975),
par.strip.text=list(cex=1.2),
scales=list(cex=0.5),
xlab=list(Size,cex=1.2),
ylab=list(Treatment,cex=1.2),
panel=function(x,y,z,...){
panel.contourplot(x,y,z,lwd=1,...)
panel.grid(h=-1,v=-1,col=grey,...)})

 I would like to specify lty=c(2,1,2) corresponding to the
 at=c(0.025,0.5,0.975), and have tried this in both the core part of the
 call, and in panel.countourplot.  However, it only recognises the first
 type.

 If there is no straightforward answer, I can provide the data.

 Best wishes,
 Andrew

 R version 2.8.1 (2008-12-22)
 i386-apple-darwin8.11.1

 locale:
 en_GB.UTF-8/en_GB.UTF-8/C/C/en_GB.UTF-8/en_GB.UTF-8

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

 other attached packages:
 [1] MASS_7.2-45 lattice_0.17-17

 loaded via a namespace (and not attached):
 [1] grid_2.8.1

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


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


Re: [R] Uninstall question

2009-02-17 Thread Sundar Dorai-Raj
This is on the Mac FAQ:

http://cran.cnr.berkeley.edu/bin/macosx/RMacOSX-FAQ.html#How-can-R-for-Mac-OS-X-be-uninstalled_003f

HTH,

--sundar

On Tue, Feb 17, 2009 at 7:17 AM, ANJAN PURKAYASTHA
anjan.purkayas...@gmail.com wrote:
 I need to uninstall R 2.7.1 from my Mac. What is the best way to uninstall
 it? Simply delete the R icon in the Applications folder?
 Or is it more involved?
 TIA,
 Anjan

 --
 =
 anjan purkayastha, phd
 bioinformatics analyst
 whitehead institute for biomedical research
 nine cambridge center
 cambridge, ma 02142

 purkayas [at] wi [dot] mit [dot] edu
 703.740.6939

[[alternative HTML version deleted]]

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


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


Re: [R] Adding abline in Lattice graph

2009-02-12 Thread Sundar Dorai-Raj
Try:

coplot(lbxglu~lbxgh|eth, data = reg.dat.5,
   panel= function(...) {
panel.smooth(...)
panel.abline(h = 126, col = red)
panel.abline(v = 6.5, col = blue)
  },
  xlab=ABC, ylab=FBG)

Also note that you removed your with call and give coplot a data argument.

HTH,

--sundar

On Thu, Feb 12, 2009 at 3:41 PM, Veerappa Chetty chett...@gmail.com wrote:
 Hi,I would like add a horizontal line at 126 (col=red) and a vertical line
 at 6.5 ( col= blue) in each panel .How should I use the panel.abline
 function in the following code I am using:
 --
 library(lattice)
 with(reg.dat.5,coplot(lbxglu~lbxgh|eth,panel=panel.smooth,xlab=ABC,
 ylab=FBG))
 
 Thanks a lot.

 Professor of Family Medicine
 Boston University
 Tel: 617-414-6221, Fax:617-414-3345
 emails: chett...@gmail.com,vche...@bu.edu

[[alternative HTML version deleted]]

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


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


Re: [R] Adding abline in Lattice graph

2009-02-12 Thread Sundar Dorai-Raj
Sorry, that was my lack of understanding on how coplot works. Try the following:

coplot(lbxglu~lbxgh|eth, data = reg.dat.5,
   panel= function(...) {
 panel.smooth(...)
 abline(h = 126, col = red)
 abline(v = 6.5, col = blue)
  },
  xlab=ABC, ylab=FBG)

On Thu, Feb 12, 2009 at 3:49 PM, Sundar Dorai-Raj sdorai...@gmail.com wrote:
 Try:

 coplot(lbxglu~lbxgh|eth, data = reg.dat.5,
   panel= function(...) {
panel.smooth(...)
panel.abline(h = 126, col = red)
panel.abline(v = 6.5, col = blue)
  },
  xlab=ABC, ylab=FBG)

 Also note that you removed your with call and give coplot a data argument.

 HTH,

 --sundar

 On Thu, Feb 12, 2009 at 3:41 PM, Veerappa Chetty chett...@gmail.com wrote:
 Hi,I would like add a horizontal line at 126 (col=red) and a vertical line
 at 6.5 ( col= blue) in each panel .How should I use the panel.abline
 function in the following code I am using:
 --
 library(lattice)
 with(reg.dat.5,coplot(lbxglu~lbxgh|eth,panel=panel.smooth,xlab=ABC,
 ylab=FBG))
 
 Thanks a lot.

 Professor of Family Medicine
 Boston University
 Tel: 617-414-6221, Fax:617-414-3345
 emails: chett...@gmail.com,vche...@bu.edu

[[alternative HTML version deleted]]

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



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


Re: [R] changing settings on a barchart (lattice)

2009-02-11 Thread Sundar Dorai-Raj
Add the adj argument to panel.text to left (adj = 0) or right(adj =
1) justify the text. Add the font argument to change the font. See
?text.

--sundar

On Wed, Feb 11, 2009 at 1:25 PM, Dimitri Liakhovitski ld7...@gmail.com wrote:
 Thanks a lot, Sundar. I experimented somewhat and here is the code
 that works well - it allows me to modify most of the stuff I want to
 modify:

 p-as.vector(c(0.1, 0.2, 0.3, 0.4))
 names(p)-c(A,BB,,)
 barchart(~sort(p), main=list(Chart Title,cex=1),xlab=list(X axis
 title,cex=1),xlim=c(0,0.42),
layout = c(1,1),
stack = TRUE,
auto.key = list(points = FALSE, rectangles = TRUE, space = 
 top),
panel = function(y,x,...){
panel.grid(h = 0, v = -1, col = gray60, lty 
 =dotted)
panel.barchart(x,y,col=brown)
panel.text(x,y,label = round(x,2),cex=1)
}
 )

 One last question: How can I modify the way the value labels (those
 that are at the end of the bars) appear? Can I make them bold? Make
 them appear a bit to the right or to the left of where they currently
 are?
 Thanks a lot!

 Dimitri

 On Wed, Feb 11, 2009 at 12:46 PM, Sundar Dorai-Raj sdorai...@gmail.com 
 wrote:
 Pass a list to xlab and main for the font sizes:

 barchart(..., xlab = list(x-axis, cex = 2), main = list(title, cex = 2))

 For value labels and a grid you'll need a custom panel function:

 barchart(..., panel = function(x, y, ...) {
  panel.barchart(x, y, ...)
  panel.text(x, y, format(y), cex = 1.2)
  panel.grid(h = -1, v = -1)
 })

 This is untested, but I think it should get you started.

 --sundar

 On Wed, Feb 11, 2009 at 9:10 AM, Dimitri Liakhovitski ld7...@gmail.com 
 wrote:
 Hello!

 I apologize - I never used lattice before, so my question is probably
 very basic - but I just can't find the answer in the archive nor in
 the documentation:

 I have a named numeric vector p of 6 numbers (of the type 6 numbers
 with people's names to whom those numbers belong). I want a simple bar
 chart.

 I am doing:

 library(lattice)
 trellis.par.set(fontsize=list(text=12))  # Changes only axes font
 barchart(~sort(p),main=Text for main,xlab=Text for X axis,
 col=PrimaryColors[3])

 It works just fine.
 Question: Where how can I change such things as font size for X axis
 label (below the numbers), font size for Title, value labels (to label
 bars with actual numbers), add grids, etc.?

 Thanks a lot!

 --
 Dimitri Liakhovitski
 MarketTools, Inc.
 dimitri.liakhovit...@markettools.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.





 --
 Dimitri Liakhovitski
 MarketTools, Inc.
 dimitri.liakhovit...@markettools.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] Efficent way to create an nxn upper triangular matrix of one's

2009-02-11 Thread Sundar Dorai-Raj
Try

x - diag(n)
x[upper.tri(x)] - 1

On Wed, Feb 11, 2009 at 1:22 PM, Dale Steele dale.w.ste...@gmail.com wrote:
 The code below create an nxn upper triangular matrix of one's.  I'm
 stuck on finding a more efficient vectorized way - Thanks.  --Dale

 n - 9
 data - matrix(data=NA, nrow=n, ncol=n)
 data
 for (i in 1:n) {
data[,i] - c(rep(1,i), rep(0,n-i))
 }
 data

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


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


Re: [R] sapply

2009-02-08 Thread Sundar Dorai-Raj
I'm not sure what you really want, so perhaps a simple example would
help (i.e. what a sample of the input looks like and what the output
you need looks like). My guess would be

sapply(df, diff)

but again, I'm not sure.

--sundar

On Sun, Feb 8, 2009 at 4:24 PM, glenn g1enn.robe...@btinternet.com wrote:
 Newbie question sorry (have tried the help pages I promise)



 I have a dataframe (date,stockprice) say and looking how I might get the
 return of: dataframe (difference in days, change in stock price) using
 sapply - I require a very simple function and don't really want to go down
 the zoo and quant mod route



 Regards



 glenn


[[alternative HTML version deleted]]

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


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


Re: [R] subsets problem

2009-02-08 Thread Sundar Dorai-Raj
you can try

lapply(lapply(uniques, function(x) subset(df, date == x)), myfun)

or possibly more accurate (subset may be finicky due to scoping):

lapply(lapply(uniques, function(x) df[df$date == x, ]), myfun)

or use ?split

lapply(split(df, df$date), myfun)

HTH,

--sundar

On Sun, Feb 8, 2009 at 5:00 PM, glenn g1enn.robe...@btinternet.com wrote:
 Help with this much appreciated



 I have a large dataframe that I would like to subset where the constraint



 Test1 - subset(df, date == uniques[[1]]), where uniques is a list of dates
 that must be matched to create Test1.



 I would like to perform an operation on Test1 that results in a single
 column of data. So far so good.



 How do loop through all values in the uniques list (say there is 50),
 perform an operationon Test1Test50, and then bolt all the lists together
 in a single list please ?



 Regards





 Glenn




[[alternative HTML version deleted]]

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


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


Re: [R] Foreign function call

2009-02-04 Thread Sundar Dorai-Raj
You're missing that R_TSConv is an R object. You can use
stats:::R_TSConv to see the value. Not sure how this helps you though.

On Wed, Feb 4, 2009 at 10:08 AM,  rkevinbur...@charter.net wrote:
 Let me get more specific. I think it this can be answered then I can 
 translate the information to other calls. In the arima 'R' code there is a 
 reference to

 .Call(R_TSconv, a, b)

 If from the console I type:

 .Call(R_TSConv, c(1,-1), c(1,-1))

 I get:

 Error: object R_TSConv not found

 If I do

 getNativeSymbolInfo(R_TSConv)

 I get:

 Error in FUN(R_TSConv[[1L]], ...) : no such symbol R_TSConv

 What am I missing?

 Thank you.

 Kevin

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


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


Re: [R] color and fontfamily in lattice

2009-02-03 Thread Sundar Dorai-Raj
Try this:

dados - data.frame(varsep = factor(rep(1:2,10)),
i = runif(20))

library(lattice)
font.settings - list(
 font = 2,
 cex = 2,
 fontfamily = serif)
my.theme - list(
 box.umbrella = list(col = red),
 box.rectangle = list(col = purple),
 box.dot = list(col = blue, pch = 15),
 par.xlab.text = font.settings,
 par.ylab.text = font.settings,
 axis.text = font.settings)
bwplot(varsep ~ i, dados,
   xlab = names(dados)[1],
   ylab = names(dados)[2],
   panel = function(...) {
 panel.grid(v = -1, h = 0)
 panel.bwplot(...)
   },
   par.settings = my.theme)

Type trellis.par.get() at the R command line to see other parameters
you can change. To change the settings on all plots, you can remove
the par.settings from the call to bwplot and simply use:

trellis.par.set(theme = my.theme)

HTH,

--sundar


2009/2/3 Leandro Marino lean...@cesgranrio.org.br:




 Hi,
 I am having some problems using bwplot(lattice) in my data. I want change 
 some parameters:
 1) Fontfamily to serif
 2) The size of the font
 3) Put it in a bold face
 4) Change de color of the lines

 How can I do that?! Now, I am using this to plot my boxplot.
 dados - data.frame(varsep=as.factor(rep(1:2,10)),i=runif(20))
 bwplot(dados[,'varsep']~dados[,'i'],xlab=names(dados)[2],ylab=names(dados)[1],panel
  =function(...){panel.grid(v = -1, h = 
 0);panel.bwplot(...)},font=2,fontfamily='serif')

 Thanks for any help on advance and sorry about my English.










 Atenciosamente,
 Leandro Lins Marino
 Centro de Avaliação
 Fundação CESGRANRIO
 Rua Santa Alexandrina, 1011 - 2º andar
 Rio de Janeiro, RJ - CEP: 20261-903
 R (21) 2103-9600 R.:236
 0 (21) 8777-7907
 ( lean...@cesgranrio.org.br

 Aquele que suporta o peso da sociedade
é precisamente aquele que obtém
  as menores vantagens. (SMITH, Adam)

   Antes de imprimir pense em sua responsabilidade e compromisso com o MEIO 
 AMBIENTE

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


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


Re: [R] xyplot with lowess curves

2009-02-02 Thread Sundar Dorai-Raj
You'll need a custom panel function. It would also help if you
provided a reproducible example:

xyplot (
  SnowLineElevation ~ Year | Model,
  data = data,
  panel = function(x, y, col, ...) {
col - ifelse(panel.number() == 1, red, green)
panel.xyplot(x, y, col = blue, ...)
panel.loess(x, y, col = col)
  },
  ylim = c(0,1800),
  pch = 21,
  xlab = 'Year',
  ylab = 'Snowline Elevation [m]'
)

Alternatively, you can use the group argument in conjunction with the panels:

xyplot(SnowLineElevation ~ Year | Model, data, groups = Model, type =
c(p, smooth))

if you want the points and the lines to be the same color.

--sundar

On Mon, Feb 2, 2009 at 10:20 AM, Hutchinson,David [PYR]
david.hutchin...@ec.gc.ca wrote:
 I am trying to change the attributes of the lowess lines fit to an
 xyplot command, but have been unsuccessful in my search of the online
 help. Right now, both the points and lowess line come out in the same
 color (blue). I am unsure how I can change the properties of the lowess
 line separately.

 xyplot (
  SnowLineElevation ~ Year | Model,
  data = data,
  ylim = c(0,1800),
  type = c('p','smooth'),
  col = 'blue',
  pch = 21,
  xlab = 'Year',
  ylab = 'Snowline Elevation [m]'
 )

 Any help would be much appreciated,

 Dave

[[alternative HTML version deleted]]

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


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


  1   2   >