Re: [R] How to Group Categorical data in R?

2012-03-18 Thread Manish Gupta
 It is working fine. 

Thanks

--
View this message in context: 
http://r.789695.n4.nabble.com/How-to-Group-Categorical-data-in-R-tp4477622p4483565.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] Output formatting in Latex and R

2012-03-18 Thread Manish Gupta
I am working on Latex and R and using following code.

<>=
infile<-read.table("test.txt",sep="\t")
Col3 <- unique(infile[,3]) 
LCol3 <- length(Col3)
for (i in 1:LCol3) {


print(paste("Column", Col3[i]))
print(infile[infile[,3]==Col3[i],-3])
}
@

I am getting following output.

1] "Column C" V1 V2 V4 1 A B D 2 X T K [1] "Column Z" V1 V2 V4 3 Z U M 4 E V
R 5 Z U M [1] "Column P" V1 V2 V4 6 E V R

Blockquote

I want to avoid numbering and columns names. I want my output as follows.

"Column C" A B D X T K

"Column Z" Z U M E V R Z U M

"Column P" E V R

How can i implement it?


--
View this message in context: 
http://r.789695.n4.nabble.com/Output-formatting-in-Latex-and-R-tp4483631p4483631.html
Sent from the R help mailing list archive at Nabble.com.

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


[R] How to use R script in VB?

2012-03-18 Thread Dong-Joon Lim
Hello R friends,

I want to use my R script in VB to make macro in Excel.
I tried with RExcel but it seems to me that this package is just GUI API
and I still have to run(connect) R to use the script.
Google tells me there are some ways to make R script as an independent
library/module/header so that I can call it in VB, C or JAVA.
Where can I get detailed tutorial or manual for that?

Thanks in advance,
Dong-Joon

[[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] randomly subsample rows from subsets

2012-03-18 Thread Rui Barradas
Hello,

Try

text="
fish fam length
1 a 71.46
2 a 71.06
3 a 62.94
4 b 79.46
5 b 52.38
6 b 56.78
7 b 92.08
8 c 96.86
9 d 98.09
10 d 17.23
11 d 98.35
12 d 82.43
13 e 83.85
14 e 33.92
15 e 23.16
16 e 31.39
17 e 57.08
18 e 27.05
19 f 62.38
20 f 83.21
21 f 18.72
22 f 84.32
23 g 15.99
24 h 40.33
25 h 92.73
26 h 59.08
27 i 29.05
"
fish <- read.table(textConnection(text), header=TRUE)
head(fish)

set.seed(1)
select <- lapply(split(fish, fish$fam),
function(x) if(NROW(x) > 1) x[sample(NROW(x), 2), ])
select <- select[!sapply(select, is.null)]

# result as a list
select
# result as a data.frame
do.call(rbind, select)

Hope this helps,

Rui Barradas


--
View this message in context: 
http://r.789695.n4.nabble.com/randomly-subsample-rows-from-subsets-tp4483477p4483613.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] Sankey Diagrams in R

2012-03-18 Thread Eric Fail
Dear R-list,

I am trying to visualize where the dropout happens in our patient flow. We are 
currently using traditional flowcharts and it bothers me that I can't visualize 
both the percentage and the flow in one diagram.

The other day I came across some interesting diagrams doing exactly what I 
wanted, they had both flow and percentages visualized on one diagram. Here is 
some nice examples apparently made with ‘sankeypython’ 
http://www.sankey-diagrams.com/tag/software/

It didn't take long to find a blog where a Ruser (thanks!) had posted an R 
script that actually produces an Sankey Diagram in R 
http://biologicalposteriors.blogspot.com/2010/07/sankey-diagrams-in-r.html

See below for working example.

My questions are, is this the most updated Sankey Diagram-script we have in the 
R community? Is there a better way to visualize flow and percentages in one 
diagram in R?

Thanks,
Eric

## the working example

## th, 
https://tonybreyal.wordpress.com/2011/11/24/source_https-sourcing-an-r-script-from-github/
sourc.https <- function(url, ...) {
  # load package
require(RCurl)
  # install.packages(c("RCurl"), dependencies = TRUE)

  # parse and evaluate each .R script
  sapply(c(url, ...), function(u) {
    eval(parse(text = getURL(u, followlocation = TRUE, cainfo = 
system.file("CurlSSL", "cacert.pem", package = "RCurl"))), envir = .GlobalEnv)
  })
}

# Example from https://gist.github.com/1423501
sourc.https("https://raw.github.com/gist/1423501/55b3c6f11e4918cb6264492528b1ad01c429e581/Sankey.R";)

# My example (there is another example inside Sankey.R):
inputs = c(6, 144)
losses = c(6,47,14,7, 7, 35, 34)
unit = "n ="
labels = c("Transfers",
   "Referrals\n",
   "Unable to Engage",
   "Consultation only",
   "Did not complete the intake",
   "Did not engage in Treatment",
   "Discontinued Mid-Treatment",
   "Completed Treatment",
   "Active in \nTreatment")
SankeyR(inputs,losses,unit,labels)

# Clean up my mess
rm("inputs", "labels", "losses", "SankeyR", "sourc.https", "unit")

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


Re: [R] Problem reading mixed CSV file

2012-03-18 Thread Ashish Agarwal
This is quite a CPu consuming process. My system got hung up for the
big file I have.

Within the for loop that you have suggested, can't I have a case
statement for different value of nfields to be read and specify what
format does the variable needs to be read?
something like
case
# input format for 6 fields
when nFields == 6
read.csv as string, string, string, numeric, numeric, numeric into dataframe1
#input format for 7 fields
when nFields == 7
read.csv as string, string, string, string, numeric, numeric, numeric
into dataframe2
end case
# Output the two dataframes via some way of tracking the original line
numbers of the input file - similar to _N_ in SAS
. Dataframe1 to be outputed as it is while in dataframe2,
concatenating the 3rd and the 4th strings.

Could you please help with the format for the above?



On Sat, Mar 17, 2012 at 4:54 AM, jim holtman  wrote:
> Here is a solution that looks for the line with 7 elements and inserts
> the quotes:
>
>
>> fileName <- '/temp/text.txt'
>> input <- readLines(fileName)
>> # count the fields to find 7
>> nFields <- count.fields(fileName, sep = ',')
>> # now fix the data
>> for (i in which(nFields == 7)){
> +     # split on comma
> +     z <- strsplit(input[i], ',')[[1]]
> +     input[i] <- paste(z[1], z[2]
> +         , paste('"', z[3], ',', z[4], '"', sep = '') # put on quotes
> +         , z[5], z[6], z[7], sep = ','
> +         )
> + }
>>
>> # now read in the data
>> result <- read.table(textConnection(input), sep = ',')
>>
>>         result
>                         V1       V2                   V3   V4 V5 V6
> 1                                                         1968 21  0
> 2                                                  Boston 1968 13  0
> 3                                                  Boston 1968 18  0
> 4                                                 Chicago 1967 44  0
> 5                                              Providence 1968 17  0
> 6                                              Providence 1969 48  0
> 7                                                   Binky 1968 24  0
> 8                                                 Chicago 1968 23  0
> 9                                                   Dally 1968  7  0
> 10                                   Raleigh, North Carol 1968 25  0
> 11 Addy ABC-Dogs Stars-W8.1                    Providence 1968 38  0
> 12              DEF_REQPRF/                     Dartmouth 1967 31  1
> 13                       PL                               1967 38  1
> 14                       XY PopatLal                      1967  5  1
> 15                       XY PopatLal                      1967  6  8
> 16                       XY PopatLal                      1967  7  7
> 17                       XY PopatLal                      1967  9  1
> 18                       XY PopatLal                      1967 10  1
> 19                       XY PopatLal                      1967 13  1
> 20                       XY PopatLal               Boston 1967  6  1
> 21                       XY PopatLal               Boston 1967  7 11
> 22                       XY PopatLal               Boston 1967  9  2
> 23                       XY PopatLal               Boston 1967 10  3
> 24                       XY PopatLal               Boston 1967  7  2
>>
>
>
> On Fri, Mar 16, 2012 at 2:17 PM, Ashish Agarwal
>  wrote:
>> I have a file that is 5000 records and to edit that file is not easy.
>> Is there any way to line 10 differently to account for changes in the
>> third field?
>>
>> On Fri, Mar 16, 2012 at 11:35 PM, Peter Ehlers  wrote:
>>> On 2012-03-16 10:48, Ashish Agarwal wrote:

 Line 10 has City and State that too separated by comma. For line 10
 how can I read differently as compared to the other lines?
>>>
>>>
>>> Edit the file and put quotes around the city-state combination:
>>>  "Raleigh, North Carol"
>>>
>>
>> __
>> R-help@r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>
>
>
> --
> Jim Holtman
> Data Munger Guru
>
> What is the problem that you are trying to solve?
> Tell me what you want to do, not how you want to do 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.


Re: [R] a very simple question

2012-03-18 Thread David Winsemius


On Mar 18, 2012, at 4:43 PM, Dajiang Liu wrote:



Dear All,
I have a seemingly very simple question, but I just cannot figure  
out the answer. I attempted to run the  
following:a=0.1*(1:9);which(a==0.3);it returns integer(0). But  
obviously, the third element of a is equal to 0.3.
I must have missed something. Can someone kindly explain why? Thanks  
a lot.


It has already been explained on this list ... "frequently" in FAQt.

Locate the FAQ and search for a question about why R doesn't think two  
numbers are equal. The FAQ should be part of a standard instalL on the  
main help page.




Regards,Dajiang

[[alternative HTML version deleted]]

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


David Winsemius, MD
Heritage Laboratories
West Hartford, CT

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Plotting Rickers curve in R with confidence intervals

2012-03-18 Thread kyoung
Hello, I am both new to this forum and to R.  Therefore apologies if I am
posting a request for help for something overly simple and/or that has
already been covered in past posts.  I would really appreciate some simple
and straightforward help on how to plot a Rickers growth curve with
confidence intervals and to determine r and K.  My data is in the very
simple form of year and population size.  I would like to know how to get
these curve parameters in graphical form and as numerical outputs.  If
someone can help me with some really simple script from start to finish I
would be so appreciative. Thank so much in advance

 

--
View this message in context: 
http://r.789695.n4.nabble.com/Plotting-Rickers-curve-in-R-with-confidence-intervals-tp4483757p4483757.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] a very simple question

2012-03-18 Thread Dajiang Liu

Dear All,
I have a seemingly very simple question, but I just cannot figure out the 
answer. I attempted to run the following:a=0.1*(1:9);which(a==0.3);it returns 
integer(0). But obviously, the third element of a is equal to 0.3. 
I must have missed something. Can someone kindly explain why? Thanks a lot.
Regards,Dajiang
  
[[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] hypergeometric function in ‘ mvtnorm’

2012-03-18 Thread statfan
Is there any way to know how the "dmvt" function computes the hypergeometric
function needed in the calculation for the density of multivariate t
distribution?  

--
View this message in context: 
http://r.789695.n4.nabble.com/hypergeometric-function-in-mvtnorm-tp4483730p4483730.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] randomly subsample rows from subsets

2012-03-18 Thread aly
Hi,

I have a list of 1787 fish from 948 full-sib families and their lengths. My
table looks like this,

fishfam length
1   a   71.46
2   a   71.06
3   a   62.94
4   b   79.46
5   b   52.38
6   b   56.78
7   b   92.08
8   c   96.86
9   d   98.09
10  d   17.23
11  d   98.35
12  d   82.43
13  e   83.85
14  e   33.92
15  e   23.16
16  e   31.39
17  e   57.08
18  e   27.05
19  f   62.38
20  f   83.21
21  f   18.72
22  f   84.32
23  g   15.99
24  h   40.33
25  h   92.73
26  h   59.08
27  i   29.05

I want to randomly select 2 fish from each family that has 2 or more
individuals and exclude those families that have just one fish. How can I do
that? Thanks,



--
View this message in context: 
http://r.789695.n4.nabble.com/randomly-subsample-rows-from-subsets-tp4483477p4483477.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] Importing files

2012-03-18 Thread jim holtman
The file that you set was readable.  The majority of the fields were
comma separated, so I use the comma as the field separator in the
'read.table'.  The 'tab' character appears to be the separator between
the date and time and this does not prevent reading in the data, or
parsing it later.  So here is what I got:

> x <- read.table("C:\\temp\\2196001_CALBOR_2008_Veneguera  0.act"
+ , sep = ','
+ , as.is= TRUE
+ )
> str(x)
'data.frame':   29 obs. of  4 variables:
 $ V1: chr  "ok" "ok" "ok" "ok" ...
 $ V2: chr  "05/06/07 19:08:00" "05/06/07 19:17:59" "05/06/07
19:27:59" "05/06/07 19:37:59" ...
 $ V3: num  39239 39239 39239 39239 39239 ...
 $ V4: int  9 1 0 0 0 0 0 0 0 0 ...
> head(x)
  V1V2   V3 V4
1 ok 05/06/07 19:08:00 39238.80  9
2 ok 05/06/07 19:17:59 39238.80  1
3 ok 05/06/07 19:27:59 39238.81  0
4 ok 05/06/07 19:37:59 39238.82  0
5 ok 05/06/07 19:47:59 39238.82  0
6 ok 05/06/07 19:57:59 39238.83  0
>

so the data is reasonable and you can work with.  So what was the
problem?   Do you want the time converted to POSIXct so you can use
it?  Do you just want to extract the value (V4)?

So I don't see any problem in processing the data.

2012/3/18 Santiago Guallar :
> Thank you Jim.
> Here the original format and its conversion to txt.
>
> Santi
>
> From: jim holtman 
> To: Santiago Guallar 
> Cc: "r-help@r-project.org" 
> Sent: Sunday, March 18, 2012 10:59 PM
> Subject: Re: [R] Importing files
>
> You attachment never made it through.  Try sending it as '.txt' file.
> If the file is using both tabs and commas on the same line, then you
> may have to use 'readLines' to read it in, and then 'strsplit' to
> split out the different elements.
>
> On Sun, Mar 18, 2012 at 4:13 PM, Santiago Guallar 
> wrote:
>> Hello,
>> I'm trying to import into R files that contain data downloaded from logger
>> devices as files with the following formats:
>> .act
>> .lig
>> .trj
>> .trn
>> These files are essentially text files but use both tabs and commas as
>> separators.
>> I've tried the function scan:
>>
>> 1) scan("filename.act", what=character(0)) returns only two columns from
>> the original 5
>> 2) scan("copia.act", what=character(0),sep=",") returns three columns but
>> puts the original fifth one in the next row
>>
>> Attached a sample file with five fields. How can I get one field per
>> column?
>>
>> Thank you for your help
>>
>> __
>> R-help@r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide
>> http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>>
>
>
>
> --
> Jim Holtman
> Data Munger Guru
>
> What is the problem that you are trying to solve?
> Tell me what you want to do, not how you want to do it.
>
>



-- 
Jim Holtman
Data Munger Guru

What is the problem that you are trying to solve?
Tell me what you want to do, not how you want to do 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] glm: getting the confidence interval for an Odds Ratio, when using predict()

2012-03-18 Thread Dominic Comtois
Say I fit a logistic model and want to calculate an odds ratio between 2
sets of predictors. It is easy to obtain the difference in the predicted
logodds using the predict() function, and thus get a point-estimate OR. But
I can't see how to obtain the confidence interval for such an OR.

 

For example:

model <- glm(chd ~age.cat + male + lowed, family=binomial(logit))

pred1 <- predict(model, newdata=data.frame(age.cat=1,male=1,lowed=1))

pred2 <- predict(model, newdata=data.frame(age.cat=2,male=0,lowed=0))

OR <- exp(pred2-pred1) 

 

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] bias sampling

2012-03-18 Thread David
Thank you for your time, Thomas .

In case the questioner is not aware of a few facts... Thomas Lumley is both a) 
the person who originally ported tThereau's "survival" package to R and was 
also its maintainer for many years , and b) the author of the "survey" package

-- 
David
Sent from my iPhone

On Mar 18, 2012, at 5:51 PM, Thomas Lumley  wrote:

> On Mon, Mar 19, 2012 at 10:27 AM, David Winsemius
>  wrote:
>> 
>> On Mar 18, 2012, at 3:54 PM, Thomas Lumley wrote:
>> 
>>> On Mon, Mar 19, 2012 at 6:34 AM, David Winsemius 
>>> wrote:
 
 
 On Mar 16, 2012, at 1:09 PM, niloo javan wrote:
 
> hi
> i want to analyze Right Censore-Length bias data under cox model with
> covariate.
> what is the package ?
 
 
 
 I initially left this question alone because I thought there might be
 viewers for whom it all made perfect sense. After two days that
 probability
 seems to be declining. The problem I had was the meaning of "length bias
 data". Are you talking about a non-proportional effect in which the
 assumption of a constant hazard ratio over time is false and other
 methods
 are needed. If that is correct, then you should get a copy of Therneau
 and
 Grambsch's "Modeling Survival Data" and study the chapter on "Functional
 Form'. The package would be "survival".
 
>>> 
>>> Length-biased sampling is what you get when you take a cross-sectional
>>> sample of an ongoing process -- long intervals are over-represented.
>> 
>> 
>> Thank you Thomas;
>> 
>>  For example people who have survived to age 75 might be systematically
>> different with respect to both the distribution of cardiovascular risk
>> factors and their impact on the event of interest (AMI. CV death, or
>> all-cause mortality) than persons at age 45. And that would also not take
>> into account the fact those risk factors might have changed over the
>> interval from age 45 to age 75 in the survivors?
>>> 
>>> 
>>> If the arrival time is known for everyone in the sample, the usual Cox
>>> model facilities for left truncation apply.  If the arrival times are
>>> not known it would be much more difficult, and would probably need
>>> parametric modelling.
>> 
>> 
>>  Am I correct in thinking that additional assumptions about the
>> "length-bias" would need to be explicitly stated or modeled under a set of
>> plausible scenarios before progress in any framework could be anticipated?
>> It would seem that there could be many forms of such a "length-bias".
>> 
> 
> Yes, as with any missing data problem things can go arbitrarily badly wrong.
> 
> The classical 'length-biased sampling' problem is a cross-sectional
> sample from a stationary population process, and that gives good
> results.
> 
> Obviously if you don't recruit anyone before time  T, there is no
> information about what happened before then, but there may still be
> useful information afterwards.  A good example is the research project
> on after-effects of the nuclear bombings of Nagasaki and Hiroshima,
> where recruitment started (IIRC) 5 years after the event.  There's no
> information on survival in the first five years, but very good
> subsequent information.
> 
>-thomas
> 
> -- 
> Thomas Lumley
> Professor of Biostatistics
> University of Auckland

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Extracting numbers from a character variable of different types

2012-03-18 Thread David


On Mar 18, 2012, at 3:17 PM, Daniel Malter  wrote:

> Assume your year value is 
> 
> x<-007/A
> 
> You want to replace all non-numeric characters (i.e. letters and
> punctuation) and all zeros with nothing.
> 
> gsub('[[:alpha:]]|[[:punct:]]|0','',x)
> 
> Let's say you have a vector with both month and year values (you can
> separate them). Now we need to identify the cells that have a month or year
> indicator
> 
> x<-c("007/A","007/a","003/M","003/m")
> 
> grep("/A|/a",x) #cells in x with year information
> grep("/M|/m",x) #cells in x with month information
> 
> To remove all characters, punctuation, and 0s from x, do:
> 
> gsub('[[:alpha:]]|[[:punct:]]|0','',x)
> 
> which you can also do specifically for the cells that identify months and
> years, respectively:
> 
> years<-gsub('[[:alpha:]]|[[:punct:]]|0','',x[grep("/A|/a",x)])

The problem with this approach is that the years vector becomes disjoint from 
the months vector. It doesn't lend itself well to data.frame operations.

-- 
David
Sent from my iPhone


> #years
> years
> months<-gsub('[[:alpha:]]|[[:punct:]]|0','',x[grep("/M|/m",x)]) #months
> months
> 
> Convert the resulting character vectors into numeric vectors by
> as.numeric(as.character(years)) , for example.
> 
> HTH,
> Daniel
> 
> 
> 
> 
> 
> --
> View this message in context: 
> http://r.789695.n4.nabble.com/Extracting-numbers-from-a-character-variable-of-different-types-tp4482248p4482732.html
> Sent from the R help mailing list archive at Nabble.com.
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

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


Re: [R] R crashes due to stats.dll

2012-03-18 Thread Duncan Murdoch

On 12-03-17 8:15 PM, Ted Stankowich wrote:

Hello!
I've been running a looped AIC analysis using several modules including
ape, nlme, and MuMIn, and during one particularly long analysis, R (ver
2.14.12) crashes several minutes into the routine with the simple
message "R for windows GUI front-end has stopped working".  I'm using a
brand new laptop with Windows 7, i7 processor, 8GB RAM.  I've tried it
on both the 64 bit and 32 bit versions of R.  Using the 64 bit version,
the analysis makes it through a few iterations before it crashes (maybe
about 20-25 min into the test).

The event viewer provides this information every time it crashes:
Faulting application name: Rgui.exe, version: 2.142.58522.0, time stamp:
0x4f4e7196
Faulting module name: stats.dll, version: 2.142.58522.0, time stamp:
0x4f4e72c0
Exception code: 0xc005

Does anyone have any idea what might be going wrong here?


Most likely some function is writing to memory it doesn't own.  This 
might be a bug in the stats package, but I would guess it is much more 
likely to be a bug in one of the other packages you used, and stats is 
crashing when it comes across the damage.


Debugging this sort of thing is quite hard in Windows:  you need to 
build R with debugging information and run it under a compatible version 
of a debugger (e.g. gdb).  I'd recommend trying the code on a Linux or 
MacOS system, where you will still need to make sure the debugger is 
installed, but you tend to get more informative messages from it.


Duncan Murdoch

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


Re: [R] Importing files

2012-03-18 Thread jim holtman
You attachment never made it through.  Try sending it as '.txt' file.
If the file is using both tabs and commas on the same line, then you
may have to use 'readLines' to read it in, and then 'strsplit' to
split out the different elements.

On Sun, Mar 18, 2012 at 4:13 PM, Santiago Guallar  wrote:
> Hello,
> I'm trying to import into R files that contain data downloaded from logger 
> devices as files with the following formats:
> .act
> .lig
> .trj
> .trn
> These files are essentially text files but use both tabs and commas as 
> separators.
> I've tried the function scan:
>
> 1) scan("filename.act", what=character(0)) returns only two columns from the 
> original 5
> 2) scan("copia.act", what=character(0),sep=",") returns three columns but 
> puts the original fifth one in the next row
>
> Attached a sample file with five fields. How can I get one field per column?
>
> Thank you for your help
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



-- 
Jim Holtman
Data Munger Guru

What is the problem that you are trying to solve?
Tell me what you want to do, not how you want to do 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.


Re: [R] Removing session variables

2012-03-18 Thread Duncan Murdoch

On 12-03-18 5:31 AM, Ajay Askoolum wrote:

If I create a data.frame using session variables as follows:

classResults<-data.frame(subjEnglish,gradeEnglish,subjFrench,gradeFrench,row.names=studentName)


How can I remove the variables? I tried


rm(names(classResults))

Error in rm(names(classResults)) :
   ... must contain names or character strings


Use rm(list=names(classResults)).

Duncan Murdoch




Also, how can I include the row.names variable. I tried


names(classResults)

[1] "subjEnglish"  "gradeEnglish" "subjFrench"   "gradeFrench"


but this does not include that name.

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] bias sampling

2012-03-18 Thread Thomas Lumley
On Mon, Mar 19, 2012 at 10:27 AM, David Winsemius
 wrote:
>
> On Mar 18, 2012, at 3:54 PM, Thomas Lumley wrote:
>
>> On Mon, Mar 19, 2012 at 6:34 AM, David Winsemius 
>> wrote:
>>>
>>>
>>> On Mar 16, 2012, at 1:09 PM, niloo javan wrote:
>>>
 hi
 i want to analyze Right Censore-Length bias data under cox model with
 covariate.
 what is the package ?
>>>
>>>
>>>
>>> I initially left this question alone because I thought there might be
>>> viewers for whom it all made perfect sense. After two days that
>>> probability
>>> seems to be declining. The problem I had was the meaning of "length bias
>>> data". Are you talking about a non-proportional effect in which the
>>> assumption of a constant hazard ratio over time is false and other
>>> methods
>>> are needed. If that is correct, then you should get a copy of Therneau
>>> and
>>> Grambsch's "Modeling Survival Data" and study the chapter on "Functional
>>> Form'. The package would be "survival".
>>>
>>
>> Length-biased sampling is what you get when you take a cross-sectional
>> sample of an ongoing process -- long intervals are over-represented.
>
>
> Thank you Thomas;
>
>  For example people who have survived to age 75 might be systematically
> different with respect to both the distribution of cardiovascular risk
> factors and their impact on the event of interest (AMI. CV death, or
> all-cause mortality) than persons at age 45. And that would also not take
> into account the fact those risk factors might have changed over the
> interval from age 45 to age 75 in the survivors?
>>
>>
>> If the arrival time is known for everyone in the sample, the usual Cox
>> model facilities for left truncation apply.  If the arrival times are
>> not known it would be much more difficult, and would probably need
>> parametric modelling.
>
>
>  Am I correct in thinking that additional assumptions about the
> "length-bias" would need to be explicitly stated or modeled under a set of
> plausible scenarios before progress in any framework could be anticipated?
> It would seem that there could be many forms of such a "length-bias".
>

Yes, as with any missing data problem things can go arbitrarily badly wrong.

The classical 'length-biased sampling' problem is a cross-sectional
sample from a stationary population process, and that gives good
results.

Obviously if you don't recruit anyone before time  T, there is no
information about what happened before then, but there may still be
useful information afterwards.  A good example is the research project
on after-effects of the nuclear bombings of Nagasaki and Hiroshima,
where recruitment started (IIRC) 5 years after the event.  There's no
information on survival in the first five years, but very good
subsequent information.

-thomas

-- 
Thomas Lumley
Professor of Biostatistics
University of Auckland

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

2012-03-18 Thread Santiago Guallar
Hello,
I'm trying to import into R files that contain data downloaded from logger 
devices as files with the following formats:
.act
.lig
.trj
.trn
These files are essentially text files but use both tabs and commas as 
separators.
I've tried the function scan:

1) scan("filename.act", what=character(0)) returns only two columns from the 
original 5
2) scan("copia.act", what=character(0),sep=",") returns three columns but puts 
the original fifth one in the next row

Attached a sample file with five fields. How can I get one field per column?

Thank you for your help
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] bias sampling

2012-03-18 Thread David Winsemius


On Mar 18, 2012, at 3:54 PM, Thomas Lumley wrote:

On Mon, Mar 19, 2012 at 6:34 AM, David Winsemius > wrote:


On Mar 16, 2012, at 1:09 PM, niloo javan wrote:


hi
i want to analyze Right Censore-Length bias data under cox model  
with

covariate.
what is the package ?



I initially left this question alone because I thought there might be
viewers for whom it all made perfect sense. After two days that  
probability
seems to be declining. The problem I had was the meaning of "length  
bias

data". Are you talking about a non-proportional effect in which the
assumption of a constant hazard ratio over time is false and other  
methods
are needed. If that is correct, then you should get a copy of  
Therneau and
Grambsch's "Modeling Survival Data" and study the chapter on  
"Functional

Form'. The package would be "survival".



Length-biased sampling is what you get when you take a cross-sectional
sample of an ongoing process -- long intervals are over-represented.


Thank you Thomas;

 For example people who have survived to age 75 might be  
systematically different with respect to both the distribution of  
cardiovascular risk factors and their impact on the event of interest  
(AMI. CV death, or all-cause mortality) than persons at age 45. And  
that would also not take into account the fact those risk factors  
might have changed over the interval from age 45 to age 75 in the  
survivors?


If the arrival time is known for everyone in the sample, the usual Cox
model facilities for left truncation apply.  If the arrival times are
not known it would be much more difficult, and would probably need
parametric modelling.


 Am I correct in thinking that additional assumptions about the  
"length-bias" would need to be explicitly stated or modeled under a  
set of plausible scenarios before progress in any framework could be  
anticipated? It would seem that there could be many forms of such a  
"length-bias".


--
David.



  -thomas

--
Thomas Lumley
Professor of Biostatistics
University of Auckland


David Winsemius, MD
Heritage Laboratories
West Hartford, CT

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

2012-03-18 Thread David Winsemius


On Mar 18, 2012, at 3:07 PM, mail me wrote:


Hi:
Thanks for reply. I am using the following statement

res <- with(df, table(paste(item1, item2, sep=', ')) )

to get the frequency counts of the rows, which gives the following  
output:

milk,bread 2
bread,butter 1
beer,diaper 3
milk,bread 2



You have already been asked why we readers should think that  
'milk,bread' has two different entries. Until that is resolved there  
is not a firm basis for offering further assistance.



But I need to extract from the above result two vectors or dataframes
(such as DF1 and DF2) to make the final output as below:

DF1
milk,bread
bread,butter
beer,diaper
milk,bread

DF2
2
1
3
2


Nonetheless, if you want to ignore the obvious problems in your data  
feel free to use this:


DF1 <- data.frame(V1 = res[ , 1])
DF2 <- data.frame(V1 = res[ , 2])

--

David Winsemius, MD
Heritage Laboratories
West Hartford, CT

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Cajun Code-a-thon in Lafayette LA 4/27 - 4/28

2012-03-18 Thread Erin Hodgess
Dear R People:

Is anyone going to attend the Cajun Code-a-thon in Lafayette, LA from
4/27 - 4/28, please?

I'd like to set up a team using R.

You can reply to me if you wish.

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.


Re: [R] Faster way to implement this search?

2012-03-18 Thread William Dunlap
> My current question is there a way to perform the same count, but with
> an arbitrary size pattern.  In other words, instead of a fixed pattern
> size of 3, could I have a pattern size of 4, 5, 6, ..., 30 any of which
> that could be run without changing the script?

Of course you cannot do this without changing your script.  However,
if you make a function out of it then you can change the function definition
to be more flexible and not have to change any calls to it.

Change your function from
  f <- function(x, test.pattern) {
  indx <- seq_len(length(x)-3) # 3 should be 2
  sum((x[indx] == test.pattern[1]) & (x[indx+1] == test.pattern[2]) & 
(x[indx+2] == test.pattern[3]))
  }
to
f <- function (x, test.pattern)  {
   if (length(x)  < length(test.pattern)) {
  0 # degenerate cases
   } else {
indx <- seq_len(length(x) - length(test.pattern) + 1)
match <- x[indx] == test.pattern[1]
for (i in seq_len(length(test.pattern) - 1)) {
match <- match & x[indx + i] == test.pattern[1 + i]
}
sum(match)
}
}
Give the function a name that is meaningful and memorable to you
and use it instead of copying the idiom in it when you need to do a search.

Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com


> -Original Message-
> From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On 
> Behalf
> Of Walter Anderson
> Sent: Saturday, March 17, 2012 5:56 AM
> To: Jeff Newmiller
> Cc: R Help
> Subject: Re: [R] Faster way to implement this search?
> 
> On 03/17/2012 12:53 AM, Jeff Newmiller wrote:
> >  for(indx in 1:(length(bin.05)-3))
> > >>> if ((bin.05[indx] == test.pattern[1])&&   (bin.05[indx+1] ==
> > >>>  test.pattern[2])&&   (bin.05[indx+2] == test.pattern[3]))
> > >>>   return.values$count.match.pattern[1] =
> > >>>  return.values$count.match.pattern[1] + 1
> Ok, sorry for not understanding the first time, here is my example with
> the type of data I am working with in this simulation
> 
>   test.pattern <- c("T", "T", "O")
>   bin.05 cut(runif(1000), breaks=c(-0.01,0.05,1), labels=c("T",
> "O"))
>   for(indx in 1:(length(bin.05)-3))
>  if (
>  (bin.05[indx] == test.pattern[1]) &&
>  (bin.05[indx+1] == test.pattern[2]) &&
>  (bin.05[indx+2] == test.pattern[3]))
>  count <- count + 1
> 
> Now the approach provided by William Dunlop sped up my simulation
> tremendously;
> 
> indx <- seq_len(length(bin.05)-3)
> count <- sum((bin.05[indx] == test.pattern[1]) &
> (bin.05[indx+1] == test.pattern[2]) &
> (bin.05[indx+2] == test.pattern[3]))
> 
> My current question is there a way to perform the same count, but with
> an arbitrary size pattern.  In other words, instead of a fixed pattern
> size of 3, could I have a pattern size of 4, 5, 6, ..., 30 any of which
> that could be run without changing the script?
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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] plotting border over map

2012-03-18 Thread Ray Brownrigg
On Sat, 17 Mar 2012, uday wrote:
> I am using following codes to plot map
> 
> library(sp)
> library(rgdal)
> library(maps)
> library(gplots)
> library(clim.pact)
> library(fields)
> source("/R/PlotGridded2DMap.R")
> source("/R/image.plot.fix.R")
> source("/R/image.plot.plt.fix.r")
> 
> seasonal_plot<-function(input,lonll=-180,latll=-90,lonres=5.,latres=3.75,wr
> ite_file=TRUE,The_title=NULL){ if(is.null(The_title)){
> for (ki in 1:length(input)){
>   The_title[[ki]]<-sprintf("XCH4 CH4 (ppb)",ki)
> }
>   }
>   if(!is.list(input)){input=list(input)}
>  lon.ll <- lonll   #lower left corner of grid
>  lat.ll <- latll#lower left corner of grid
>  lon.res<- lonres   #resolution in degrees longitude
>  lat.res<- latres#resolution in degrees latitude
> 
> for (ki in 1:length(input)){
> # plot for whole world
>   sh<-dim(input[[ki]]$avg)
>  numpix.x   <- sh[1] #number of pixels in x directions in
> grid
>  numpix.y   <- sh[2] #number of pixels in y directions in
> grid
>  #print(ki)
>  #print(input[[ki]]$avg)
>  mat<- t(input[[ki]]$avg)# length
>  xs <- seq(lon.ll,by=lon.res,length=dim(mat)[2])+0.5*lon.res
> #centers of cells
>  ys <- seq(lat.ll,by=lat.res,length=dim(mat)[1])+0.5*lat.res
> #centers of cells
>  col=rich.colors(32)
> 
>  xlims  <-c(-180,180)
>  ylims  <-c(-90,90)
> 
>  old.par<- par(no.readonly = TRUE)
>  par(mar=c(par()$mar[1:3],4))
>  cex.set<- 1.2
>  par(cex=cex.set)
>  par(mgp=c(2.0,0.3,0))
>  par(tcl=-0.1)
>  opath <- ("/Result/scitm3/") # path to save image
>  if(write_file){png(file=paste(opath,The_title[[ki]],".png",sep="
> "),width=1000,height=800,pointsize=23)}
> 
>   if(!write_file){x11()}
> 
> image.plot.fix(x=xs,y=ys,z=input[[ki]]$avg,zlim=c(1600,2000),nlevel=64,col=
> col,xlab="Longitude",ylab="Latitude",legend.width=0.03,
> offset=0.05,legend.only=F,lg=F)
> 
> map(database = "world", add=TRUE,col="black")
> 
>  title(paste(The_title[[ki]]))
>  if(write_file){dev.off()}
> 
> }
> }
> 
> when I try to use map(database = "world", add=TRUE,col="black")
> I get error
> Error in map(database = "world", add = TRUE, col = "black") :
>   unused argument(s) (database = "world")
> 
> if I comment this line then I get plot but it does not have world border.
> 
> I really got stuck at this point and I do not know how to fix it.
> 
Well, you haven't provided a minimal reproducible example, so we can only guess 
what is in 
/R/PlotGridded2DMap.R
/R/image.plot.fix.R
/R/image.plot.plt.fix.r
but my guess is you are redefining the map() function in there.

HTH,
Ray

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


[R] Help with dlply, loop and column names

2012-03-18 Thread Igor Sosa Mayor
Hi,

I have a dataframe basically like this:

> head(asturias.gen2011[,c(1,4,9:14)])
   municipio total upyd  psoeppiu   factipo
440  Allande  2031 1.44 31.10 39.75  4.01 21.62  1000-1
443Aller 12582 1.37 33.30 37.09 15.53 10.35 1-5
567   Amieva   805 1.48 32.69 37.36  6.15 20.16   <1000
849   Avilés 84202 4.15 30.26 35.49 14.37 11.80  >5
1087 Belmonte de Miranda  1751 1.66 38.42 35.74  7.22 14.81  1000-1
1260 Bimenes  1894 0.98 34.28 26.87 23.30 10.98  1000-1

I want to do the following:
1. for every party (psoe, pp, etc.) I want to create a variable like
this: upyd.lm.tipos, psoe.lm.tipos, etc.

2. I want to store in this variable a regression (psoe~total), but
split up by tipo.

I have the main idea of using dlply from the plyr vignette. But when I
try to put all this in a loop I'm coming into trouble and I'm at the
moment really confused how to solve this problem:

I have the following function:

elecregtipos <- function(y){
z<-dlply(asturias.gen2011, .(tipo), function(x) lm(x[,y]~x$edad.media))
# rsq<-function(x) summary(x)$r.squared
# bcoefs<-ldply(z, function(x) c(coef(x), rsquare=rsq(x))) 
#  return (bcoefs)
return(z)
}

And I try to call it with:
for (y in c("upyd", "psoe", "pp", "fac", "iu")) {
  eval(parse(text=paste(y,'.lm.tipos', '<- elecregtipos(',y,')',sep='')))
}

At the moment I'm getting the error:
Error en `[.data.frame`(x, , y) : objeto 'upyd' no encontrado

If I call simply: 
elecregtipos("upyd") 

it works perfectly. The problem is the loop, column names, etc., but I'm
really confused what I still could try, because I have already tried any
possibility.

Any hint? 

Thanks in advance.


-- 
:: Igor Sosa Mayor :: joseleopoldo1...@gmail.com ::
:: GnuPG: 0x1C1E2890   :: http://www.gnupg.org/  ::
:: jabberid: rogorido  ::::


pgpgGpuJRbo1C.pgp
Description: PGP signature
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] bias sampling

2012-03-18 Thread Thomas Lumley
On Mon, Mar 19, 2012 at 6:34 AM, David Winsemius  wrote:
>
> On Mar 16, 2012, at 1:09 PM, niloo javan wrote:
>
>> hi
>> i want to analyze Right Censore-Length bias data under cox model with
>> covariate.
>> what is the package ?
>
>
> I initially left this question alone because I thought there might be
> viewers for whom it all made perfect sense. After two days that probability
> seems to be declining. The problem I had was the meaning of "length bias
> data". Are you talking about a non-proportional effect in which the
> assumption of a constant hazard ratio over time is false and other methods
> are needed. If that is correct, then you should get a copy of Therneau and
> Grambsch's "Modeling Survival Data" and study the chapter on "Functional
> Form'. The package would be "survival".
>

Length-biased sampling is what you get when you take a cross-sectional
sample of an ongoing process -- long intervals are over-represented.

If the arrival time is known for everyone in the sample, the usual Cox
model facilities for left truncation apply.  If the arrival times are
not known it would be much more difficult, and would probably need
parametric modelling.

   -thomas

-- 
Thomas Lumley
Professor of Biostatistics
University of Auckland

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

2012-03-18 Thread mail me
Hi:
Thanks for reply. I am using the following statement

res <- with(df, table(paste(item1, item2, sep=', ')) )

to get the frequency counts of the rows, which gives the following output:
milk,bread 2
bread,butter 1
beer,diaper 3
milk,bread 2

But I need to extract from the above result two vectors or dataframes
(such as DF1 and DF2) to make the final output as below:

DF1
milk,bread
bread,butter
beer,diaper
milk,bread

DF2
2
1
3
2

Can anyone help? Thanks in advance!




On Sun, Mar 18, 2012 at 4:22 PM, S Ellison  wrote:
> You could do try
> with(df, table(item1:item2) )
> or
> with(df, table(paste(item1, item2, sep=', ')) )
>
> If the order is immaterial, so that (milk, bread) is the same as (bread, 
> milk), there's a bit more work to do. Maybe
>
> table( apply(df, 1, function(x) paste(sort(x))) )
>
> 
> From: r-help-boun...@r-project.org [r-help-boun...@r-project.org] On Behalf 
> Of mail me [mailme...@googlemail.com]
> Sent: 18 March 2012 13:31
> To: r-help
> Subject: Re: [R] word frequency count
>
> Hi:
>
> Suppose I create the dataframe df using the following code:
>
> df <- data.frame( item1 = c('milk',
> 'bread','beer','beer','milk','beer'), item2 =c('bread',
> 'butter','diaper','diaper','bread', 'diaper'), stringsAsFactors = F);
>
>
> df
>
>  item1  item2
> 1  milk  bread
> 2 bread butter
> 3  beer diaper
> 4  beer diaper
> 5  milk  bread
> 6  beer diaper
>
> And now i want the following output:milk,bread   2
> bread,butter 1
> beer,diaper  3
> milk,bread   2

>
> >
> and "milk,bread" is a single datum. I hope this clarifies the problem!
>
> Thanks!
>
>
>
> On 3/18/12, John Kane  wrote:
>> ? table
>>
>> First however confirm "that milk,bread" is a single datum. str() should do
>> this
>>
>> Can you post a sample of the data here using dput()?
>>
>> John Kane
>> Kingston ON Canada
>>
>>
>>> -Original Message-
>>> From: mailme...@googlemail.com
>>> Sent: Sun, 18 Mar 2012 13:12:48 +0200
>>> To: r-help@r-project.org
>>> Subject: [R] word frequency count
>>>
>>> Hi:
>>>
>>> I have a dataframe containing comma seperated group of words such as
>>>
>>> milk,bread
>>> bread,butter
>>> beer,diaper
>>> beer,diaper
>>> milk,bread
>>> beer,diaper
>>>
>>> I want to output the frequency of occurrence of comma separated words
>>> for each row and collapse duplicate rows, to make the output as shown
>>> in the following dataframe:
>>>
>>> milk,bread   2
>>> bread,butter 1
>>> beer,diaper  3
>>> milk,bread   2
>>>
>>> Thanks for help!
>>>
>>> deb
>>>
>>> __
>>> R-help@r-project.org mailing list
>>> https://stat.ethz.ch/mailman/listinfo/r-help
>>> PLEASE do read the posting guide
>>> http://www.R-project.org/posting-guide.html
>>> and provide commented, minimal, self-contained, reproducible code.
>>
>> 
>> FREE 3D MARINE AQUARIUM SCREENSAVER - Watch dolphins, sharks & orcas on your
>> desktop!
>> Check it out at http://www.inbox.com/marineaquarium
>>
>>
>>
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
> ***
> This email and any attachments are confidential. Any u...{{dropped:8}}

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


Re: [R] Extracting numbers from a character variable of different types

2012-03-18 Thread Daniel Malter
Assume your year value is 

x<-007/A

You want to replace all non-numeric characters (i.e. letters and
punctuation) and all zeros with nothing.

gsub('[[:alpha:]]|[[:punct:]]|0','',x)

Let's say you have a vector with both month and year values (you can
separate them). Now we need to identify the cells that have a month or year
indicator

x<-c("007/A","007/a","003/M","003/m")

grep("/A|/a",x) #cells in x with year information
grep("/M|/m",x) #cells in x with month information

To remove all characters, punctuation, and 0s from x, do:

gsub('[[:alpha:]]|[[:punct:]]|0','',x)

which you can also do specifically for the cells that identify months and
years, respectively:

years<-gsub('[[:alpha:]]|[[:punct:]]|0','',x[grep("/A|/a",x)]) #years
years
months<-gsub('[[:alpha:]]|[[:punct:]]|0','',x[grep("/M|/m",x)]) #months
months

Convert the resulting character vectors into numeric vectors by
as.numeric(as.character(years)) , for example.

HTH,
Daniel





--
View this message in context: 
http://r.789695.n4.nabble.com/Extracting-numbers-from-a-character-variable-of-different-types-tp4482248p4482732.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] assign a value to an element

2012-03-18 Thread David Winsemius


On Mar 18, 2012, at 2:24 PM, Marc Girondot wrote:

Assign can be used to set a value to a variable that has name as a  
value of another variable. Example:



name<-"essai"
assign(name, "plouf")
essai

[1] "plouf"

OK.
But how to do the same when it is only an element of a vector, data  
frame and so on that must be changed.



vec<-1:10
vec

 [1]  1  2  3  4  5  6  7  8  9 10

vec[4]

[1] 4

name<-"vec[4]"
assign(name, 100)
vec

 [1]  1  2  3  4  5  6  7  8  9 10

The reason is probably here (from help of assign):
assign does not dispatch assignment methods, so it cannot be used to  
set elements of vectors, names, attributes, etc.


Yes and further, vec[4] in your example does not have a name, since  
you created vect as an unnamed vector. It's not generally optimal  
practice to build up strings and pass them to eval(parse()).


However there is some assignment possible by name to data.frame rows  
with "["


> vecdf <- data.frame(vec=vec)
> vecdf['a' , ] <- 20
> vecdf
  vec
a  20
b  10
c   3
d   4
e   5
f   6
g   7
h   8
i   9
j  10

Where the rowname value is used as the index for assignment. Is that  
sufficiently elegant?




I have found this solution:

eval(parse(text=paste(name, "<-100", sep="")))
vec

 [1]   1   2   3 100   5   6   7   8   9  10

Is-it the only way ? It is not very elegant !

Thanks a lot

Marc



David Winsemius, MD
West Hartford, CT

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] assign a value to an element

2012-03-18 Thread William Dunlap
Do not use assign().  It is a relic from the 1980s.

Instead, decide where you want your
variables to live, perhaps in a list,
   where<-list()
or perhaps in an environment,
   where<-new.env()
or
  where<-environment().
Then use where[[varName]] to refer to the variable.  You can
use further subsetting functions on that.  E.g.,
   where <- environment() # the current environment
   varName <- "qwerty"
   where[[varName]] <- 1:10
   where[[varName]][2:3] <- log(where[[varName]][9:10])
   where[[varName]] 
   # [1]  1.00  2.197225  2.302585  4.00
   # [5]  5.00  6.00  7.00  8.00
   # [9]  9.00 10.00

Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com


> -Original Message-
> From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On 
> Behalf
> Of Marc Girondot
> Sent: Sunday, March 18, 2012 11:25 AM
> To: r-help@r-project.org
> Subject: [R] assign a value to an element
> 
> Assign can be used to set a value to a variable that has name as a value of 
> another
> variable. Example:
> 
> > name<-"essai"
> > assign(name, "plouf")
> > essai
> [1] "plouf"
> 
> OK.
> But how to do the same when it is only an element of a vector, data frame and 
> so on
> that must be changed.
> 
> > vec<-1:10
> > vec
>  [1]  1  2  3  4  5  6  7  8  9 10
> > vec[4]
> [1] 4
> > name<-"vec[4]"
> > assign(name, 100)
> > vec
>  [1]  1  2  3  4  5  6  7  8  9 10
> 
> The reason is probably here (from help of assign):
> assign does not dispatch assignment methods, so it cannot be used to set 
> elements of
> vectors, names, attributes, etc.
> 
> 
> I have found this solution:
> > eval(parse(text=paste(name, "<-100", sep="")))
> > vec
>  [1]   1   2   3 100   5   6   7   8   9  10
> 
> Is-it the only way ? It is not very elegant !
> 
> Thanks a lot
> 
> Marc
> 
> __
> Marc Girondot, Pr
> 
> Laboratoire Ecologie, Systématique et Evolution
> Equipe de Conservation des Populations et des Communautés
> CNRS, AgroParisTech et Université Paris-Sud 11 , UMR 8079
> Bâtiment 362
> 91405 Orsay Cedex, France
> 
> Tel:  33 1 (0)1.69.15.72.30   Fax: 33 1 (0)1.69.15.73.53
> e-mail: marc.giron...@u-psud.fr
> Web: http://www.ese.u-psud.fr/epc/conservation/Marc.html
> Skype: girondot
>   [[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] assign a value to an element

2012-03-18 Thread Marc Girondot
Assign can be used to set a value to a variable that has name as a value of 
another variable. Example:

> name<-"essai"
> assign(name, "plouf")
> essai
[1] "plouf"

OK.
But how to do the same when it is only an element of a vector, data frame and 
so on that must be changed.

> vec<-1:10
> vec
 [1]  1  2  3  4  5  6  7  8  9 10
> vec[4]
[1] 4
> name<-"vec[4]"
> assign(name, 100)
> vec
 [1]  1  2  3  4  5  6  7  8  9 10

The reason is probably here (from help of assign):
assign does not dispatch assignment methods, so it cannot be used to set 
elements of vectors, names, attributes, etc.


I have found this solution:
> eval(parse(text=paste(name, "<-100", sep="")))
> vec
 [1]   1   2   3 100   5   6   7   8   9  10

Is-it the only way ? It is not very elegant !

Thanks a lot

Marc

__ 
Marc Girondot, Pr 

Laboratoire Ecologie, Systématique et Evolution 
Equipe de Conservation des Populations et des Communautés 
CNRS, AgroParisTech et Université Paris-Sud 11 , UMR 8079 
Bâtiment 362 
91405 Orsay Cedex, France 

Tel:  33 1 (0)1.69.15.72.30   Fax: 33 1 (0)1.69.15.73.53 
e-mail: marc.giron...@u-psud.fr 
Web: http://www.ese.u-psud.fr/epc/conservation/Marc.html 
Skype: girondot 
[[alternative HTML version deleted]]

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


Re: [R] plot intersecting planes

2012-03-18 Thread Uwe Ligges

persp() is not really designed to do that.
rgl has a nice interface that allows this sort of things with its 
persp3d() function.


Uwe Ligges


On 07.03.2012 11:01, Simone Tenan wrote:

Hi all,

I need to plot two intersecting planes in a graph. Using persp() function
(see code below) I am not able to add a second plane with good results.
I tried with par(new=TRUE) but the output was very poor.
I have found some previous discussions about this point but (apparently)
without a clear solution.
Any advice would be appreciated.

Simone Tenan

##
library(popbio)
fec<-seq(0.1,2,0.1)
delta<- seq(0,0.6,0.05)
lambda<-matrix(0,length(fec),
length(delta))
S0=0.7
S1=0.8
S2=0.85
S3=S2
for (j in 1:length(delta)){
 for (i in 1:length(fec)){
 F1=0
 F2=fec[i]*0.05
 F3=fec[i]*0.3
 M<-matrix(0,3,3)
 M[1,]<-c(F1,F2*S0*(1-delta[j]),F3*S0*(1-delta[j]))
 M[2,]<-c(S1*(1-delta[j]),0,0)
 M[3,]<-c(0,S2*(1-delta[j]),S3*(1-delta[j]))
 lambda[i,j]<-eigen.analysis(M)$lambda
 }
}
res<- persp(fec,delta,lambda,xlim = range(fec), ylim =
range(delta),shade=T,theta = 230, phi = 20, expand = 0.8, col =
"lightblue",ticktype="detailed")
lines(trans3d(c(2,2,0.1,0.1,2), c(0.6,0,0,0.6,0.6),
c(1,1,1,1,1),res),col="blue")

[[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] suggestions for debugging problem with a package

2012-03-18 Thread Uwe Ligges



On 13.03.2012 07:15, Daniel Nordlund wrote:

I am trying to resolve a problem I am having with running the rattle package on 
two different Windows 7 x64 systems.  It appears to be a problem with my two 
specific systems, because others on Windows 7 x64 systems aren't complaining 
about this problem.  What I am looking for is a method for trying to determine 
the source of the problem.


If you have systems with same version of Windows, same R, both 64-bit, 
and they behave differently, then it may happen because of different 
versions of the Gtk framework.


Have you run

update.packages(checkBuilt=TRUE)

(to get updated R packages) and installed a recent enough version of Gtk?

Uwe Ligges





Here is what I am experiencing.  I had Rattle running fine (and it still does) 
under R-2.14.1 (CRAN binary build).  I installed R-2.14.2 and ran 
update.packages().  When I loaded rattle using library(rattle), it apparently 
got loaded OK.


library(rattle)

Rattle: A free graphical interface for data mining with R.
Version 2.6.17 Copyright (c) 2006-2011 Togaware Pty Ltd.
Type 'rattle()' to shake, rattle, and roll your data.




When I tried to run rattle using

rattle()

I got a popup window with the message

"R for Windows GUI front-end has stopped working.  A problem caused the program to 
stop working correctly.  Windows will close the program and notify you if a solution is 
available."

I am not sure how to proceed to track down this problem, since I get no 
messages from either the package or from R because R itself stops working.  I 
downloaded R-2.14.2patched and experienced the same problem.Any suggestions 
about how to debug this problem?

Thanks,

Dan

Daniel Nordlund
Bothell, WA USA


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


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

2012-03-18 Thread David Winsemius


On Mar 16, 2012, at 1:09 PM, niloo javan wrote:


hi
i want to analyze Right Censore-Length bias data under cox model  
with covariate.

what is the package ?


I initially left this question alone because I thought there might be  
viewers for whom it all made perfect sense. After two days that  
probability seems to be declining. The problem I had was the meaning  
of "length bias data". Are you talking about a non-proportional effect  
in which the assumption of a constant hazard ratio over time is false  
and other methods are needed. If that is correct, then you should get  
a copy of Therneau and Grambsch's "Modeling Survival Data" and study  
the chapter on "Functional Form'. The package would be "survival".


--
David Winsemius, MD
West Hartford, CT

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 : package is not installed for 'arch=x64'

2012-03-18 Thread Uwe Ligges



On 13.03.2012 18:18, Li, Yan wrote:

HI All,

I got the error : package  is not installed for 'arch=x64' when building my own 
package for 64bit R. How can I configure the arch ? The 'R CMD config' does not 
work. Thank you very much!


Which OS?

If Linux: run R with the desired architecture and install.package().

If Windows: See the R Installation and Administration manual that 
explains the steps to set the environment up correctly. And if you start 
with it, use R >= 2.14.2 so that you install the new toolchain to be 
compatible for future releases.


Uwe Ligges






The detailed error is :

** testing if installed package can be loaded
Error : package 'xxx' is not installed for 'arch=x64'
Error: loading failed
Execution halted
ERROR: loading failed

Best,
Yan

[[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] Linux R / Windows client

2012-03-18 Thread beltrand
Not really answering your question but as an alternative suggestion  you can
get a nice gui/ide for R on a server by using Rstudio server, which is for
Linux only. That way you won't need Windows at all.

http://rstudio.org/

--
View this message in context: 
http://r.789695.n4.nabble.com/Linux-R-Windows-client-tp4482087p4482382.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] call to system returns warning : status 2 (Ubuntu)

2012-03-18 Thread Uwe Ligges



On 18.03.2012 15:39, Eric Elguero wrote:

Hi everybody,

I have to run under Ubuntu a programs repeatedly
with different arguments and I am using R just to
generate the data files and call the external program.

basically, in my script I have inside a loop these two lines:

command<- paste(,sep="")
system(command,intern=T,wait=T)

when I run this script, I get a number of warnings,
like this one:

16: running command '~/LDhat22/ldconvert -seq ld/serca/serca-Trs.fas
-freqcut 0.0 -missfreqcut 100.0 -sites 1 3687 -nous 6>
ld/serca/serca-Trs.out' had status 2


Not sure what status 2 is in ldconvert. Are you sure you get 0 when you 
call it directly? Anyway, the issue may well come from using different 
shells (directly and via the system call).


Uwe Ligges







however, when I run the very same command at the bash prompt,
everything seems fine (no complaint).

in either cases, the output is the same and looks correct.

So, may I just ignore these warnings or is there something
I should fix?

thank you in advance,

Eric Elguero
MIVEGEC
IRD -CNRS - UM1
Montpellier - France

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] fitting plane to 3dim set of data

2012-03-18 Thread David Winsemius


On Mar 17, 2012, at 9:45 AM, phi771 wrote:


Hello!

I have a problem creating a fitting plane through my 3d-data set.  
here is a

sample how my set looks like (x,y,z (with z increasing)):


dataset

 [,1] [,2] [,3]
 [1,] -1.3712 -3.1551   10
 [2,] -1.2690 -3.0751   10
 [3,] -1.1216 -2.9768   10
 [4,] -0.9875 -2.8987   10
 [5,] -0.4021 -2.7542   10
 [6,]  0.0048 -2.6568   10
 [7,]  0.1642 -2.6071   10
 [8,]  0.0720 -2.5816   10
 [9,] -0.2961 -2.5552   10
[10,] -0.7770 -2.5118   10
[11,] -1.0970 -2.4508   10
[12,] -1.2456 -2.3786   10
[13,] -1.4179 -2.3276   10
[14,] -1.7759 -2.2667   10
[15,] -2.2801 -3.4330   11
[16,] -2.0254 -3.3232   11
[17,] -1.8960 -3.2282   11
[18,] -1.7148 -3.1101   11
[19,] -1.5559 -3.0150   11
[20,] -0.8677 -2.8460   11
[21,] -0.3568 -2.7250   11
[22,] -0.1721 -2.6692   11
[23,] -0.2951 -2.6373   11
[24,] -0.7103 -2.5965   11
[25,] -1.3342 -2.5458   11
[26,] -1.6955 -2.4662   11
[27,] -1.8697 -2.3821   11
[28,] -2.0863 -2.3138   11
[29,] -2.4981 -2.2376   11
[30,] -3.0639 -3.6329   12
[31,] -2.7939 -3.5062   12
[32,] -2.5782 -3.3798   12
[33,] -2.3708 -3.2439   12
[34,] -2.1916 -3.1285   12
[35,] -1.3914 -2.9368   12
[36,] -0.7883 -2.7911   12
[37,] -0.5625 -2.7263   12
[38,] -0.6858 -2.6882   12
[39,] -1.2123 -2.6343   12
[40,] -1.9606 -2.5708   12
[41,] -2.3586 -2.4765   12
[42,] -2.5972 -2.3738   12
[43,] -2.7832 -2.2905   12
[44,] -3.3004 -2.1983   12
[45,] -3.8862 -3.8286   13
[46,] -3.5691 -3.6789   13
[47,] -3. -3.5338   13
[48,] -3.0851 -3.3760   13
[49,] -2.8812 -3.2451   13
[50,] -1.9070 -3.0168   13
[51,] -1.2529 -2.8556   13
[52,] -0.9685 -2.7769   13
[53,] -1.1275 -2.7322   13
[54,] -1.7272 -2.6625   13
[55,] -2.5896 -2.5866   13
[56,] -3.0374 -2.4728   13
[57,] -3.3758 -2.3541   13
[58,] -3.5959 -2.2514   13
[59,] -4.1466 -2.1419   13
[60,] -4.8565 -4.0770   14
[61,] -4.5154 -3.9081   14
[62,] -4.1926 -3.7312   14
[63,] -3.8720 -3.5449   14
[64,] -3.6627 -3.3992   14
[65,] -2.5851 -3.1462   14
[66,] -1.7868 -2.9548   14
[67,] -1.4638 -2.8651   14
[68,] -1.6493 -2.8082   14
[69,] -2.3455 -2.7232   14
[70,] -3.3572 -2.6257   14
[71,] -3.8678 -2.4903   14
[72,] -4.1988 -2.3545   14
[73,] -4.5039 -2.2328   14
[74,] -5.0707 -2.1091   14

i want to have an analytical expression of a plane, which is smooth  
and

connects all data points.


I see that collection of requirements as being mutually exclusive for  
every case except the degenerate case where all points are on the  
plane. Is this homework? What are the requirements if this is a real  
problem?


Answers might involve one or more of these functions:

?lm
?persp
?lattice::wireframe
?rgl::plot3d
?car::scatter3d

--

David Winsemius, MD
West Hartford, CT

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

2012-03-18 Thread Uwe Ligges
your "not sepcial" stuff and afterwards add your special data with a 
call to points() in, e.g. anotehr color. If you want to separate plots, 
look at then lattice package.


Uwe Ligges


On 14.03.2012 15:16, sybil kennelly wrote:

Hi Guys, this is actually a thread of emails, but for some reason, even
though i am a member, it's withholding my email so i said i would try it
this route instead!...

I appreciate the reading Thank you. If i have:

matrix:

 var1var2 var3
cell1x   x x
cell2x   x x
cell3x   x x

cell4

.
.
.
.
cell100


and:

vector1<- c("cell1, "cell5",cell19", "cell50", "cell70")

your_data$mycells<- factor(your_data$cells %in% vector1, c("Special",
"NotSpecial"))

So my output will be something like:

[25] SpecialSpecialSpecialSpecialSpecialSpecial
   [31] SpecialNotSpecial NotSpecial NotSpecial NotSpecial NotSpecial
   [37] NotSpecial NotSpecial NotSpecial NotSpecial

is there a way to plot the data so that my "Special" cells are plotted on
top of my not special cells. The reason is my data may have 1 not
special points,and i may have 5 special cells, I find I'm not able to see
where they are on my plot because they are being covered by my not special
cells :(

I have been looking around for  "order of factors plotted" , 'order of
levels", "order of factor levels", is this on the right track or can it even
be done?

Syb

--
View this message in context: 
http://r.789695.n4.nabble.com/list-factoring-tp4471931p4471931.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.


[R] p-value and mlogit

2012-03-18 Thread Ville Iiskola
Hi

How does mlogit count the p-values of the variables?

Ville
[[alternative HTML version deleted]]

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


Re: [R] problem saving gplot.hexbin using file save as pdf - "Error: invalid graphics state

2012-03-18 Thread Uwe Ligges



On 18.03.2012 15:35, Henry wrote:

I can save to png, TIFF and jpg but get an error  "Error: invalid graphics
state" when trying to save as pdf and I have to restart R.
This happens when I add mtext lines.

There are a few other questions e.g. I want to move the mtext on side 1 to
the left, but that is the main issue for now.
I'm not using the ylab inside gplot.hexbin because it writes over the
numbers on the axis.

The file is  33k records but I could get a subset and paste in here if
people need that to resolve the issue.


Yes, please.

also, we get

Error: object 'gplot.hexbin' not found

which is probably in some not mentioned contributed package?

Uwe Ligges






the code

par(oma=c(3,3.5,3,1))
par(mar=c(2, 4, 0, 0))
plot.new()
gplot.hexbin(h, style = "colorscale",
colramp = function(n) {LinGray(7, beg=92, end=1)},
colorcut = 8,
xlab = "", ylab = "", main = "",
legend = .75, lcex = .8)

mtext("Outside Temperature (F)", side=1, line = 2, col="black",cex=1.1)
mtext("Electrical Power (kW)", side=2, line=6, col="black",cex=1.1) 

mtext("Building 90 - 2011 All Hours, All Days", side=3, line=0,
col="black",cex=1.2)  




--
View this message in context: 
http://r.789695.n4.nabble.com/problem-saving-gplot-hexbin-using-file-save-as-pdf-Error-invalid-graphics-state-tp4482235p4482235.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] Problem reading a graph file

2012-03-18 Thread Uwe Ligges



On 15.03.2012 13:47, Marc Marí Dell'Olmo wrote:

I obtain this message:


Error: C stack usage is too close to the limit


Using the function inla.read.graph?
Then please ask the corresponding package maintainer.

Uwe Ligges




Marc Marí-Dell'Olmo
CIBER Epidemiología y Salud Pública
Servei de Sistemes d'Informació Sanitària (SeSIS)
Agència de Salut Pública de Barcelona
Pl. Lesseps 1. 08023 Barcelona
Tel. 93 2027775 | Fax. 93 3686943
www.aspb.cat


El 15 de marzo de 2012 13:35, Marc Marí Dell'Olmo  escribió:


I am analysing a lot of cities, and with the testing version I have the
problem that INLA not works for some of them. I think that cities that do
not work are those with a lot of areas and, therefore, with big graph
files. For example I am working with cities with more than 3000 areas... is
it possible??

Marc Marí-Dell'Olmo
CIBER Epidemiología y Salud Pública
Servei de Sistemes d'Informació Sanitària (SeSIS)
Agència de Salut Pública de Barcelona
Pl. Lesseps 1. 08023 Barcelona
Tel. 93 2027775 | Fax. 93 3686943
www.aspb.cat


El 15 de marzo de 2012 13:24, help help  escribió:

It's fixed in the testing version

On Mar 15, 2012 1:23 PM, "Marc Marí Dell'Olmo"
wrote:


Hello!

I have a simple problem. I am using the R version 2.14.1 with the last
stable version of INLA (not the testing version) and windows 7 with 64bits.
Today I have rerunned some BYM models with the last version of INLA and I
have obtained errors. These models had already run with previous
versions of INLA (and previous versions of R) and I had not received any
errors.

I have tried to find the problem and I think that now the graph file is
not being read correctly. My graph has no disconnected components but
INLA thinks that I have 3 disconnected components. Have you changed the format
through which the neighbourhood matrix is specified?

I attach my graph file in order you can check this problem.


aux<- inla.read.graph("W:/bratislava.inla")
summary(aux)

 n =  17
 ncc =  3
 nnbs = (names)  2 3 4 5 6 7
(count)  2 4 5 2 2 2


___
this summary shoud be:
  n =  17
 ncc =  1
 nbs = (names)  2 3 4 5 6 7
   (count)  2 4 5 2 2 2



Thank you very much!

Marc Marí-Dell'Olmo
CIBER Epidemiología y Salud Pública
Servei de Sistemes d'Informació Sanitària (SeSIS)
Agència de Salut Pública de Barcelona
Pl. Lesseps 1. 08023 Barcelona
Tel. 93 2027775 | Fax. 93 3686943
www.aspb.cat







[[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] paste (CTRL + v) not working rgui

2012-03-18 Thread Ajay Askoolum


I've definitely encountered problems when running programs without 
administrator righs. Perhaps that was down to virus/spyware protection software.

At this linkhttp://forums.techarena.in/windows-software/1258938.htm there is 
the following suggestion

1.Click on Start
2.Type Run in Search and hit Enter
3.Type services.msc and hit enter
4.Find These services: ◦Network DDE DSDM.
◦Network DDE.
◦Clipbook.

5.Right Click on Each
6.And select Restart

NOt tried it - as I do not have the prolem - but it sounds plausible.
 
The alternative to the first 3 steps is Administration Tools + SERVICES>

[[alternative HTML version deleted]]

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


Re: [R] R crashes due to stats.dll

2012-03-18 Thread Uwe Ligges



On 18.03.2012 01:15, Ted Stankowich wrote:

Hello!
I've been running a looped AIC analysis using several modules including
ape, nlme, and MuMIn, and during one particularly long analysis, R (ver
2.14.12) crashes several minutes into the routine with the simple
message "R for windows GUI front-end has stopped working". I'm using a
brand new laptop with Windows 7, i7 processor, 8GB RAM. I've tried it on
both the 64 bit and 32 bit versions of R. Using the 64 bit version, the
analysis makes it through a few iterations before it crashes (maybe
about 20-25 min into the test).

The event viewer provides this information every time it crashes:
Faulting application name: Rgui.exe, version: 2.142.58522.0, time stamp:
0x4f4e7196
Faulting module name: stats.dll, version: 2.142.58522.0, time stamp:
0x4f4e72c0
Exception code: 0xc005

Does anyone have any idea what might be going wrong here?


Not unless you specify a minimal reproducible example that causes the 
crash, preferrably without using contribted packages. Otherwise the 
reason for the crash may be caused by them.


Uwe Ligges




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] plot only non-zero values

2012-03-18 Thread Uwe Ligges



On 17.03.2012 10:19, Joshua Wiley wrote:

What about just setting them to missing and plotting?

md<- yourdata
md[md==0]<- NA

My other idea depending how you want the plot to look would be to try something 
where 0 values get a blank colour or null plotting value




Or the OP is going to just ignore such data and want to plot na.omit(md) 
after you had set all 0 to NA.


Uwe





On Mar 16, 2012, at 22:53, Noah Silverman  wrote:


Hi,

i have some data in a matrix.  It has zero values scattered throughout, at 
random.

I'd like to create a line plot, with a line for each row, that *excludes* the 
zero or NA values.

The data looks like this (toy example)

10 12 21 0 23 0 43 0 NA 41
0 0 0 34 35 0 35 0 44 0
NA NA NA 3 2 5 0 3 2
etc...

Suggestions on an easy way to do this?

Thanks!

--
Noah Silverman
UCLA Department of Statistics
8208 Math Sciences Building
Los Angeles, CA 90095


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

2012-03-18 Thread Jeff Newmiller
My thought is that your question seems to be about StatET/Eclipse rather than 
R, so this may not be the best place to ask.

I don't know the answer, but since Eclipse works on Linux as well, that might 
be an option. I also think RStudio might be able to utilize a remote server. As 
to whether you will have to have a local installation of R setup before you can 
configure either application to go remote, I don't know but it should be easy 
to try it and find out or consult the appropriate documentation or support 
forum.
---
Jeff NewmillerThe .   .  Go Live...
DCN:Basics: ##.#.   ##.#.  Live Go...
  Live:   OO#.. Dead: OO#..  Playing
Research Engineer (Solar/BatteriesO.O#.   #.O#.  with
/Software/Embedded Controllers)   .OO#.   .OO#.  rocks...1k
--- 
Sent from my phone. Please excuse my brevity.

Mag Gam  wrote:

>Hello,
>
>I am currently running R on ubuntu and everything is working perfectly
>fine. However, I would like to connect to R via Windows using Eclipse
>StatEt plugin. Is this possible to do? or do I have to have a version
>of R running on Windows also? I prefer to have Linux do the heavy
>lifting and Windows Eclipse to be a sort of GUI.
>
>Any thoughts?
>
>__
>R-help@r-project.org mailing list
>https://stat.ethz.ch/mailman/listinfo/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] Extracting numbers from a character variable of different types

2012-03-18 Thread David Winsemius


On Mar 18, 2012, at 11:37 AM, David Winsemius wrote:



On Mar 18, 2012, at 10:44 AM, irene wrote:


Hello,

I have a file which contains a column with age, which is  
represented in the

two following patterns

1. "007/A" or ''007/a" or ''7 /a" . In this case A or a means  
year and I
would like to extract only the numeric values eg 7 in the above  
case if this

pattern exits in a line of file.

2. "004/M" or "004/m" where M or m means month .. for these  
lines I
would like to first extract the numeric value of Month eg. 4  and  
then
convert it into a value of years, which would be 0.33 eg 4 divided  
by 12.


I thought it easier to get to months as an initial step:

> dfrm <- read.table(text="'007/A'\n'007/a' \n '7 /a '\n '004/ 
M'\n'004/m'")


As I was thinking further it's easier (and clearer) to do it as years:

> dfrm$agenew3 <- sub("[mM]", "12", dfrm$V1)
> dfrm$agenew3 <- sub("[aA]", "1", dfrm$agenew3)
> sapply(dfrm$agenew3, function(x) eval(parse(text=x)) )
007/1 007/1 7 /1 004/12004/12
7.000 7.000 7.000 0.333 0.333



> dfrm$agenew <- sub("(^\\d+\\s*)(/)([aA])","\\1 * 12", dfrm$V1)
> dfrm$agenew2 <- sub("(^\\d+\\s*)(/)([mM])","\\1", dfrm$agenew)
> dfrm$agenew2
[1] "007 * 12" "007 * 12" "7  * 12 " "004"  "004"
> eval(parse(text=dfrm$agenew2))
[1] 4
> sapply(dfrm$agenew2, function(x) eval(parse(text=x)) )
007 * 12 007 * 12 7  * 12   004  004
 84   84   8444

--

David Winsemius, MD
West Hartford, CT

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

2012-03-18 Thread Tobias Verbeke

L.S.

On 03/18/2012 02:39 PM, Mag Gam wrote:


correct, but for StatET i believe I can only use the local R installed
to do my computation. My intention is to use my Linux server -- which
as 128GB of memory and 32 cores to do my calculations and I want to
connect to it via Windows Eclipse GUI.


That is perfectly possible. In summary you need to get the
rj-consoleserver tarball from the StatET website, untar it
(on the GNU/Linux machine) and edit the startup.sh script
that is included.

From your Windows client you then configure a so-called
Remote R Console within Eclipse and point to the startup.sh
file on the server.

It is BTW possible to tunnel all traffic over SSH just by
checking the appropriate box in the Remote Console run
configuration.

Help > Help Contents > StatET User Guide > R Console > Remote Console

gives some more extensive explanations.

Should you have further questions, don't hesitate to ask on
the StatET mailing list.

http://lists.r-forge.r-project.org/mailman/listinfo/statet-user

Best wishes,
Tobias


On Sun, Mar 18, 2012 at 9:13 AM, jose Bartolomei  wrote:


Hi,

I do not understand why you want to do that but


both Eclipse and StatEt are available for Linux environment.


Then, you can have everything running on Linux



http://www.eclipse.org/downloads/


http://www.walware.de/goto/statet


Jose






Date: Sun, 18 Mar 2012 08:56:39 -0400
From: magaw...@gmail.com
To: r-help@r-project.org
Subject: [R] Linux R / Windows client




Hello,

I am currently running R on ubuntu and everything is working perfectly
fine. However, I would like to connect to R via Windows using Eclipse
StatEt plugin. Is this possible to do? or do I have to have a version
of R running on Windows also? I prefer to have Linux do the heavy
lifting and Windows Eclipse to be a sort of GUI.

Any thoughts?

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] ANOVA testing over nested MS term

2012-03-18 Thread peter dalgaard

On Mar 18, 2012, at 08:21 , shoreliner11 wrote:

> I'm still relatively new to R but was wondering if anyone could help me force
> R to compute the f-statistic etc using the  the nested term rather than the
> residual. In my particular case we were nesting a treatment effect by a
> replicated tank which was not non-significant enough (p>0.25)to be dropped
> from the statistical model.

Ouch! Don't _ever_ take high p-values as proof of absence of effect. 

> 
> Here's my code:
> summary(analysis1<-aov(Area~Treatment/Tank))
> 
> Area is the response variable, treatment is the main effect, nested within a
> replicated tank. Thanks so much for your help.
> 

I.e. Tanks are numbered within Treatments, so that Treatment 1, Tank 1 is 
distinct from Treatment 2, Tank 1?

Something like aov(Area~Treatment + Error(Treatment:Tank)) should do it. 
There's a wart in aov() causing this sort of model to throw a warning that 
"Error() model is singular", for reasons that I never quite fathomed. An 
explicit 

TrTa <- interaction(Treatment,Tank)

and then using Error(TrTa) gets rid of the warning and provides equivalent 
output.


> --
> View this message in context: 
> http://r.789695.n4.nabble.com/ANOVA-testing-over-nested-MS-term-tp4481767p4481767.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.

-- 
Peter Dalgaard, Professor,
Center for Statistics, Copenhagen Business School
Solbjerg Plads 3, 2000 Frederiksberg, Denmark
Phone: (+45)38153501
Email: pd@cbs.dk  Priv: pda...@gmail.com

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


Re: [R] Extracting numbers from a character variable of different types

2012-03-18 Thread David Winsemius


On Mar 18, 2012, at 10:44 AM, irene wrote:


Hello,

I have a file which contains a column with age, which is represented  
in the

two following patterns

1. "007/A" or ''007/a" or ''7 /a" . In this case A or a means  
year and I
would like to extract only the numeric values eg 7 in the above case  
if this

pattern exits in a line of file.

2. "004/M" or "004/m" where M or m means month .. for these  
lines I

would like to first extract the numeric value of Month eg. 4  and then
convert it into a value of years, which would be 0.33 eg 4 divided  
by 12.


I thought it easier to get to months as an initial step:

> dfrm <- read.table(text="'007/A'\n'007/a' \n '7 /a '\n '004/ 
M'\n'004/m'")


> dfrm$agenew <- sub("(^\\d+\\s*)(/)([aA])","\\1 * 12", dfrm$V1)
> dfrm$agenew2 <- sub("(^\\d+\\s*)(/)([mM])","\\1", dfrm$agenew)
> dfrm$agenew2
[1] "007 * 12" "007 * 12" "7  * 12 " "004"  "004"
> eval(parse(text=dfrm$agenew2))
[1] 4
> sapply(dfrm$agenew2, function(x) eval(parse(text=x)) )
007 * 12 007 * 12 7  * 12   004  004
  84   84   8444




Can anyone help?

Thank you

--
View this message in context: 
http://r.789695.n4.nabble.com/Extracting-numbers-from-a-character-variable-of-different-types-tp4482248p4482248.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.


David Winsemius, MD
West Hartford, CT

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] paste (CTRL + v) not working rgui

2012-03-18 Thread Uwe Ligges



On 18.03.2012 07:44, AAsk wrote:

I am using 2.14.2 and use CTL+C&  CTL+V all the time without any
surprises; it simply works.

I suspect that you are using 2.14.2 on Windows 7 computer as user who
does not have Administrator provileges. If that is the case, by
default, R will not have access to the clipboard, hence the failures.


No, you do not need any special privileges to use the clipboard via 
Ctrl-c + Ctrl-v


I checked it myself on a Win 7 machine and it works perfectly for me, 
hence I guess this is some other R unrelated software interaction on the 
machine of the OP.


Uwe Ligges



Try starting R as Administrator, check Copy and Copy + Paste, and
update this thread.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Extracting numbers from a character variable of different types

2012-03-18 Thread irene
Hello,

I have a file which contains a column with age, which is represented in the
two following patterns

1. "007/A" or ''007/a" or ''7 /a" . In this case A or a means year and I
would like to extract only the numeric values eg 7 in the above case if this
pattern exits in a line of file.

2. "004/M" or "004/m" where M or m means month .. for these lines I
would like to first extract the numeric value of Month eg. 4  and then
convert it into a value of years, which would be 0.33 eg 4 divided by 12.

Can anyone help?

Thank you 

--
View this message in context: 
http://r.789695.n4.nabble.com/Extracting-numbers-from-a-character-variable-of-different-types-tp4482248p4482248.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] Having difficulties installing r commander

2012-03-18 Thread John Fox
Dear Rowan,

As you can see, the error message in your email did not come through,
probably because you posted your message in HTML, which isn't accepted by
the r-help list (see the mailing-list instructions).

I'm going to guess that you're working on Mac OS X. 

If the Rcmdr package was successfully installed, you needn't worry about the
dependencies. Just load the Rcmdr via library(Rcmdr) and it will offer to
download and install the additional packages that you need if any are really
missing.

If the Rcmdr package wasn't installed successfully, then you'll have to send
the resulting error message as plain text so that I can see what it is.
There have been recent problems with the index of Mac OX X binary packages
on CRAN, but I believe that it has been fixed, and I had no trouble just now
installing the Rcmdr on a Mac using the Ontario CRAN mirror.

The installation notes for the Rcmdr at

suggest that you use the command install.packages("Rcmdr"), which will end
up installing many fewer packages than if you set dependencies=TRUE. I
noticed that the command install.packages("Rcmdr", dependencies=TRUE) is
still mentioned on the main Rcmdr page, and I should change that.

Best,
 John


John Fox
Senator William McMaster
  Professor of Social Statistics
Department of Sociology
McMaster University
Hamilton, Ontario, Canada
http://socserv.mcmaster.ca/jfox



> -Original Message-
> From: r-help-boun...@r-project.org [mailto:r-help-bounces@r-
> project.org] On Behalf Of Rowan McCarthy
> Sent: March-18-12 2:56 AM
> To: r-help@r-project.org
> Subject: [R] Having difficulties installing r commander
> 
> Hi,
> I have recently installed R on my mac and am trying to install R
> commander.
> When I type:
> install.packages("Rcmdr",dependencies=TRUE)
> the following message appears
> 
> 
> I have also tried installing commander via the package installer
> window.
> When I do this a large number of error messages (over 50) appear. They
> are mainly saying that certain dependencies are not available, or that
> they could not be compiled.
> 
> Any clues on what I can do to fix this? I've followed the instructions
> online and have X11 open and have installed Tcl/Tk.
> thank you for your help,
> Rowan
> 
>   [[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] a question about writing C extensions to functions

2012-03-18 Thread Uwe Ligges



On 16.03.2012 18:08, Erin Hodgess wrote:

Dear R People:

I'm not sure if I should ask this here or in Rcpp,


Why is this related to Rcpp?


but I thought I'd
start here first.

If I'm writing a C program, when do I know to use SEXP vs. int or float, please?


For very short:

If you want keep some things internal to your C code, use int etc. , but 
if it makes sense to use R objects (e.g. because you return things or 
make use of otehr R functionality), use SEXP objects. If the latter, you 
already decided to use the .Call() interface.


There is more in Writing R Extensions.

Uwe



Thanks,
Erin




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


[R] Sensitivity analysis in case of correlated inputs

2012-03-18 Thread Jin Minming
Dear All,

There are two packages which can be used for sensitivtiy analysis when the 
predictor variables are correlated. 
a: pcc (partial correlation coefficient) in R sensitivity package
b: varimp in R party package (conditional importance)

Are other R packages available for sensitivity anlaysis to handle the 
correlated inputs?

Thanks,

Jim

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] call to system returns warning : status 2 (Ubuntu)

2012-03-18 Thread Eric Elguero
Hi everybody,

I have to run under Ubuntu a programs repeatedly
with different arguments and I am using R just to 
generate the data files and call the external program.

basically, in my script I have inside a loop these two lines:

command <- paste(,sep="")
system(command,intern=T,wait=T)

when I run this script, I get a number of warnings,
like this one:

16: running command '~/LDhat22/ldconvert -seq ld/serca/serca-Trs.fas
-freqcut 0.0 -missfreqcut 100.0 -sites 1 3687 -nous 6 >
ld/serca/serca-Trs.out' had status 2


however, when I run the very same command at the bash prompt,
everything seems fine (no complaint).

in either cases, the output is the same and looks correct.

So, may I just ignore these warnings or is there something
I should fix?

thank you in advance,

Eric Elguero
MIVEGEC
IRD -CNRS - UM1
Montpellier - France

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


[R] problem saving gplot.hexbin using file save as pdf - "Error: invalid graphics state

2012-03-18 Thread Henry
I can save to png, TIFF and jpg but get an error  "Error: invalid graphics
state" when trying to save as pdf and I have to restart R.
This happens when I add mtext lines.

There are a few other questions e.g. I want to move the mtext on side 1 to
the left, but that is the main issue for now.
I'm not using the ylab inside gplot.hexbin because it writes over the
numbers on the axis.

The file is  33k records but I could get a subset and paste in here if
people need that to resolve the issue.
the code

par(oma=c(3,3.5,3,1))
par(mar=c(2, 4, 0, 0))
plot.new()
gplot.hexbin(h, style = "colorscale", 
colramp = function(n) {LinGray(7, beg=92, end=1)},
colorcut = 8,
xlab = "", ylab = "", main = "",
legend = .75, lcex = .8)

mtext("Outside Temperature (F)", side=1, line = 2, col="black",cex=1.1)
mtext("Electrical Power (kW)", side=2, line=6, col="black",cex=1.1) 

mtext("Building 90 - 2011 All Hours, All Days", side=3, line=0,
col="black",cex=1.2)




--
View this message in context: 
http://r.789695.n4.nabble.com/problem-saving-gplot-hexbin-using-file-save-as-pdf-Error-invalid-graphics-state-tp4482235p4482235.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] word frequency count

2012-03-18 Thread Uwe Ligges



On 18.03.2012 14:31, mail me wrote:

Hi:

Suppose I create the dataframe df using the following code:

df<- data.frame( item1 = c('milk',
'bread','beer','beer','milk','beer'), item2 =c('bread',
'butter','diaper','diaper','bread', 'diaper'), stringsAsFactors = F);


df

  item1  item2
1  milk  bread
2 bread butter
3  beer diaper
4  beer diaper
5  milk  bread
6  beer diaper

And now i want the following output:

milk,bread   2
bread,butter 1
beer,diaper  3
milk,bread   2


Why do you want "milk,bread" twice?



and "milk,bread" is a single datum. I hope this clarifies the problem!



If you don't want milk,bread twice, I'd go with:

table(apply(df, 1, paste, collapse=","))

Uwe Ligges



Thanks!



On 3/18/12, John Kane  wrote:

? table

First however confirm "that milk,bread" is a single datum. str() should do
this

Can you post a sample of the data here using dput()?

John Kane
Kingston ON Canada



-Original Message-
From: mailme...@googlemail.com
Sent: Sun, 18 Mar 2012 13:12:48 +0200
To: r-help@r-project.org
Subject: [R] word frequency count

Hi:

I have a dataframe containing comma seperated group of words such as

milk,bread
bread,butter
beer,diaper
beer,diaper
milk,bread
beer,diaper

I want to output the frequency of occurrence of comma separated words
for each row and collapse duplicate rows, to make the output as shown
in the following dataframe:

milk,bread   2
bread,butter 1
beer,diaper  3
milk,bread   2

Thanks for help!

deb

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



FREE 3D MARINE AQUARIUM SCREENSAVER - Watch dolphins, sharks&  orcas on your
desktop!
Check it out at http://www.inbox.com/marineaquarium





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

2012-03-18 Thread mail me
Hi:

Suppose I create the dataframe df using the following code:

df <- data.frame( item1 = c('milk',
'bread','beer','beer','milk','beer'), item2 =c('bread',
'butter','diaper','diaper','bread', 'diaper'), stringsAsFactors = F);


df

 item1  item2
1  milk  bread
2 bread butter
3  beer diaper
4  beer diaper
5  milk  bread
6  beer diaper

And now i want the following output:

milk,bread   2
bread,butter 1
beer,diaper  3
milk,bread   2

and "milk,bread" is a single datum. I hope this clarifies the problem!

Thanks!



On 3/18/12, John Kane  wrote:
> ? table
>
> First however confirm "that milk,bread" is a single datum. str() should do
> this
>
> Can you post a sample of the data here using dput()?
>
> John Kane
> Kingston ON Canada
>
>
>> -Original Message-
>> From: mailme...@googlemail.com
>> Sent: Sun, 18 Mar 2012 13:12:48 +0200
>> To: r-help@r-project.org
>> Subject: [R] word frequency count
>>
>> Hi:
>>
>> I have a dataframe containing comma seperated group of words such as
>>
>> milk,bread
>> bread,butter
>> beer,diaper
>> beer,diaper
>> milk,bread
>> beer,diaper
>>
>> I want to output the frequency of occurrence of comma separated words
>> for each row and collapse duplicate rows, to make the output as shown
>> in the following dataframe:
>>
>> milk,bread   2
>> bread,butter 1
>> beer,diaper  3
>> milk,bread   2
>>
>> Thanks for help!
>>
>> deb
>>
>> __
>> R-help@r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide
>> http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>
> 
> FREE 3D MARINE AQUARIUM SCREENSAVER - Watch dolphins, sharks & orcas on your
> desktop!
> Check it out at http://www.inbox.com/marineaquarium
>
>
>

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

2012-03-18 Thread jose Bartolomei













Hi,
I do not understand why you want to do
that but



both Eclipse and StatEt are available
for Linux environment.  

Then, you can have everything running on Linux








http://www.eclipse.org/downloads/



http://www.walware.de/goto/statet
Jose










> Date: Sun, 18 Mar 2012 08:56:39 -0400
> From: magaw...@gmail.com
> To: r-help@r-project.org
> Subject: [R] Linux R / Windows client
> 
> Hello,
> 
> I am currently running R on ubuntu and everything is working perfectly
> fine. However, I would like to connect to R via Windows using Eclipse
> StatEt plugin. Is this possible to do? or do I have to have a version
> of R running on Windows also? I prefer to have Linux do the heavy
> lifting and Windows Eclipse to be a sort of GUI.
> 
> Any thoughts?
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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] Matrix Results

2012-03-18 Thread Uwe Ligges



On 13.03.2012 15:40, RMSOPS wrote:

Hello


Error: could not find function sqldf:

Hello, I'm using R Studio, and installed the option of installing the
packages sqldbf function.
 But When I run the code give the next error.


install.packages("sqldf")
library("RSQLite")
require(sqldf)
  x<- read.fwf(textConnection("4 - 4   56
+ 4 - 3   61
+ 3 - 3   300
+ 3 - 327
+ 3 - 3   33
+ 3 - 3   87
+ 3 - 4  49
+ 4 - 4  71
+ 4 - 3 121
+ 3 - 4 138
+ 4 - 3  15"), width = c(7,8) , header = FALSE, as.is = TRUE)
closeAllConnections()
  sqldf("
+ select V1
+ , count(*) as Freq
+ , min(V2) as Min
+ , max(V2) as Max
+ , median(V2) as Median
+ from x
+ group by V1
+ ")


ERROR: lazy loading failed for package ‘sqldf’
* removing ‘/home/ricardosousa/R/x86_64-pc-linux-gnu-library/2.13/sqldf’
Warning in install.packages :
   installation of package 'sqldf' had non-zero exit status



So that error message tells us that the installation of sqldf did not 
succeed on your machine.


Uwe Ligges



The downloaded packages are in
‘/tmp/RtmpS53jrJ/downloaded_packages’



--
View this message in context: 
http://r.789695.n4.nabble.com/Matrix-Results-tp4468642p4469239.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] install R package on Unix cluster

2012-03-18 Thread Uwe Ligges



On 18.03.2012 05:47, Lorenzo Cattarino wrote:

Hi R users,

Working from a PC, I am trying to install the spatstat package on a Unix 
cluster. I created the following PBS file to send a job array:

#!/bin/bash -ue

#PBS -m ae
#PBS -M my email
#PBS -J 1-45
#PBS -A my username
#PBS -N job name
#PBS -l resources
#PBS -l walltime

cd $PBS_O_WORKDIR

module load R/2.14.1

R CMD INSTALL -l /path/to/library spatstat


This command installs *a* source package from the current subdirectory 
spatstat.


If there is no such directory containing the sources, it won't work.
Either provide the gzipped tarball and give its name or use 
install.packages("spatstat") within an R script.


It makes sense to install it outside the parallel processing into a 
common directory and just use it in parallel (It is not entirely clear 
to me if you are really running the installation on all nodes).


Uwe Ligges





R CMD BATCH /path/to/folder/Script_$PBS_ARRAY_INDEX.R

Obviosuly I failed to understand pag 19 of the R admin manual because I keep 
getting the following error message:

Warning: invalid package ‘spatstat’
Error: ERROR: no packages specified

I'd appreciate if you can point me in the right direction

Thanks
Lorenzo


[[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] Linux R / Windows client

2012-03-18 Thread Mag Gam
correct, but for StatET i believe I can only use the local R installed
to do my computation. My intention is to use my Linux server -- which
as 128GB of memory and 32 cores to do my calculations and I want to
connect to it via Windows Eclipse GUI.




On Sun, Mar 18, 2012 at 9:13 AM, jose Bartolomei  wrote:
>
> Hi,
>
> I do not understand why you want to do that but
>
>
> both Eclipse and StatEt are available for Linux environment.
>
>
> Then, you can have everything running on Linux
>
>
>
> http://www.eclipse.org/downloads/
>
>
> http://www.walware.de/goto/statet
>
>
> Jose
>
>
>
>
>
>> Date: Sun, 18 Mar 2012 08:56:39 -0400
>> From: magaw...@gmail.com
>> To: r-help@r-project.org
>> Subject: [R] Linux R / Windows client
>
>>
>> Hello,
>>
>> I am currently running R on ubuntu and everything is working perfectly
>> fine. However, I would like to connect to R via Windows using Eclipse
>> StatEt plugin. Is this possible to do? or do I have to have a version
>> of R running on Windows also? I prefer to have Linux do the heavy
>> lifting and Windows Eclipse to be a sort of GUI.
>>
>> Any thoughts?
>>
>> __
>> R-help@r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/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] word frequency count

2012-03-18 Thread John Kane
? table

First however confirm "that milk,bread" is a single datum. str() should do this

Can you post a sample of the data here using dput()?

John Kane
Kingston ON Canada


> -Original Message-
> From: mailme...@googlemail.com
> Sent: Sun, 18 Mar 2012 13:12:48 +0200
> To: r-help@r-project.org
> Subject: [R] word frequency count
> 
> Hi:
> 
> I have a dataframe containing comma seperated group of words such as
> 
> milk,bread
> bread,butter
> beer,diaper
> beer,diaper
> milk,bread
> beer,diaper
> 
> I want to output the frequency of occurrence of comma separated words
> for each row and collapse duplicate rows, to make the output as shown
> in the following dataframe:
> 
> milk,bread   2
> bread,butter 1
> beer,diaper  3
> milk,bread   2
> 
> Thanks for help!
> 
> deb
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.


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

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


[R] Linux R / Windows client

2012-03-18 Thread Mag Gam
Hello,

I am currently running R on ubuntu and everything is working perfectly
fine. However, I would like to connect to R via Windows using Eclipse
StatEt plugin. Is this possible to do? or do I have to have a version
of R running on Windows also? I prefer to have Linux do the heavy
lifting and Windows Eclipse to be a sort of GUI.

Any thoughts?

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

2012-03-18 Thread mail me
Hi:

I have a dataframe containing comma seperated group of words such as

milk,bread
bread,butter
beer,diaper
beer,diaper
milk,bread
beer,diaper

I want to output the frequency of occurrence of comma separated words
for each row and collapse duplicate rows, to make the output as shown
in the following dataframe:

milk,bread   2
bread,butter 1
beer,diaper  3
milk,bread   2

Thanks for help!

deb

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

2012-03-18 Thread Jim Holtman
to remove an individual column:

classResults$subjEnglish <- NULL

to remove object:

rm(classResults)

to access student names:

row.names(classResults)

Sent from my iPad

On Mar 18, 2012, at 5:31, Ajay Askoolum  wrote:

> If I create a data.frame using session variables as follows:
> 
> classResults<-data.frame(subjEnglish,gradeEnglish,subjFrench,gradeFrench,row.names=studentName)
> 
> 
> How can I remove the variables? I tried
> 
>> rm(names(classResults))
> Error in rm(names(classResults)) : 
>   ... must contain names or character strings
> 
> 
> Also, how can I include the row.names variable. I tried
> 
>> names(classResults)
> [1] "subjEnglish"  "gradeEnglish" "subjFrench"   "gradeFrench" 
> 
> 
> but this does not include that name.
> 
> 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] ANOVA testing over nested MS term

2012-03-18 Thread shoreliner11
I'm still relatively new to R but was wondering if anyone could help me force
R to compute the f-statistic etc using the  the nested term rather than the
residual. In my particular case we were nesting a treatment effect by a
replicated tank which was not non-significant enough (p>0.25)to be dropped
from the statistical model.

Here's my code:
summary(analysis1<-aov(Area~Treatment/Tank))

Area is the response variable, treatment is the main effect, nested within a
replicated tank. Thanks so much for your help.

--
View this message in context: 
http://r.789695.n4.nabble.com/ANOVA-testing-over-nested-MS-term-tp4481767p4481767.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] how to modify the tickment of x-axis

2012-03-18 Thread Jim Lemon

On 03/18/2012 02:00 PM, Jie Tang wrote:

I have found that  the dimension number of label must be equal with the
dimension of the plot data by your this method.
if we have two data in every hour,it seems can not show the correct
tickment?
.plot(1:20, xaxt = "n")
axis(1, at = 1:10, label = paste(1:10, "h", sep = "")) # Happy axis!


Hi Jie,
What is happening is that if you only pass the "y" values to "plot", it 
makes up the "x" values by using 1 to the number of y values. So:


plot(1:20)

has the "y" values 1 to 20, and because there are twenty values, it also 
has the "x" values of 1 to 20.


plot(11:30)

would have the same "x" values. There are two ways to get the values you 
want on the x axis. Say you have 20 values over 10 hours like this:


values<-c(rnorm(20,5,1))
hours<-as.numeric(paste(rep(8:17,each=2),c("00","30"),sep=""))
plot(hours,values,type="l")

Now your x axis shows hours in a "pretty" sequence. If you want all hours:

plot(hours,values,type="l",xaxt="n")
axis(1,at=seq(800,1700,by=100))

That's the easy way. You can do it like this also:

plot(values,type="l",xaxt="n")
axis(1,at=seq(1,19,by=2),labels=seq(800,1700,by=100))

Got it?

Jim

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

2012-03-18 Thread Ajay Askoolum
If I create a data.frame using session variables as follows:

classResults<-data.frame(subjEnglish,gradeEnglish,subjFrench,gradeFrench,row.names=studentName)


How can I remove the variables? I tried

> rm(names(classResults))
Error in rm(names(classResults)) : 
  ... must contain names or character strings


Also, how can I include the row.names variable. I tried

> names(classResults)
[1] "subjEnglish"  "gradeEnglish" "subjFrench"   "gradeFrench" 


but this does not include that name.

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] memory, i am getting mad in reading climate data

2012-03-18 Thread Prof Brian Ripley

On 17/03/2012 20:42, jim holtman wrote:

Another suggestion is to start with a subset of the data file to see
how much memory is required for your processing.  One of the
misconceptions is that "memory is free".  People think that with
virtual memory and other such tools, that there is no restriction on
what you can do.  Instead of starting off, and getting "mad", when
trying to read in all your data, try a small subset and then look at
the memory usage of the R process.  I would assume that you are
running on a 32-bit Windows system, which if you are lucky, can
address 3GB for a user process.  My rule of thumb is that the largest
object I can work with is 30% of the real memory I have available, so
for my Windows system which lets me address almost 3GB, the biggest
object I would attempt to work with is 1GB,


But that's because your real limit is address space, not the amount of 
memory you have.  Only people with 32-bit OSes have that problem, and 
they are rapidly going obsolete.  Some of us have been using 64-bit OSes 
for more than a decade (even with 1GB of RAM).



Working with a subset, you would understand how much memory an XXXMB
file might require.  This would then give you an idea of what the
maximum size file you might be able to process.

Every system has limits.  If you have lots of money, then invest in a
64-bit system with 100GB of real memory and you probably won't hit its


Actually, you only need a pretty modest amount of money for that, and an 
extremely modest amount for a 64-bit system with 8GB RAM (which will 
give you maybe 5x more usable memory than Jim's system).


Just about any desktop computer made in the last 5 years can be upgraded 
to that sort of spec (and our IT staff did so for lots of our machines 
in mid-2010).



limits for a while.  Otherwise, look at taking incremental steps and
possibly determining if you can partition the data.  You might
consider a relational database to sotre the data so that it is easier
to select a subset of data to process.


But in this case, netCDF is itself a sort of database system with lots 
of facilities to select subsets of the data.






2012/3/17 Uwe Ligges:



On 17.03.2012 19:27, David Winsemius wrote:



On Mar 17, 2012, at 10:33 AM, Amen wrote:


I faced this problem when typing:

temperature<- get.var.ncdf( ex.nc, 'Temperature' )

*unable to allocate a vector of size 2.8 GB*



Read the R-Win-FAQ







By the way my computer memory is 4G and the original size of the file is
1.4G,netcdf file



... and reading / storing the data in memory may require much more than
4GB...

Uwe Ligges



I don't know what is the problem.Any suggestion please
I tried also
memory limit(4000)
4000
but didnt solve the problem.any help




--
Brian D. Ripley,  rip...@stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel:  +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UKFax:  +44 1865 272595

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

2012-03-18 Thread Lorenzo Cattarino
Hi R users,

Working from a PC, I am trying to install the spatstat package on a Unix 
cluster. I created the following PBS file to send a job array:

#!/bin/bash -ue

#PBS -m ae
#PBS -M my email
#PBS -J 1-45
#PBS -A my username
#PBS -N job name
#PBS -l resources
#PBS -l walltime

cd $PBS_O_WORKDIR

module load R/2.14.1

R CMD INSTALL -l /path/to/library spatstat

R CMD BATCH /path/to/folder/Script_$PBS_ARRAY_INDEX.R

Obviosuly I failed to understand pag 19 of the R admin manual because I keep 
getting the following error message:

Warning: invalid package ‘spatstat’
Error: ERROR: no packages specified

I'd appreciate if you can point me in the right direction

Thanks
Lorenzo


[[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] Having difficulties installing r commander

2012-03-18 Thread Rowan McCarthy
Hi,
I have recently installed R on my mac and am trying to install R commander.
When I type:
install.packages("Rcmdr",dependencies=TRUE)
the following message appears


I have also tried installing commander via the package installer window.
When I do this a large number of error messages (over 50) appear. They are
mainly saying that certain dependencies are not available, or that they
could not be compiled.

Any clues on what I can do to fix this? I've followed the instructions
online and have X11 open and have installed Tcl/Tk.
thank you for your help,
Rowan

[[alternative HTML version deleted]]

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


Re: [R] Error in conditional execution "missing value where TRUE/FALSE needed"

2012-03-18 Thread Dong-Joon Lim
Yes, that was the problem.
Now it's solved.

Thanks a lot,
Dong-Joon


On Sat, Mar 17, 2012 at 6:38 AM, R. Michael Weylandt <
michael.weyla...@gmail.com> wrote:

> My guess is that you're not getting what you expect from operator
> precedence: note that
>
> 1:3 - 1
> 1:(3-1) #Not equal
>
> If that doesn't fix it, you can use options(error = recover) to find
> the values of your logical conditions at the exact moment an error is
> thrown and see which one is NA but my money is on the above.
>
> Michael
>
>
> On Sat, Mar 17, 2012 at 5:34 AM, Dong-Joon Lim 
> wrote:
> > Hello R friends,
> >
> > I've got error message as follows;
> >
> >>
> >> n<-0
> >> roc<-array(0,c(ti-1,1))
> >> avgroc<-0
> >>
> >> for(i in 1:ti-1){
> > +  if(orientation=="in"){
> > +   if(eff_p1[i,1,i]==1 && eff_p1[i,1,ti-1]<1 && ed[i,1]>d[i,1]){
> > +  roc[i,1]<-(1/eff_p1[i,1,ti-1])^(1/(ed[i,1]-d[i,1]))
> > +  n<-n+1
> > +   }
> > +  }
> > +  if(orientation=="out"){
> > +   if(eff_p1[i,1,i]==1 && eff_p1[i,1,ti-1]>1 && ed[i,1]>d[i,1]){
> > +roc[i,1]<-(eff_p1[i,1,ti-1])^(1/(ed[i,1]-d[i,1]))
> > +n<-n+1
> > +   }
> > +  }
> > + }
> > Error in if (eff_p1[i, 1, i] == 1 && eff_p1[i, 1, ti - 1] < 1 && ed[i,  :
> >  missing value where TRUE/FALSE needed
> >
> > I checked "eff_p1[i,1,i]==1 && eff_p1[i,1,ti-1]<1 && ed[i,1]>d[i,1]" for
> > all i and it returned either TRUE or FALSE normally.
> > Why it shows error message when I link it with repetitive execution (for
> i
> > in 1:ti-1)?
> > All variables have been defined correctly including ti, orientation,
> > eff_p1, and ed.
> >
> > Thanks in advance,
> > DJ
> >
> >[[alternative HTML version deleted]]
> >
> > __
> > R-help@r-project.org mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> > and provide commented, minimal, self-contained, reproducible code.
>

[[alternative HTML version deleted]]

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


[R] R package to efficiently create polyline shape file

2012-03-18 Thread yeheng...@gmail.com
I need to convert dbf/csv data to an ESRI shape file consisting of 200,000
polylines in R.  I used the package "shapefiles" that can create small shape
files.  I found it takes too much time for create 200,000 polylines.  I
checked the source codes and found R loop is used.  I guess it may be the
reason.  

I tried some other software and found the procedure just takes a few seconds
but I want to do the work in R. Is there a package using compiled codes so
that this work can be done more efficiently?   Thanks a lot for your
precious information!

--
View this message in context: 
http://r.789695.n4.nabble.com/R-package-to-efficiently-create-polyline-shape-file-tp4481558p4481558.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] R crashes due to stats.dll

2012-03-18 Thread Ted Stankowich

Hello!
I've been running a looped AIC analysis using several modules including 
ape, nlme, and MuMIn, and during one particularly long analysis, R (ver 
2.14.12) crashes several minutes into the routine with the simple 
message "R for windows GUI front-end has stopped working".  I'm using a 
brand new laptop with Windows 7, i7 processor, 8GB RAM.  I've tried it 
on both the 64 bit and 32 bit versions of R.  Using the 64 bit version, 
the analysis makes it through a few iterations before it crashes (maybe 
about 20-25 min into the test).


The event viewer provides this information every time it crashes:
Faulting application name: Rgui.exe, version: 2.142.58522.0, time stamp: 
0x4f4e7196
Faulting module name: stats.dll, version: 2.142.58522.0, time stamp: 
0x4f4e72c0

Exception code: 0xc005

Does anyone have any idea what might be going wrong here?

Thanks in advance!

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


Re: [R] paste (CTRL + v) not working rgui

2012-03-18 Thread AAsk
I am using 2.14.2 and use CTL+C & CTL+V all the time without any
surprises; it simply works.

I suspect that you are using 2.14.2 on Windows 7 computer as user who
does not have Administrator provileges. If that is the case, by
default, R will not have access to the clipboard, hence the failures.
Try starting R as Administrator, check Copy and Copy + Paste, and
update this thread.

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