[R] Package rms: c-statistic from lrm function with weights

2016-06-15 Thread Marie-Pierre Sylvestre
Dear list,

I am using the lrm function from the rms package to estimate a logistic
model with weights. The c-statistic (or area under the curve) is part of
the lrm output.

To understand how the weights enter the computation of the c-statistics, I
looked at the script of lrm and lrm.fit but I am out of luck because it is
making a call to a Fortran routine and I don't know Fortran.

z <- .Fortran("lrmfit", coef = initial, nx, 1:nx, x,
y, offset, u = double(nvi), double(nvi * (nvi + 1)),
double(1), n, nx, sumw, nvi, v = double(nvi * nvi),
double(nvi), double(2 * nvi), double(nvi), integer(nvi),
opts = opts, ftable, penmat, weights, PACKAGE = "rms")


Can somebody help me figure out how the weights from the regression are
used in the computation of the c-statistic? Here is a small example that
shows that the c-statistic computed from the rms package and using the pROC
packages are not the same (not even close) when calculated from a weighted
logistic regression.

set.seed(1233)
x <- rnorm(100)
w <- runif(100)
y <- rbinom(100, 1, .5)
require(rms)
# unweighted model
umod <- lrm(y~x)
umod$stat # c-statistic is   0.5776796
# weighted model
wmod <- lrm(y~x, weight = w)
wmod$stat # c-statistic is  0.65625
# using pROC
require(pROC)
umod2 <- glm(y~x, family = binomial)
auc(y, predict(umod2)) # 0.5769
wmod2 <- glm(y~x, weights = w, family = binomial)
auc(y, predict(wmod2)) # 0.5769

BTW results from umod and umod2 and from wmod and wmod2 are identical so
the discrepancy in c-statistics in not due to using lrm vs. glm.

Best regards,
MP

[[alternative HTML version deleted]]

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


[R] cv.binary problem

2016-06-15 Thread Amit Sengupta via R-help
HI,I am analyzing a risk model for type 2 diabetes using a logistic regression. 
In the final model I have only 6 predictors. The regression gives correct 
output (fullmod is the fitted model). Now I  try to do cross validation using 
cv.binary. Any help in resolving this problem will be appreciated.
> cv.binary(fullmod)
Error in sample.int(x, size, replace, prob) : invalid 'size' argument
Regards,Amit

[[alternative HTML version deleted]]

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

Re: [R] [FORGED] Re: help with r package "trip"

2016-06-15 Thread Michael Sumner
On Wed, 15 Jun 2016 at 18:51 Rolf Turner  wrote:

> On 15/06/16 20:18, Jim Lemon wrote:
> > Hi Alice,
> > Have you tried creating a vector of the start position (xpos[1],ypos[1]):
> >
> > xstart<-rep(xpos[1],n)
> > ystart<-rep(ypos[1],n)
> > # where "n" is the number of subsequent positions in the trip
> > max(trackDistance(xstart,ystart,xpos[2:n],ypos[2:n],...))
> >
> > may then give you the value of the longest distance from the start. I
> > don't have the trip package or I could see if you really need to
> > replicate the start positions.
>
> Jim:  This seems to me to be somewhat off the point.  The OP was faced
> with the problem of not being able to access the function homedist().
> This function seems *not* to be exported from the trip package, and yet
> it is a *documented* function which I would assume to imply that users
> should be able to invoke it directly.
>
> It is possible that in the past the OP was dealing with a version of the
> trip package that was created before namespaces came into the picture,
> whence "exporting" was not relevant.  I would suggest that the OP
> contact the package maintainer (maintainer("trip") will give you the
> email address) and enquire as to what is going on.
>
>
This is correct, the maintainer of trip never finished the task and so it's
documented but not exported - but also the CRAN version is incorrect so
please don't use it. Apologies for this.


> In the interim, a workaround *might* be to invoke homedist() as
>
>  trip:::homedist()
>

Please don't do this, the current definition is incorrect. I've updated it
here but can't spend much time checking, any direct input to me is welcome
- perhaps via the Issues feature on the GitHub repository.

https://github.com/mdsumner/trip

Again, my apologies for this.

Cheers, Mike.


> Note the *triple* colon in the foregoing.  I am not at all familiar with
> the trip package so my advice should probably be taken with several
> grains of salt.
>
> cheers,
>
> Rolf Turner
>
> --
> Technical Editor ANZJS
> Department of Statistics
> University of Auckland
> Phone: +64-9-373-7599 ext. 88276
>
> > On Wed, Jun 15, 2016 at 1:43 PM, Alice Domalik  wrote:
> >> Hi List,
> >>
> >> I'm relatively new to R, so apologies if my question is rather
> elementary.
> >> I'm working with some bird tracking data and I would like to calculate
> the maximum distance traveled from the colony.
> >> For the maximum distance traveled, I was going to use the function
> homedist(). However, when I try to use this function I get the following
> error:
> >> Error: could not find function "homedist"
> >> Anyone know why I would get this error? I have been using other
> functions in "trip" without an issue. Is there an alternative way I can
> calculate this?
> >>
> >> Thanks in advance for any help!
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
-- 
Dr. Michael Sumner
Software and Database Engineer
Australian Antarctic Division
203 Channel Highway
Kingston Tasmania 7050 Australia

[[alternative HTML version deleted]]

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


[R] Fwd: help for fine mappting

2016-06-15 Thread greg holly
Dear all;


Unfortunately I did not get any response for my  following questions. It is
time sensitive job. I would be greatly appreciate if you give help soon.


Regards,

Greg



I am sorry for this posting. I have got help from Jim, Bert, Jeff and PIKAL
on similar issue before. I tried to modify Jim`s code to the real data but
it did not work. Now I am posting first two rows the imitation of real data
using dput() format (please see at the bottom).  I have two data sets,
data=map and data=ref. The first to rows of each data set are given below.
Data map has more than 27 million and data ref has about 560 rows.
Basically I need run two different tasks. My R codes for these task are
given below but they do not work properly. I sincerely do appreciate your
helps.



Regards,

Greg



Task 1)

For example, the first and second columns for row 1 in data ref are chr1,
6457839 and 6638389. So I need write an R code normally first look the
first row in ref (which they are chre1 6457839  and 6638389) than summing
the column of "map$post_prob" and give the number of map$snp falls between
6457839  and 6638389 that  their cumulative sum is >0.85. Then do the same
for the second, thirdin ref. At the end I would like a table gave below
(need_ouput). Please notice the all value specified info in ref data file
are exist in map$CHR and map$POS columns.



Task2)

Again example, the first and second columns for row 1 in data ref are chr1,
6457839 and 6638389. So I need that R gives me the minimum map$p for the 2
chr1, 6457839 and 6638389 (as there are many snps between these regions and
would like choose the smallest one in those regions. Than do the same for
the second, thirdrows in ref.



Then put the results of Task1 and Task2 into need_ouput file




#R codes modified from Jim


map2<-map[order(map$CHR, map$POS, -map$post_prob),]



# get a field for the counts

 ref$n<-NA



# and a field for the minimum p values

 ref$min_p<-NA



# get the number of rows in "ref"

 nref<-dim(ref)[1]

 for(i in 1:nref) {

  CHR<- which(map2$CHR==ref$CHR[i])

  POS_start<-which(map2$POS==ref$POS_start[i])

  POS_end<-which(map2$POS==ref$POS_end[i])

  cat("CHR", "CHR"," POS_start",POS_start,"POS_end",POS_end,"\n")



# get the range of matches

  POSrange<-range(c(CHR,POS_start,POS_end))



# convert this to a sequence spanning all matches

  allPOS<-POSrange[1]:POSrange[2]

  ref$n[i]<-sum(map2$post_prob[allPOS] > 0.99)

  ref$min_p[i]<-min(map2$p[allPOS])

 }





  dput(map)

  structure(list(CHR = structure(c(1L, 1L), .Label = "chr1", class =
"factor"),

  snp = structure(1:2, .Label = c("rs4747841", "rs4749917"), class
= "factor"),

  Allel1 = structure(1:2, .Label = c("A", "T"), class = "factor"),

  Allel2 = structure(c(2L, 1L), .Label = c("C", "G"), class =
"factor"),

  fr = c(0.551, 0.436), effec = c(-0.0011, 0.0011), SE = c(0.0029,

  0.0029), p = c(0.7, 0.7), POS = c(9960129L, 9960259L), post_prob
= c(1.248817e-158,

  1.248817e-158)), .Names = c("CHR", "snp", "Allel1", "Allel2",

  "fr", "effec", "SE", "p", "POS", "post_prob"), class = "data.frame",
row.names = c(NA,

  -2L))





 dput(ref)

 structure(list(CHR = structure(1:2, .Label = c("chr10", "chr14"

 ), class = "factor"), POS_start = c(6457839L, 21005246L), POS_end =
c(6638389L,

 21550658L)), .Names = c("CHR", "POS_start", "POS_end"), class =
"data.frame", row.names = c(NA,

-2L))





dput(need_output)

structure(list(CHR = structure(1:2, .Label = c("chr1", "chr22"

), class = "factor"), POS = c(312127953L, 46487552L), POS_start =
c(32036927L,

45766451L), POS_end = c(3232240262, 46801601), snp = structure(1:2, .Label
= c("rs1143427",

"rs55958907"), class = "factor"), alle1l = structure(1:2, .Label = c("G",

"T"), class = "factor"), allel2 = structure(1:2, .Label = c("A",

"G"), class = "factor"), fr = c(0.278, 0.974), effec = c(0.6,

0.106), SE = c(0.015, 0.027), P = c(0.000156, 7.63e-05), post_prob =
c(0.229,

0.125), n = c(612L, 4218L)), .Names = c("CHR", "POS", "POS_start",

"POS_end", "snp", "alle1l", "allel2", "fr", "effec", "SE", "P",

"post_prob", "n"), class = "data.frame", row.names = c(NA, -2L

))

[[alternative HTML version deleted]]

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


Re: [R] dplyr's arrange function

2016-06-15 Thread David Winsemius

> On Jun 15, 2016, at 2:08 PM, Muhuri, Pradip (AHRQ/CFACT) 
>  wrote:
> 
> Hello,
> 
> I am using the dplyr's arrange() function to sort  one of the  many data 
> frames  on a character variable (named "prevalence").
> 
> Issue: I am not getting the desired output  (line 7 is the problem, which 
> should be the very last line in the sorted data frame) because the sorted 
> field is character, not numeric. 
> 
> The reproducible example and the output are appended below. 
> 
> Is there any work-around  to convert/treat  this character variable (named 
> "prevalence" in the data frame below)  as numeric before using the arrange() 
> function within the dplyr package?
> 
> Any hints will be appreciated.
> 
> Thanks,
> 
> Pradip Muhuri
> 
> # Reproducible Example 
> 
> library("readr")
> testdata <- read_csv(
> "indicator,  prevalence
> 1. Health check-up, 77.2 (1.19)
> 2. Blood cholesterol checked,  84.5 (1.14)
> 3. Recieved flu vaccine, 50.0 (1.33)
> 4. Blood pressure checked, 88.7 (0.88)
> 5. Aspirin use-problems, 11.7 (1.02)
> 6.Colonoscopy, 60.2 (1.41)
> 7. Sigmoidoscopy,  6.1 (0.61)
> 8. Blood stool test, 14.6 (1.00)
> 9.Mammogram,  72.6 (1.82)
> 10. Pap Smear test, 73.3 (2.37)")
> 
> # Sort on the character variable in descending order
> arrange(testdata, desc(prevalence))
> 
> # Results from Console
> 
>  indicator  prevalence
>  (chr)   (chr)
> 1 4. Blood pressure checked 88.7 (0.88)
> 2  2. Blood cholesterol checked 84.5 (1.14)
> 31. Health check-up 77.2 (1.19)
> 410. Pap Smear test 73.3 (2.37)
> 5   9.Mammogram 72.6 (1.82)
> 6 6.Colonoscopy 60.2 (1.41)
> 7  7. Sigmoidoscopy  6.1 (0.61)
> 8   3. Recieved flu vaccine 50.0 (1.33)
> 9   8. Blood stool test 14.6 (1.00)
> 10  5. Aspirin use-problems 11.7 (1.02)

Despite the fact that the prevalence columns is not really the  mixed 
numeric/alpha , it still can be sorted quite easily with the very handy 
gtools::mixedorder function:

> > require(gtools)
> Loading required package: gtools
> > testdata[ mixedorder(testdata$prevalence), ]
>   indicator  prevalence
> 7  7. Sigmoidoscopy  6.1 (0.61)
> 5   5. Aspirin use-problems 11.7 (1.02)
> 8   8. Blood stool test 14.6 (1.00)
> 3   3. Recieved flu vaccine 50.0 (1.33)
> 6 6.Colonoscopy 60.2 (1.41)
> 9   9.Mammogram 72.6 (1.82)
> 10   10. Pap Smear test 73.3 (2.37)
> 11. Health check-up 77.2 (1.19)
> 2  2. Blood cholesterol checked 84.5 (1.14)
> 4 4. Blood pressure checked 88.7 (0.88)

The mixedorder function splits the strings at the space boundaries and tests 
for numeric or alpha.

> 
> 
> Pradip K. Muhuri,  AHRQ/CFACT
> 5600 Fishers Lane # 7N142A, Rockville, MD 20857
> Tel: 301-427-1564
> 

-- 

David Winsemius
Alameda, CA, USA

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


Re: [R] dplyr's arrange function

2016-06-15 Thread Jim Lemon
Hi Pradip,
I'll assume that you are reading the data from a file:

pm.df<-read.csv("pmdat.txt",stringsAsFactors=FALSE)
# create a vector of numeric values of prevalence
numprev<-as.numeric(sapply(strsplit(trimws(pm.df$prevalence)," "),"[",1))
# order the data frame by that vector
pm.df[order(numprev),]

Jim


On Thu, Jun 16, 2016 at 7:08 AM, Muhuri, Pradip (AHRQ/CFACT)
 wrote:
> Hello,
>
> I am using the dplyr's arrange() function to sort  one of the  many data 
> frames  on a character variable (named "prevalence").
>
> Issue: I am not getting the desired output  (line 7 is the problem, which 
> should be the very last line in the sorted data frame) because the sorted 
> field is character, not numeric.
>
> The reproducible example and the output are appended below.
>
> Is there any work-around  to convert/treat  this character variable (named 
> "prevalence" in the data frame below)  as numeric before using the arrange() 
> function within the dplyr package?
>
> Any hints will be appreciated.
>
> Thanks,
>
> Pradip Muhuri
>
> # Reproducible Example
>
> library("readr")
> testdata <- read_csv(
> "indicator,  prevalence
> 1. Health check-up, 77.2 (1.19)
> 2. Blood cholesterol checked,  84.5 (1.14)
> 3. Recieved flu vaccine, 50.0 (1.33)
> 4. Blood pressure checked, 88.7 (0.88)
> 5. Aspirin use-problems, 11.7 (1.02)
> 6.Colonoscopy, 60.2 (1.41)
> 7. Sigmoidoscopy,  6.1 (0.61)
> 8. Blood stool test, 14.6 (1.00)
> 9.Mammogram,  72.6 (1.82)
> 10. Pap Smear test, 73.3 (2.37)")
>
> # Sort on the character variable in descending order
> arrange(testdata, desc(prevalence))
>
> # Results from Console
>
>   indicator  prevalence
>   (chr)   (chr)
> 1 4. Blood pressure checked 88.7 (0.88)
> 2  2. Blood cholesterol checked 84.5 (1.14)
> 31. Health check-up 77.2 (1.19)
> 410. Pap Smear test 73.3 (2.37)
> 5   9.Mammogram 72.6 (1.82)
> 6 6.Colonoscopy 60.2 (1.41)
> 7  7. Sigmoidoscopy  6.1 (0.61)
> 8   3. Recieved flu vaccine 50.0 (1.33)
> 9   8. Blood stool test 14.6 (1.00)
> 10  5. Aspirin use-problems 11.7 (1.02)
>
>
> Pradip K. Muhuri,  AHRQ/CFACT
>  5600 Fishers Lane # 7N142A, Rockville, MD 20857
> Tel: 301-427-1564
>
>
>
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

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


Re: [R] benchmark-dea

2016-06-15 Thread Jim Lemon
Hi farzana,
Probably the first thing is to ascertain what the class of "farzana" might be:

class(farzana)

Because "write.csv" expects "the object to be written, preferably a
matrix or data frame. If not, it is attempted to coerce x to a data
frame." to be the first argument. It seems that "farzana" is neither a
matrix nor a data frame and something for which there is no method to
convert it to one.

The second thing to do is to try to work out what is inside "farzana":

str(farzana)

This will produce a summary of what is in there. _Maybe_ with that
summary you can figure out how to convert it into a data frame. If
not, you can always save the object:

save(farzana,file="farzana.Rdata")

and reload it later.

Jiim


On Thu, Jun 16, 2016 at 5:47 AM, farzana akbari
 wrote:
> in the name of God
>
>
> hi dear
>
> I  use benchmark package to use of dea  and when I wanna save my result
> as csv by this as below
>  write.csv(farzana,'D:sajjaad.csv')
>
> I can not and the error is as below
>
>
> Error in as.data.frame.default(x[[i]], optional = TRUE, stringsAsFactors =
> stringsAsFactors) :
>   cannot coerce class ""Farrell"" to a data.frame
>
>
> what should I do ?
>
>
> best regards
> farzana
>
> [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

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


Re: [R] dplyr's arrange function

2016-06-15 Thread Daniel Nordlund

On 6/15/2016 2:08 PM, Muhuri, Pradip (AHRQ/CFACT) wrote:

Hello,

I am using the dplyr's arrange() function to sort  one of the  many data frames  on a 
character variable (named "prevalence").

Issue: I am not getting the desired output  (line 7 is the problem, which 
should be the very last line in the sorted data frame) because the sorted field 
is character, not numeric.

The reproducible example and the output are appended below.

Is there any work-around  to convert/treat  this character variable (named 
"prevalence" in the data frame below)  as numeric before using the arrange() 
function within the dplyr package?

Any hints will be appreciated.

Thanks,

Pradip Muhuri

# Reproducible Example

library("readr")
testdata <- read_csv(
"indicator,  prevalence
1. Health check-up, 77.2 (1.19)
2. Blood cholesterol checked,  84.5 (1.14)
3. Recieved flu vaccine, 50.0 (1.33)
4. Blood pressure checked, 88.7 (0.88)
5. Aspirin use-problems, 11.7 (1.02)
6.Colonoscopy, 60.2 (1.41)
7. Sigmoidoscopy,  6.1 (0.61)
8. Blood stool test, 14.6 (1.00)
9.Mammogram,  72.6 (1.82)
10. Pap Smear test, 73.3 (2.37)")

# Sort on the character variable in descending order
arrange(testdata, desc(prevalence))

# Results from Console

  indicator  prevalence
  (chr)   (chr)
1 4. Blood pressure checked 88.7 (0.88)
2  2. Blood cholesterol checked 84.5 (1.14)
31. Health check-up 77.2 (1.19)
410. Pap Smear test 73.3 (2.37)
5   9.Mammogram 72.6 (1.82)
6 6.Colonoscopy 60.2 (1.41)
7  7. Sigmoidoscopy  6.1 (0.61)
8   3. Recieved flu vaccine 50.0 (1.33)
9   8. Blood stool test 14.6 (1.00)
10  5. Aspirin use-problems 11.7 (1.02)


Pradip K. Muhuri,  AHRQ/CFACT
 5600 Fishers Lane # 7N142A, Rockville, MD 20857
Tel: 301-427-1564





The problem is that you are sorting a character variable.


testdata$prevalence

 [1] "77.2 (1.19)" "84.5 (1.14)" "50.0 (1.33)" "88.7 (0.88)" "11.7 (1.02)"
 [6] "60.2 (1.41)" "6.1 (0.61)"  "14.6 (1.00)" "72.6 (1.82)" "73.3 (2.37)"




Notice that the 7th element is "6.1 (0.61)".  The first CHARACTER is a 
"6", so it is going to sort BEFORE the "50.0 (1.33)" (in descending 
order).  If you want the character value of line 7 to sort last, it 
would need to be "06.1 (0.61)" or " 6.1 (0.61)" (notice the leading space).


Hope this is helpful,

Dan

Daniel Nordlund
Port Townsend, WA USA

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


[R] cv.glm problem

2016-06-15 Thread Amit Sengupta via R-help
HI,I am analyzing a risk model for type 2 diabetes using a logistic regression. 
In the final model I have only 6 predictors. The regression gives correct 
output (fullmod is the fitted model). Now I have a subset of dataset (mydata1) 
with 7 variables (1 response(0/1) + 6 predictors) and try to do cross 
validation using cv.glm. The dataset mydata1 has 1410 rows and no NA entry. 
This is the problem I run into (It does not matter what K I choose). Any help 
in this matter will be appreciated.
> cv.glm(mydata1,fullmod,K=6)
Error in if ((K > n) || (K <= 1)) stop("'K' outside allowable range") : 
  missing value where TRUE/FALSE needed
Regards,Amit

[[alternative HTML version deleted]]

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

[R] dplyr's arrange function

2016-06-15 Thread Muhuri, Pradip (AHRQ/CFACT)
Hello,

I am using the dplyr's arrange() function to sort  one of the  many data frames 
 on a character variable (named "prevalence").

Issue: I am not getting the desired output  (line 7 is the problem, which 
should be the very last line in the sorted data frame) because the sorted field 
is character, not numeric. 

The reproducible example and the output are appended below. 

Is there any work-around  to convert/treat  this character variable (named 
"prevalence" in the data frame below)  as numeric before using the arrange() 
function within the dplyr package?

Any hints will be appreciated.

Thanks,

Pradip Muhuri

# Reproducible Example 

library("readr")
testdata <- read_csv(
"indicator,  prevalence
1. Health check-up, 77.2 (1.19)
2. Blood cholesterol checked,  84.5 (1.14)
3. Recieved flu vaccine, 50.0 (1.33)
4. Blood pressure checked, 88.7 (0.88)
5. Aspirin use-problems, 11.7 (1.02)
6.Colonoscopy, 60.2 (1.41)
7. Sigmoidoscopy,  6.1 (0.61)
8. Blood stool test, 14.6 (1.00)
9.Mammogram,  72.6 (1.82)
10. Pap Smear test, 73.3 (2.37)")

# Sort on the character variable in descending order
arrange(testdata, desc(prevalence))

# Results from Console

  indicator  prevalence
  (chr)   (chr)
1 4. Blood pressure checked 88.7 (0.88)
2  2. Blood cholesterol checked 84.5 (1.14)
31. Health check-up 77.2 (1.19)
410. Pap Smear test 73.3 (2.37)
5   9.Mammogram 72.6 (1.82)
6 6.Colonoscopy 60.2 (1.41)
7  7. Sigmoidoscopy  6.1 (0.61)
8   3. Recieved flu vaccine 50.0 (1.33)
9   8. Blood stool test 14.6 (1.00)
10  5. Aspirin use-problems 11.7 (1.02)


Pradip K. Muhuri,  AHRQ/CFACT
 5600 Fishers Lane # 7N142A, Rockville, MD 20857
Tel: 301-427-1564


 

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


Re: [R] Writing R package that call Fortran codes

2016-06-15 Thread Eduardo M. A. M.Mendes
Hi

Have you tried to load and run the fortran code using just a wrapper function 
in R?   I do that as the first step in order to build a package.  

Example:   fortran sources -> rk4_mod_r.f90 ,derive_henonheilles.f90, 
poincare_section.f90

a) I use R CMD SHLIB rk4_mod_r.f90 ,derive_henonheilles.f90, 
poincare_section.f90 - o poincare_section_henonheilles_rk4.so 
b) Then I write a wrapper function in R, poinc_section_henonheilles.R
...
 dyn.load("poincare_section_henonheilles_rk4.so")
  
  out<-.Fortran("section_crossing",
h=as.numeric(h),
nphas=as.integer(nphas),..
...
c) and call the function as usual.

Please note that the function called by .Fortran is the name of the subroutine 
within poincare_section.f90 and not the filename.

I take the opportunity to thank R-developers for making the calling of C and 
Fortran in R very easy.   

I hope this helps.

regards

Ed

PS.  If you need an example of a package using Fortran90, please check 
https://github.com/emammendes/mittagleffler 




> On Jun 15, 2016, at 5:20 PM, Kodalore Vijayan, Vineetha W  
> wrote:
> 
> Hi,
> 
> I'm trying to write an R package that calls a Fortran subroutine on my  Mac
> os x El Capitan with Xcode 7 and gfortran 6.1, R 3.3.0.   I can build and
> load the library but when I try to use it in R I get this error:
>> library(NEpidemic)
>> random_epi(variable_names)
> 
> Error in .Fortran("random_epi", : "random_pi" not resolved from current
> namespace (NEpidemic).
> 
> Then I  tried adding useDynLib(random_epi.f95) in the NAMESPACE file,
> additional to useDynLib(NEpidemic). After doing that I couldn't build the
> package and it gave me another error:
> 
> Error in library.dynam(lib, package, package.lib) :
>  shared object ‘random_epi.so’ not found
> Error: loading failed
> Execution halted
> ERROR: loading failed
> 
> When I checked my src folder, there is only random_epi.o file.  How can I
> fix this issue? Any help would be much appreciated. I'm vey new to both R
> and Fortran coding, especially in package building.
> 
> Thanks in advance!
> Vineetha
> 
>   [[alternative HTML version deleted]]
> 
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.


[[alternative HTML version deleted]]

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

Re: [R] Closing FTP sessions with RCurl

2016-06-15 Thread William Dunlap via R-help
>With the call to gc(), the garbage collector will be called some time in
the
>future and the finalizers will be run then.

Typo: that initial 'With' should be 'Without'.


Bill Dunlap
TIBCO Software
wdunlap tibco.com

On Wed, Jun 15, 2016 at 12:57 PM, William Dunlap  wrote:

> >>rm(curl) # release the curl! (does this end the session???)
>
> Try adding a call to gc() immediately after this removal.  That will force
> an
> immediate run of any finalizer associated with the object just removed.
> With the call to gc(), the garbage collector will be called some time in
> the
> future and the finalizers will be run then.
>
> (I don't know if curl has a finalizer that closes the session.)
>
>
> Bill Dunlap
> TIBCO Software
> wdunlap tibco.com
>
> On Wed, Jun 15, 2016 at 12:34 PM, J Payne  wrote:
>
>> Thanks Tom!  I tried that and it didn’t work, but perhaps there are other
>> problems.  The system administrator wrote “I think closing sessions
>> immediately upon completion of the transfer,
>> or continuing to use the same session for additional requests would both
>> have a similar and positive effect.”  However, I’ve now tried your solution
>> to close the session, and also tried using one curl handle throughout, but
>> the throttling persists.
>>
>> John
>>
>> On 6/14/16, 1:00 PM, "Tom Wright"  wrote:
>>
>> >No expert here, and this isn't tested. It seems you can set the
>> >forbid.reuse option which will cause curl to shutdown the connection
>> >after transfer is complete.
>> >
>> >if(url.exists("http://www.omegahat.net/RCurl/index.html;)) {
>> >   curl <- getCurlHandle()
>> >   curlSetOpt(.opts=list(forbid.reuse=1),curl=curl)
>> >   getURL("http://www.omegahat.net/RCurl/index.html;, curl = curl)
>> >}
>> >
>> >On Tue, Jun 14, 2016 at 2:41 PM, J Payne  wrote:
>> >> Does anyone know how to close an FTP session with RCurl?  I am trying
>> to automate the process of downloading snow data from a government website,
>> and their server is throttling the connection after a few files are
>> downloaded.  I contacted their system administrator, who wrote: “My
>> suspicion at this point is that the getURL commands are opened and perform
>> the function asked, then linger in wait for 15 minutes until or ftp server
>> closes the idle sessions. Is there a way to tell R to close the sessions?”
>> >>
>> >>
>> >>
>> >> I’ve perused the RCurl manual but I don’t see a way to close
>> sessions.  I tried copying the following example from the RCurl manual, but
>> it didn’t solve the problem.  I’m a novice at this and I don’t understand
>> the relationship between handles and sessions, so I am probably missing
>> something.
>> >>
>> >>
>> >>
>> >> #EXAMPLE from getCurl(), p. 39
>> >>
>> >> if(url.exists("http://www.omegahat.net/RCurl/index.html;)) {
>> >>
>> >>curl = getCurlHandle()
>> >>
>> >>getURL("http://www.omegahat.net/RCurl/index.html;, curl = curl)
>> >>
>> >>#getCurlInfo(curl) # I skipped this step
>> >>
>> >>rm(curl) # release the curl! (does this end the session???)
>> >>
>> >> }
>> >>
>> >>
>> >>
>> >> Thanks!
>> >>
>> >>
>> >>
>> >> John
>> >>
>> >>
>> >> [[alternative HTML version deleted]]
>> >>
>> >> __
>> >> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>> >> https://stat.ethz.ch/mailman/listinfo/r-help
>> >> PLEASE do read the posting guide
>> http://www.R-project.org/posting-guide.html
>> >> and provide commented, minimal, self-contained, reproducible code.
>>
>> __
>> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide
>> http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>
>
>

[[alternative HTML version deleted]]

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

Re: [R] Closing FTP sessions with RCurl

2016-06-15 Thread J Payne
Fantastic!  That did the trick.  I still suspect that there may be a command 
within RCurl that accomplishes the same thing, but in any case I’m very 
grateful to have a solution that works.  

 

Best,

 

John

 

From: William Dunlap 
Date: Wednesday, June 15, 2016 at 12:57 PM
To: J Payne 
Cc: Tom Wright , R help list 
Subject: Re: [R] Closing FTP sessions with RCurl

 

>>rm(curl) # release the curl! (does this end the session???)

 

Try adding a call to gc() immediately after this removal.  That will force an

immediate run of any finalizer associated with the object just removed.

With the call to gc(), the garbage collector will be called some time in the

future and the finalizers will be run then.

 

(I don't know if curl has a finalizer that closes the session.)

 


Bill Dunlap
TIBCO Software
wdunlap tibco.com

 

On Wed, Jun 15, 2016 at 12:34 PM, J Payne  wrote:

Thanks Tom!  I tried that and it didn’t work, but perhaps there are other 
problems.  The system administrator wrote “I think closing sessions immediately 
upon completion of the transfer,
or continuing to use the same session for additional requests would both have a 
similar and positive effect.”  However, I’ve now tried your solution to close 
the session, and also tried using one curl handle throughout, but the 
throttling persists.

John

On 6/14/16, 1:00 PM, "Tom Wright"  wrote:

>No expert here, and this isn't tested. It seems you can set the
>forbid.reuse option which will cause curl to shutdown the connection
>after transfer is complete.
>
>if(url.exists("http://www.omegahat.net/RCurl/index.html;)) {
>   curl <- getCurlHandle()
>   curlSetOpt(.opts=list(forbid.reuse=1),curl=curl)
>   getURL("http://www.omegahat.net/RCurl/index.html;, curl = curl)
>}
>
>On Tue, Jun 14, 2016 at 2:41 PM, J Payne  wrote:
>> Does anyone know how to close an FTP session with RCurl?  I am trying to 
>> automate the process of downloading snow data from a government website, and 
>> their server is throttling the connection after a few files are downloaded.  
>> I contacted their system administrator, who wrote: “My suspicion at this 
>> point is that the getURL commands are opened and perform the function asked, 
>> then linger in wait for 15 minutes until or ftp server closes the idle 
>> sessions. Is there a way to tell R to close the sessions?”
>>
>>
>>
>> I’ve perused the RCurl manual but I don’t see a way to close sessions.  I 
>> tried copying the following example from the RCurl manual, but it didn’t 
>> solve the problem.  I’m a novice at this and I don’t understand the 
>> relationship between handles and sessions, so I am probably missing 
>> something.
>>
>>
>>
>> #EXAMPLE from getCurl(), p. 39
>>
>> if(url.exists("http://www.omegahat.net/RCurl/index.html;)) {
>>
>>curl = getCurlHandle()
>>
>>getURL("http://www.omegahat.net/RCurl/index.html;, curl = curl)
>>
>>#getCurlInfo(curl) # I skipped this step
>>
>>rm(curl) # release the curl! (does this end the session???)
>>
>> }
>>
>>
>>
>> Thanks!
>>
>>
>>
>> John
>>
>>
>> [[alternative HTML version deleted]]
>>
>> __
>> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.

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




[[alternative HTML version deleted]]

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

[R] Writing R package that call Fortran codes

2016-06-15 Thread Kodalore Vijayan, Vineetha W
Hi,

I'm trying to write an R package that calls a Fortran subroutine on my  Mac
os x El Capitan with Xcode 7 and gfortran 6.1, R 3.3.0.   I can build and
load the library but when I try to use it in R I get this error:
>library(NEpidemic)
>random_epi(variable_names)

Error in .Fortran("random_epi", : "random_pi" not resolved from current
namespace (NEpidemic).

Then I  tried adding useDynLib(random_epi.f95) in the NAMESPACE file,
additional to useDynLib(NEpidemic). After doing that I couldn't build the
package and it gave me another error:

Error in library.dynam(lib, package, package.lib) :
  shared object ‘random_epi.so’ not found
Error: loading failed
Execution halted
ERROR: loading failed

When I checked my src folder, there is only random_epi.o file.  How can I
fix this issue? Any help would be much appreciated. I'm vey new to both R
and Fortran coding, especially in package building.

Thanks in advance!
Vineetha

[[alternative HTML version deleted]]

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

Re: [R] Closing FTP sessions with RCurl

2016-06-15 Thread William Dunlap via R-help
>>rm(curl) # release the curl! (does this end the session???)

Try adding a call to gc() immediately after this removal.  That will force
an
immediate run of any finalizer associated with the object just removed.
With the call to gc(), the garbage collector will be called some time in the
future and the finalizers will be run then.

(I don't know if curl has a finalizer that closes the session.)


Bill Dunlap
TIBCO Software
wdunlap tibco.com

On Wed, Jun 15, 2016 at 12:34 PM, J Payne  wrote:

> Thanks Tom!  I tried that and it didn’t work, but perhaps there are other
> problems.  The system administrator wrote “I think closing sessions
> immediately upon completion of the transfer,
> or continuing to use the same session for additional requests would both
> have a similar and positive effect.”  However, I’ve now tried your solution
> to close the session, and also tried using one curl handle throughout, but
> the throttling persists.
>
> John
>
> On 6/14/16, 1:00 PM, "Tom Wright"  wrote:
>
> >No expert here, and this isn't tested. It seems you can set the
> >forbid.reuse option which will cause curl to shutdown the connection
> >after transfer is complete.
> >
> >if(url.exists("http://www.omegahat.net/RCurl/index.html;)) {
> >   curl <- getCurlHandle()
> >   curlSetOpt(.opts=list(forbid.reuse=1),curl=curl)
> >   getURL("http://www.omegahat.net/RCurl/index.html;, curl = curl)
> >}
> >
> >On Tue, Jun 14, 2016 at 2:41 PM, J Payne  wrote:
> >> Does anyone know how to close an FTP session with RCurl?  I am trying
> to automate the process of downloading snow data from a government website,
> and their server is throttling the connection after a few files are
> downloaded.  I contacted their system administrator, who wrote: “My
> suspicion at this point is that the getURL commands are opened and perform
> the function asked, then linger in wait for 15 minutes until or ftp server
> closes the idle sessions. Is there a way to tell R to close the sessions?”
> >>
> >>
> >>
> >> I’ve perused the RCurl manual but I don’t see a way to close sessions.
> I tried copying the following example from the RCurl manual, but it didn’t
> solve the problem.  I’m a novice at this and I don’t understand the
> relationship between handles and sessions, so I am probably missing
> something.
> >>
> >>
> >>
> >> #EXAMPLE from getCurl(), p. 39
> >>
> >> if(url.exists("http://www.omegahat.net/RCurl/index.html;)) {
> >>
> >>curl = getCurlHandle()
> >>
> >>getURL("http://www.omegahat.net/RCurl/index.html;, curl = curl)
> >>
> >>#getCurlInfo(curl) # I skipped this step
> >>
> >>rm(curl) # release the curl! (does this end the session???)
> >>
> >> }
> >>
> >>
> >>
> >> Thanks!
> >>
> >>
> >>
> >> John
> >>
> >>
> >> [[alternative HTML version deleted]]
> >>
> >> __
> >> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> >> https://stat.ethz.ch/mailman/listinfo/r-help
> >> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> >> and provide commented, minimal, self-contained, reproducible code.
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

[[alternative HTML version deleted]]

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

[R] benchmark-dea

2016-06-15 Thread farzana akbari
in the name of God


hi dear

I  use benchmark package to use of dea  and when I wanna save my result
as csv by this as below
 write.csv(farzana,'D:sajjaad.csv')

I can not and the error is as below


Error in as.data.frame.default(x[[i]], optional = TRUE, stringsAsFactors =
stringsAsFactors) :
  cannot coerce class ""Farrell"" to a data.frame


what should I do ?


best regards
farzana

[[alternative HTML version deleted]]

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


Re: [R] Closing FTP sessions with RCurl

2016-06-15 Thread J Payne
Thanks Tom!  I tried that and it didn’t work, but perhaps there are other 
problems.  The system administrator wrote “I think closing sessions immediately 
upon completion of the transfer,
or continuing to use the same session for additional requests would both have a 
similar and positive effect.”  However, I’ve now tried your solution to close 
the session, and also tried using one curl handle throughout, but the 
throttling persists.  

John

On 6/14/16, 1:00 PM, "Tom Wright"  wrote:

>No expert here, and this isn't tested. It seems you can set the
>forbid.reuse option which will cause curl to shutdown the connection
>after transfer is complete.
>
>if(url.exists("http://www.omegahat.net/RCurl/index.html;)) {
>   curl <- getCurlHandle()
>   curlSetOpt(.opts=list(forbid.reuse=1),curl=curl)
>   getURL("http://www.omegahat.net/RCurl/index.html;, curl = curl)
>}
>
>On Tue, Jun 14, 2016 at 2:41 PM, J Payne  wrote:
>> Does anyone know how to close an FTP session with RCurl?  I am trying to 
>> automate the process of downloading snow data from a government website, and 
>> their server is throttling the connection after a few files are downloaded.  
>> I contacted their system administrator, who wrote: “My suspicion at this 
>> point is that the getURL commands are opened and perform the function asked, 
>> then linger in wait for 15 minutes until or ftp server closes the idle 
>> sessions. Is there a way to tell R to close the sessions?”
>>
>>
>>
>> I’ve perused the RCurl manual but I don’t see a way to close sessions.  I 
>> tried copying the following example from the RCurl manual, but it didn’t 
>> solve the problem.  I’m a novice at this and I don’t understand the 
>> relationship between handles and sessions, so I am probably missing 
>> something.
>>
>>
>>
>> #EXAMPLE from getCurl(), p. 39
>>
>> if(url.exists("http://www.omegahat.net/RCurl/index.html;)) {
>>
>>curl = getCurlHandle()
>>
>>getURL("http://www.omegahat.net/RCurl/index.html;, curl = curl)
>>
>>#getCurlInfo(curl) # I skipped this step
>>
>>rm(curl) # release the curl! (does this end the session???)
>>
>> }
>>
>>
>>
>> Thanks!
>>
>>
>>
>> John
>>
>>
>> [[alternative HTML version deleted]]
>>
>> __
>> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.

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

Re: [R-es] Hadoop

2016-06-15 Thread Carlos Ortega
Hola,

Te recomendaría lo siguiente:


   - Montar un RSpark en AWS:
  - http://amunategui.github.io/sparkr/index.html
   - Y también, no descartaría el que consideraras montar un H2O, también
   sobre AWS:
  - http://amunategui.github.io/h2o-on-aws/index.html

En ambos casos, en estas entradas están las capturas de pantalla y vínculos
a los videos que están disponibles en YouTube. Y si no están puedes
apuntarte a Udemy y comprar los cursos/videos. En su blog aparecen cupones
de descuento con los que podrás tener los cursos muy baratos.

Y además de esto ya hay libros que tratan el tema (para R con Hadoop):

https://www.packtpub.com/big-data-and-business-intelligence/big-data-analytics-r-and-hadoop

En cuanto a lo de H2O, la web de H2O tiene múltiples ayudas, documentos y
guías para su instalación.

Saludos,
Carlos Ortega
www.qualityexcellence.es

El 15 de junio de 2016, 11:05, Javier Villacampa González <
javier.villacampa.gonza...@gmail.com> escribió:

> Hola buenas,
>
> me preguntaba si alguno usa hadoop Spark en su día día y si me podíais
> recomendar un buen curso para empezar. Estuve en la charla de meetup de
> madrid hace unos meses de Rspark y estuvo bien, ahora me preguntaba si es
> posible profundizar.
>
> Pero me gustaría tener recomendaciones de cualquier material que podáis
> recomendar, cursos de coursera que hayais hecho, libros que hayais leido,
> charlas de youtube que hayais visto. Los objetivo son:
>
>1. que sea simple,  un poco para tontitos y si puede ser que usen R por
>no meterme con una cosa más.
>2. que lo hayáis mirado, la red esta llena de cosas de estas me gustaría
>que me dieses opinión. Estoy intentando hacer alguno a ciegas pero no
> es la
>mejor opción
>3. que sea simple y con R
>
>
> Gracias por adelantado.
>
> --
>
> [[alternative HTML version deleted]]
>
> ___
> R-help-es mailing list
> R-help-es@r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-help-es
>



-- 
Saludos,
Carlos Ortega
www.qualityexcellence.es

[[alternative HTML version deleted]]

___
R-help-es mailing list
R-help-es@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-help-es


Re: [R-es] Levantar archivos de Qlikview (.qvd) en R

2016-06-15 Thread Javier Marcuzzi
Estimado Mauricio Monsalvo

Nunca usé qlikview, de curioso por su correo encontré lo siguiente:

http://qlikviewapuntes.blogspot.com.ar/2015/03/qlikview-r-para-kmeans.html

Javier Rubén Marcuzzi

De: Mauricio Monsalvo
Enviado: miércoles, 15 de junio de 2016 15:19
Para: r-help-es
Asunto: [R-es] Levantar archivos de Qlikview (.qvd) en R

Hola.
Sabiendo que la primera respuesta sería "evitar el paso por Qlikview y usar
directamente el R" y siendo que esto no es posible en esta situación
particular que enfrento, consulto:
¿Conocen un paquete que me permita acceder al contenido (conectar) o
directamente levantar con R archivos en formato .qvd o, en general, acceder
a la BD nativa que crea el Qlikview como en el caso SQL con RODBC?
Muchas gracias.
-- 
Mauricio

[[alternative HTML version deleted]]

___
R-help-es mailing list
R-help-es@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-help-es


[[alternative HTML version deleted]]

___
R-help-es mailing list
R-help-es@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-help-es


Re: [R] Find mean of values in three-dimensional array

2016-06-15 Thread Dénes Tóth



On 06/15/2016 09:05 PM, peter dalgaard wrote:
>
>> On 15 Jun 2016, at 19:37 , Nick Tulli  wrote:
>>
>> Hey R-Help,
>>
>> I've got a three dimensional array which I pulled from a netcdf file.
>> The data in array are the humidity values of locations in the United
>> States over a time period. The three dimensions are [longitude,
>> latitude, days], 141x81x92. My goal is to find the mean value at each
>> longitude/latitude over the 92 day period.
>>
>> I could probably accomplish my goal by running a loop, but I'm sure
>> that there is a much easier and more efficient way to accomplish the
>> goal in R. Any suggestions?
>
> Dunno about fast, but the canonical way is apply(A, c(1,2), mean)

For "mean" and "sum", row/colMeans() is pretty fast and efficient. Note 
the 'dims' argument; you might also consider the aperm() function before 
the aggregation.


E.g.:

# create an array
x <- provideDimnames(array(rnorm(141*81*92), c(141, 81, 92)))
names(dimnames(x)) <- c("long", "lat", "days")

# collapse over days
str(rowMeans(x, dims = 2))

# collapse over lat
x_new <- aperm(x, c("lat", "long", "days"))
str(colMeans(x_new))

Cheers,
Denes


>
> E.g.
>
> (A <- array(1:24,c(2,3,4)))
> apply(A, c(1,2), mean)
> apply(A, c(1,3), mean)
>
> -pd
>
>>
>>
>> Thanks guys.
>>
>> __
>> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide 
http://www.R-project.org/posting-guide.html

>> and provide commented, minimal, self-contained, reproducible code.
>

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


Re: [R] Find mean of values in three-dimensional array

2016-06-15 Thread peter dalgaard

> On 15 Jun 2016, at 19:37 , Nick Tulli  wrote:
> 
> Hey R-Help,
> 
> I've got a three dimensional array which I pulled from a netcdf file.
> The data in array are the humidity values of locations in the United
> States over a time period. The three dimensions are [longitude,
> latitude, days], 141x81x92. My goal is to find the mean value at each
> longitude/latitude over the 92 day period.
> 
> I could probably accomplish my goal by running a loop, but I'm sure
> that there is a much easier and more efficient way to accomplish the
> goal in R. Any suggestions?

Dunno about fast, but the canonical way is apply(A, c(1,2), mean)

E.g.

(A <- array(1:24,c(2,3,4)))
apply(A, c(1,2), mean)
apply(A, c(1,3), mean)

-pd

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

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

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


[R] Find mean of values in three-dimensional array

2016-06-15 Thread Nick Tulli
Hey R-Help,

I've got a three dimensional array which I pulled from a netcdf file.
The data in array are the humidity values of locations in the United
States over a time period. The three dimensions are [longitude,
latitude, days], 141x81x92. My goal is to find the mean value at each
longitude/latitude over the 92 day period.

I could probably accomplish my goal by running a loop, but I'm sure
that there is a much easier and more efficient way to accomplish the
goal in R. Any suggestions?


Thanks guys.

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


Re: [R] is there a package in R or functions to calculate odds/hasard ratio from spline regression

2016-06-15 Thread takiy berrandou
Hello,
thank you for the answer. it's true i was'nt clear enough.
the problem with glm()/gam or coxph() when the spline terms are used
(specialy spline of 3rd degree) the calculated coefficients for the spline
terms are difficult to interpret. for example for spline of degree=3 and 3
knots, there are 7 beta's calculated, and to represent the result clearly
we need to calculate OR/HR against a reference. just making exp(beta)
does'nt have a propre meaning.
On SAS there are some MACRO's like %regspline which help to make some
calcul to figure out the OR's.

Thank's again for the answers




2016-06-15 17:56 GMT+02:00 David Winsemius :

>
> > On Jun 14, 2016, at 7:43 AM, takiy berrandou 
> wrote:
> >
> > Hello,
> >
> > I'm looking for a package or function, which calculate OR/HR from spline
> > model regression. for example in SAS it exist some MACRO helping to do
> that
> > easiely.
> >
> > i had make some research on the forum here and on the web but without any
> > succes.
> >
>
> It's not yet clear what  you want to do. Odds ratios are easily calculated
> from logistic regression models (typically constructed with the glm
> function the stats package) and hazard ratios are easily calculated from
> survival models (typically constructed with survreg or coxph in the
> survival package). All those functions accept spline terms in their formula
> versions. There are many worked examples that could be found with google
> searching since google now properly interprets the letter "r" as referring
> to the computer language. You can get a more focussed search using
> rseek.com.
>
>
>
> >
> >   [[alternative HTML version deleted]]
>
> You should read the posting guide. Rhelp is a plain text mailing list.
>
> >
> > __
> > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> > and provide commented, minimal, self-contained, reproducible code.
>
> David Winsemius
> Alameda, CA, USA
>
>


-- 
Takiy BERRANDOU
0618916037
takiyedd...@gmail.com

[[alternative HTML version deleted]]

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


Re: [R] is there a package in R or functions to calculate odds/hasard ratio from spline regression

2016-06-15 Thread David Winsemius

> On Jun 15, 2016, at 9:12 AM, takiy berrandou  wrote:
> 
> Hello,
> thank you for the answer. it's true i was'nt clear enough. 
> the problem with glm()/gam or coxph() when the spline terms are used 
> (specialy spline of 3rd degree) the calculated coefficients for the spline 
> terms are difficult to interpret.

Not just difficult, but also generally unwise to attempt interpretation of 
individual spline coefficients. 

> for example for spline of degree=3 and 3 knots, there are 7 beta's 
> calculated, and to represent the result clearly we need to calculate OR/HR 
> against a reference.

Natural splines are third degree, although generally the number of knots is 1 
less than the degree of the polynomial.

> just making exp(beta) does'nt have a propre meaning.
> On SAS there are some MACRO's like %regspline which help to make some calcul 
> to figure out the OR's.
> 

The predict.* functions will generally handle that difficulty naturally. Each 
of hte regression functions will have a specific `predict` method for the class 
of model object. You simply provide the values for the covariates in a 
dataframe and a prediction for for total of associated terms will be returned. 
See:

?predict.glm

Std errors are generally available if the proper parameters are offered to the 
function. This procedure should be exemplified in the help documents and 
vignettes of the packages with whatever regression function you anticipate 
using. On the Rhelp mailing list you are requested to present questions with 
sufficient code to support a coding response.

-- 
David


> Thank's again for the answers
> 
> 
> 
> 
> 2016-06-15 17:56 GMT+02:00 David Winsemius :
> 
> > On Jun 14, 2016, at 7:43 AM, takiy berrandou  wrote:
> >
> > Hello,
> >
> > I'm looking for a package or function, which calculate OR/HR from spline
> > model regression. for example in SAS it exist some MACRO helping to do that
> > easiely.
> >
> > i had make some research on the forum here and on the web but without any
> > succes.
> >
> 
> It's not yet clear what  you want to do. Odds ratios are easily calculated 
> from logistic regression models (typically constructed with the glm function 
> the stats package) and hazard ratios are easily calculated from survival 
> models (typically constructed with survreg or coxph in the survival package). 
> All those functions accept spline terms in their formula versions. There are 
> many worked examples that could be found with google searching since google 
> now properly interprets the letter "r" as referring to the computer language. 
> You can get a more focussed search using rseek.com.
> 
> 
> 
> >
> >   [[alternative HTML version deleted]]
> 
> You should read the posting guide. Rhelp is a plain text mailing list.
> 
> >
> > __
> > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> > and provide commented, minimal, self-contained, reproducible code.
> 
> David Winsemius
> Alameda, CA, USA
> 
> 
> 
> 
> -- 
> Takiy BERRANDOU
> 0618916037
> takiyedd...@gmail.com
> 

David Winsemius
Alameda, CA, USA

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


Re: [R] inverse table

2016-06-15 Thread David L Carlson
After converting the table to a data frame, replicate each row by the number of 
observations:

> ddd.df <- as.data.frame(ddd)  # as.data.frame.table does the same thing
> ddd.new <- as.matrix(ddd.df[rep(seq_along(ddd.df[, 1]), ddd.df$Freq), 1:2])
> head(ddd.new)
a   b  
1   "a" "A"
1.1 "a" "A"
2   "b" "A"
2.1 "b" "A"
3   "c" "A"
4   "d" "A"
> rownames(ddd.new) <- NULL # Optional - get rid of row names
> head(ddd.new)
 a   b  
[1,] "a" "A"
[2,] "a" "A"
[3,] "b" "A"
[4,] "b" "A"
[5,] "c" "A"
[6,] "d" "A"

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

-Original Message-
From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Patrizio 
Frederic
Sent: Wednesday, June 15, 2016 11:10 AM
To: r-help@r-project.org
Subject: [R] inverse table

Dear R-users,
I've a problem that puzzle me

suppose I have a two way contigency  table

a <- sample(al <- letters[1:10],100,T)
b <- sample(bl <- LETTERS[1:5],100,T)
ab <- cbind(a,b)

ddd <- (xtabs(data = ab))
ddd <- as.matrix(ddd)

the question is: how do I reverse the code, thus how do I get raw data
(object ab) from ddd?

I've tried

as.data.frame.table(ddd)

which is not the answer I'm looking for.
Thanks in advance,

PF



-- 
+---
| Patrizio Frederic,
| http://morgana.unimore.it/frederic_patrizio/
+---

[[alternative HTML version deleted]]

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

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


Re: [R] inverse table

2016-06-15 Thread Marc Schwartz

> On Jun 15, 2016, at 11:10 AM, Patrizio Frederic  
> wrote:
> 
> Dear R-users,
> I've a problem that puzzle me
> 
> suppose I have a two way contigency  table
> 
> a <- sample(al <- letters[1:10],100,T)
> b <- sample(bl <- LETTERS[1:5],100,T)
> ab <- cbind(a,b)
> 
> ddd <- (xtabs(data = ab))
> ddd <- as.matrix(ddd)
> 
> the question is: how do I reverse the code, thus how do I get raw data
> (object ab) from ddd?
> 
> I've tried
> 
> as.data.frame.table(ddd)
> 
> which is not the answer I'm looking for.
> Thanks in advance,
> 
> PF


Hi,

There is a function called expand.dft(), which I posted some years ago, which 
is a modification of a prior version, posted a few years before that.

The updated version is here:

  https://stat.ethz.ch/pipermail/r-help/2009-January/378521.html

If memory serves, that code has made its way into one or more packages on CRAN 
but I don't recall which at the moment.

Regards,

Marc Schwartz

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


Re: [R] inverse table

2016-06-15 Thread Leonardo Fontenelle
Em Qua 15 jun. 2016, às 13:10, Patrizio Frederic escreveu:
> Dear R-users,
> I've a problem that puzzle me
> 
> suppose I have a two way contigency  table
> 
> a <- sample(al <- letters[1:10],100,T)
> b <- sample(bl <- LETTERS[1:5],100,T)
> ab <- cbind(a,b)
> 
> ddd <- (xtabs(data = ab))
> ddd <- as.matrix(ddd)
> 
> the question is: how do I reverse the code, thus how do I get raw data
> (object ab) from ddd?

I believe packages reshape and reshape2 could help, although I don't use
them.

a <- sample(al <- letters[1:10],100,T)
b <- sample(bl <- LETTERS[1:5],100,T)
ab <- cbind(a,b)
ddd <- (xtabs(data = ab))
ddd <- as.matrix(ddd)

df <- expand.grid(dimnames(ddd), stringsAsFactors = FALSE)
df$freq <- as.vector(ddd)
ab2 <- as.matrix(df[rep(seq.int(nrow(df)), df$freq), 1:2])
all.equal(ab2[order(ab2[, c("a", "b")])], 
  ab[order(ab[, c("a", "b")])])

Hope that helps,

Leonardo Ferreira Fontenelle

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

Re: [R] inverse table

2016-06-15 Thread Ulrik Stervbo
Hi Patrizio,

maybe there is a more efficient way, but you can loop over rows and columns
like this

ab.recon <- data.frame()

ddd.rownames <- rownames(ddd)
ddd.colnames <- colnames(ddd)

for(cur.row in ddd.rownames){
  for(cur.col in ddd.colnames){
times.found <- ddd[cur.row, cur.col]
tmp.df <- data.frame(a = rep(cur.row, times.found),
 b = rep(cur.col, times.found))
ab.recon <- rbind(ab.recon, tmp.df)
  }
}

Hope this helps
Ulrik

On Wed, 15 Jun 2016 at 18:12 Patrizio Frederic 
wrote:

> Dear R-users,
> I've a problem that puzzle me
>
> suppose I have a two way contigency  table
>
> a <- sample(al <- letters[1:10],100,T)
> b <- sample(bl <- LETTERS[1:5],100,T)
> ab <- cbind(a,b)
>
> ddd <- (xtabs(data = ab))
> ddd <- as.matrix(ddd)
>
> the question is: how do I reverse the code, thus how do I get raw data
> (object ab) from ddd?
>
> I've tried
>
> as.data.frame.table(ddd)
>
> which is not the answer I'm looking for.
> Thanks in advance,
>
> PF
>
>
>
> --
> +---
> | Patrizio Frederic,
> | http://morgana.unimore.it/frederic_patrizio/
> +---
>
> [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

[[alternative HTML version deleted]]

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


[R-es] PCA output

2016-06-15 Thread Dr. José A. Betancourt Bethencourt
Estimados

�C�mo se puede exportar  los resultados de summary(res.pca)  a un archivo
que deseemos sea en pdf o htlm? Como hemos visto en otros an�lisis

 

saludos

 

library(FactoMineR)

res.pca<-PCA(X, scale.unit = TRUE, dimensiones ,  graph = TRUE, axes =
c(1,2))

summary(res.pca) 

 

 

X


Max,TemperatureF

Mean,TemperatureF

Min,TemperatureF

Max,Dew,PointF

MeanDew,PointF

Min,DewpointF

Max,Humidity

Mean,Humidity

Min,Humidity


1

82

75

68

62

58

54

72

56


2

82

74

67

61

58

56

74

58


3

84

75

66

62

58

52

77

58


4

82

73

65

61

57

54

76

59


5

83

75

66

60

58

54

73

57


6

84

73

62

64

59

56

83

64


7

85

75

65

61

58

54

76

58


8

85

76

66

60

56

49

73

53


9

84

74

64

60

55

49

72

53


10

84

75

65

60

57

52

72

54


11

84

75

65

61

56

49

74

53


12

87

76

64

63

55

50

72

52


13

86

76

64

61

57

50

75

54


14

86

77

67

59

56

51

70

51


15

85

76

68

62

60

57

76

58


16

87

77

67

66

61

56

81

59


17

89

77

66

68

62

56

84

63


18

88

77

67

68

61

55

85

62


19

88

79

70

65

63

60

78

61


20

85

76

68

66

62

58

85

66


21

84

76

68

67

64

60

88

69


22

85

76

66

68

63

57

92

70


23

81

73

66

70

66

64

98

83


24

85

76

67

68

64

61

88

70


25

85

77

70

67

64

62

82

65


26

84

77

70

68

64

62

85

66


27

84

76

68

67

64

62

84

68


28

82

74

66

68

64

60

90

73


29

83

74

65

69

63

57

96

73


30

83

76

68

66

63

60

82

67


31

85

77

69

65

62

58

82

62


32

85

76

68

67

65

61

90

72


33

84

75

67

68

63

59

90

67


34

84

75

66

68

63

57

91

69


35

85

76

66

69

64

59

95

71


36

84

75

66

68

63

58

88

68


37

82

74

66

71

65

62

100

78


38

84

75

66

70

66

62

99

81


39

85

75

64

70

66

61

93

79


40

84

75

66

70

65

60

93

76


41

84

74

65

69

65

61

93

77


42

82

74

67

70

67

64

95

82


43

81

74

66

70

66

62

94

81


44

83

73

64

70

65

60

94

78


45

83

74

65

70

65

61

93

80


46

82

75

66

71

66

63

94

80


47

81

73

65

67

64

60

88

75


48

84

74

64

64

60

56

79

62


49

84

76

67

66

62

59

83

65


50

84

75

65

69

64

61

89

72


51

85

76

67

65

62

58

80

63

 



--
Este mensaje le ha llegado mediante el servicio de correo electronico que 
ofrece Infomed para respaldar el cumplimiento de las misiones del Sistema 
Nacional de Salud. La persona que envia este correo asume el compromiso de usar 
el servicio a tales fines y cumplir con las regulaciones establecidas

Infomed: http://www.sld.cu/




[[alternative HTML version deleted]]

___
R-help-es mailing list
R-help-es@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-help-es

[R] inverse table

2016-06-15 Thread Patrizio Frederic
Dear R-users,
I've a problem that puzzle me

suppose I have a two way contigency  table

a <- sample(al <- letters[1:10],100,T)
b <- sample(bl <- LETTERS[1:5],100,T)
ab <- cbind(a,b)

ddd <- (xtabs(data = ab))
ddd <- as.matrix(ddd)

the question is: how do I reverse the code, thus how do I get raw data
(object ab) from ddd?

I've tried

as.data.frame.table(ddd)

which is not the answer I'm looking for.
Thanks in advance,

PF



-- 
+---
| Patrizio Frederic,
| http://morgana.unimore.it/frederic_patrizio/
+---

[[alternative HTML version deleted]]

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


Re: [R] is there a package in R or functions to calculate odds/hasard ratio from spline regression

2016-06-15 Thread Leonardo Fontenelle
Em Ter 14 jun. 2016, às 11:43, takiy berrandou escreveu:
> Hello,
> 
> I'm looking for a package or function, which calculate OR/HR from spline
> model regression. for example in SAS it exist some MACRO helping to do
> that
> easiely.
> 
> i had make some research on the forum here and on the web but without any
> succes.
> 

One, there are functions/packages to calculate OR/HR.
Two, there are functions/packages to use splines as predictors, instead
of the usual linear effect.

As David said, "odds ration in R" and so on is a great way to find what
you want.

Att,

Leonardo Ferreira Fontenelle, MD, MPH

PhD candidate in epidemiology, Federal University of Pelotas
Professor of medicine, Vila Velha University
Legislative consultant in health, Municipal Chamber of Vitória.

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

Re: [R] is there a package in R or functions to calculate odds/hasard ratio from spline regression

2016-06-15 Thread David Winsemius

> On Jun 14, 2016, at 7:43 AM, takiy berrandou  wrote:
> 
> Hello,
> 
> I'm looking for a package or function, which calculate OR/HR from spline
> model regression. for example in SAS it exist some MACRO helping to do that
> easiely.
> 
> i had make some research on the forum here and on the web but without any
> succes.
> 

It's not yet clear what  you want to do. Odds ratios are easily calculated from 
logistic regression models (typically constructed with the glm function the 
stats package) and hazard ratios are easily calculated from survival models 
(typically constructed with survreg or coxph in the survival package). All 
those functions accept spline terms in their formula versions. There are many 
worked examples that could be found with google searching since google now 
properly interprets the letter "r" as referring to the computer language. You 
can get a more focussed search using rseek.com.



> 
>   [[alternative HTML version deleted]]

You should read the posting guide. Rhelp is a plain text mailing list.

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

David Winsemius
Alameda, CA, USA

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


Re: [R-es] Ejecutar bloques con codigo

2016-06-15 Thread eric

Muchas gracias Javier, siempre aportas buenas ideas.

Saludos,

Eric.





On 06/14/2016 03:03 PM, Javier Marcuzzi wrote:

Estimado Eric

Supongo que usted tiene una organización de código tipo:

Hacer A …

Hacer B …

Hacer C …

De acuerdo a lo que necesita en algunas oportunidades es en el orden
anterior (A, B ,C), en otros casos (A, C), o podría ser (C, B, A).

Ante esa forma podría ser colocar los Hacer X, en archivos separados y
llamarlos con source, o todos al principio, y luego los “llama”,
haciendo como una función.

Yo prefiero una carpeta para el proyecto, en esta un archivo de R que
llama a los otros archivos de R colocados entro de una carpeta para
guardar códigos de proceso.

De esta forma el código puede llegar a organizarse de esta forma

Análisis A.r

… source A

… source B

Análisis B.r

… source B

… source A

Javier Rubén Marcuzzi

*De: *eric 
*Enviado: *domingo, 12 de junio de 2016 10:00
*Para: *Lista R 
*Asunto: *[R-es] Ejecutar bloques con codigo

Estimados, estoy usando R desde rkward y quisiera saber, porque no lo he

encontrado  ni logrado, si es posible ejecutar bloques de codigo usando

alguna instruccion de R. Me explico ...en rkward es posible marcar

trozos de codigo y luego ejecutarlos pinchando los iconos o en el manu o

usando short-cuts (Ctrl+Shift+F1 por ejemplo)... pero yo quisiera hacer

eso usando alguna instruccion de codigo ... es esto posible ? si es

posible, como se hace ?

Por distintas razones, tengo trozos en distintos lugares de un script

que debo ejecutar no siempre en el mismo orden y lo mas comodo para mi

seria usando codigo.

Alguna idea ?

Muchas gracias,

Saludos,

Eric.

--

Forest Engineer

Master in Environmental and Natural Resource Economics

Ph.D. student in Sciences of Natural Resources at La Frontera University

Member in AguaDeTemu2030, citizen movement for Temuco with green city

standards for living

Nota: Las tildes se han omitido para asegurar compatibilidad con algunos

lectores de correo.

___

R-help-es mailing list

R-help-es@r-project.org

https://stat.ethz.ch/mailman/listinfo/r-help-es



--
Forest Engineer
Master in Environmental and Natural Resource Economics
Ph.D. student in Sciences of Natural Resources at La Frontera University
Member in AguaDeTemu2030, citizen movement for Temuco with green city 
standards for living


Nota: Las tildes se han omitido para asegurar compatibilidad con algunos 
lectores de correo.


___
R-help-es mailing list
R-help-es@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-help-es

[R] help for fine mappting

2016-06-15 Thread greg holly
dear all;


I am sorry for this posting. I have got help from Jim, Bert, Jeff and PIKAL
on similar issue before. I tried to modify Jim`s code to the real data but
it did not work. Now I am posting first two rows the imitation of real data
using dput() format (please see at the bottom).  I have two data sets,
data=map and data=ref. The first to rows of each data set are given below.
Data map has more than 27 million and data ref has about 560 rows.
Basically I need run two different tasks. My R codes for these task are
given below but they do not work properly. I sincerely do appreciate your
helps.



Regards,

Greg



Task 1)

For example, the first and second columns for row 1 in data ref are chr1,
6457839 and 6638389. So I need write an R code normally first look the
first row in ref (which they are chre1 6457839  and 6638389) than summing
the column of "map$post_prob" and give the number of map$snp falls between
6457839  and 6638389 that  their cumulative sum is >0.85. Then do the same
for the second, thirdin ref. At the end I would like a table gave below
(need_ouput). Please notice the all value specified info in ref data file
are exist in map$CHR and map$POS columns.



Task2)

Again example, the first and second columns for row 1 in data ref are chr1,
6457839 and 6638389. So I need that R gives me the minimum map$p for the 2
chr1, 6457839 and 6638389 (as there are many snps between these regions and
would like choose the smallest one in those regions. Than do the same for
the second, thirdrows in ref.



Then put the results of Task1 and Task2 into need_ouput file




#R codes modified from Jim


map2<-map[order(map$CHR, map$POS, -map$post_prob),]



# get a field for the counts

 ref$n<-NA



# and a field for the minimum p values

 ref$min_p<-NA



# get the number of rows in "ref"

 nref<-dim(ref)[1]

 for(i in 1:nref) {

  CHR<- which(map2$CHR==ref$CHR[i])

  POS_start<-which(map2$POS==ref$POS_start[i])

  POS_end<-which(map2$POS==ref$POS_end[i])

  cat("CHR", "CHR"," POS_start",POS_start,"POS_end",POS_end,"\n")



# get the range of matches

  POSrange<-range(c(CHR,POS_start,POS_end))



# convert this to a sequence spanning all matches

  allPOS<-POSrange[1]:POSrange[2]

  ref$n[i]<-sum(map2$post_prob[allPOS] > 0.99)

  ref$min_p[i]<-min(map2$p[allPOS])

 }





  dput(map)

  structure(list(CHR = structure(c(1L, 1L), .Label = "chr1", class =
"factor"),

  snp = structure(1:2, .Label = c("rs4747841", "rs4749917"), class
= "factor"),

  Allel1 = structure(1:2, .Label = c("A", "T"), class = "factor"),

  Allel2 = structure(c(2L, 1L), .Label = c("C", "G"), class =
"factor"),

  fr = c(0.551, 0.436), effec = c(-0.0011, 0.0011), SE = c(0.0029,

  0.0029), p = c(0.7, 0.7), POS = c(9960129L, 9960259L), post_prob
= c(1.248817e-158,

  1.248817e-158)), .Names = c("CHR", "snp", "Allel1", "Allel2",

  "fr", "effec", "SE", "p", "POS", "post_prob"), class = "data.frame",
row.names = c(NA,

  -2L))





 dput(ref)

 structure(list(CHR = structure(1:2, .Label = c("chr10", "chr14"

 ), class = "factor"), POS_start = c(6457839L, 21005246L), POS_end =
c(6638389L,

 21550658L)), .Names = c("CHR", "POS_start", "POS_end"), class =
"data.frame", row.names = c(NA,

-2L))





dput(need_output)

structure(list(CHR = structure(1:2, .Label = c("chr1", "chr22"

), class = "factor"), POS = c(312127953L, 46487552L), POS_start =
c(32036927L,

45766451L), POS_end = c(3232240262, 46801601), snp = structure(1:2, .Label
= c("rs1143427",

"rs55958907"), class = "factor"), alle1l = structure(1:2, .Label = c("G",

"T"), class = "factor"), allel2 = structure(1:2, .Label = c("A",

"G"), class = "factor"), fr = c(0.278, 0.974), effec = c(0.6,

0.106), SE = c(0.015, 0.027), P = c(0.000156, 7.63e-05), post_prob =
c(0.229,

0.125), n = c(612L, 4218L)), .Names = c("CHR", "POS", "POS_start",

"POS_end", "snp", "alle1l", "allel2", "fr", "effec", "SE", "P",

"post_prob", "n"), class = "data.frame", row.names = c(NA, -2L

))

[[alternative HTML version deleted]]

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


Re: [R] Error in twitterR package

2016-06-15 Thread Jeff Newmiller
I have never used that package, but the error message seems clear.  You need to 
use the correct arguments to the setup_twitter_oauth function, and that 
requires that you interact with twitter parsonally to obtain appropriate 
credentials. While someone here may be able to give you a pointer as to how to 
do that, Google is probably a more appropriate way to start learning about that 
because it involves a legal agreement between you and twitter and has nothing 
to do with R and we are not lawyers representing twitter or you.
-- 
Sent from my phone. Please excuse my brevity.

On June 14, 2016 9:46:57 PM PDT, Seema Shelke via R-help  
wrote:
> Hi,
>I am trying to use twitter package. I got  below error while
>authentication.
>> setup_twitter_oauth(api_key,api_secret,access_token,
>access_token_secret)
>[1] "Using direct authentication"
>Error in check_twitter_oauth() : OAuth authentication error:
>This most likely means that you have incorrectly called
>setup_twitter_oauth()'
>I am using windows machine. Please find below code and software
>details;
>library("twitteR")
>library(httr)
>library(ROAuth)
>download.file(url="http://curl.haxx.se/ca/cacert.pem;,
>destfile="cacert.pem")
>api_key  <-"xxx"
>api_secret  <- "xxx"
>access_token  <- " xxx"
>access_token_secret  <- "xxx"
>setup_twitter_oauth(api_key,api_secret,access_token,
>access_token_secret)
>R version : Ri386 3.3.0R studio:  0.99.902 
>Thanks,Seema
>   [[alternative HTML version deleted]]
>
>__
>R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>https://stat.ethz.ch/mailman/listinfo/r-help
>PLEASE do read the posting guide
>http://www.R-project.org/posting-guide.html
>and provide commented, minimal, self-contained, reproducible code.

[[alternative HTML version deleted]]

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

[R] Y in Kohonen xyf function

2016-06-15 Thread ch.elahe via R-help
Hi all,
I have a df and I want to use supervised Self Organizing Map to do 
classification. I should use Kohonen library and xyf function from it. As you 
know the xyf function looks like this and I have problem defining my Y:

xyf(data,Y,grid=somgrid(),rlen=100,alpha=c(0.05,0.01))
I want to do classification based on a column which shows the speed that a 
protocols is run, and this column is the following:

   $speed   :num 4 4 3 3 3 1 1 1 2 1 4 4 3
numbers from 1 to 4 show the speed from very fast to very slow protocols. so 
the property I want to be modeled is df$speed, but I don't know how should I 
bring it in xyf function. Does anyone know how to do that? I also added my 
train set ans test set: 

   dt=sort(sample(nrow(df),nrow(df)*.7))
   train=df[dt,]
   Xtraining=scale(trian)
   Xtest=scale(-trian)
   center=attr(Xtrianing,"scaled:center")
   scale=attr(Xtraining,"scaled:scale")
   xyf(Xtraining,,grid=somgrid(10,10,"hexagonal"))


Thanks for any Help,
Elahe

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


Re: [R] messy code found when reading CSV file on win 10 system

2016-06-15 Thread Duncan Murdoch

On 15/06/2016 1:22 AM, 李兰婷 wrote:

 Dear Team,
A problem occured when I run Rstudio.  Could you please give me some 
advice?there is a lot of messy code when I read a csv file, which includes 
several columns in chinese, and R code run on WIN 10  system. I tried all the 
methods I can find on the internet, but no one is worked. is there some way I 
can fix it?
Really appreciated your help.


You should use the RStudio help forums for RStudio problems.

Your problem might have nothing to do with RStudio, but you haven't 
given us any information about what you did, so we can't tell.


What you should do:

Start R without RStudio, e.g. using Rgui.  See if the problem persists. 
If so, post the details here.  If not, move over to the RStudio help forums.


Duncan Murdoch

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

[R] messy code found when reading CSV file on win 10 system

2016-06-15 Thread 李兰婷
 Dear Team,
A problem occured when I run Rstudio.  Could you please give me some 
advice?there is a lot of messy code when I read a csv file, which includes 
several columns in chinese, and R code run on WIN 10  system. I tried all the 
methods I can find on the internet, but no one is worked. is there some way I 
can fix it?
Really appreciated your help.
Best regards
Lanting 
[[alternative HTML version deleted]]

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

Re: [R] Warning message in openxlsx

2016-06-15 Thread peter dalgaard

On 15 Jun 2016, at 11:04 , PIKAL Petr  wrote:

> Hi
> 
> not completely sure but is there a variable with name "fonts" in some of your 
> data frames?


That doesn't usually give a warning, unless an option is set, and even then, 
it's not quite the same message:

> options(warnPartialMatchDollar=TRUE)
> airquality$O
  [1]  41  36  12  18  NA  28  23  19   8  NA   7  16  11  14  18  14  34   6

Warning message:
In `$.data.frame`(airquality, O) :
  Partial match of 'O' to 'Ozone' in data frame

So it might another $-method that does check for partial matching(?). 

At any rate, this sort of thing can often be debugged using 

options(warn=2, error=recover)

E.g., (with the above option still on)

> options(warn=2, error=recover)
> airquality$O
Error in `$.data.frame`(airquality, O) : 
  (converted from warning) Partial match of 'O' to 'Ozone' in data frame

Enter a frame number, or 0 to exit   

1: airquality$O
2: `$.data.frame`(airquality, O)
3: warning(gettextf("Partial match of '%s' to '%s' in data frame", name, names
4: .signalSimpleWarning("Partial match of 'O' to 'Ozone' in data frame", quote
5: withRestarts({
.Internal(.signalCondition(simpleWarning(msg, call), msg
6: withOneRestart(expr, restarts[[1]])
7: doWithOneRestart(return(expr), restart)

Selection: 2
Called from: withRestarts({
.Internal(.signalCondition(simpleWarning(msg, call), msg, 
call))
.Internal(.dfltWarn(msg, call))
}, muffleWarning = function() NULL)
Browse[1]> ls()
[1] "a" "name"  "names" "x"
Browse[1]> x
Ozone Solar.R Wind Temp Month Day
1  41 190  7.4   67 5   1
2  36 118  8.0   72 5   2

15320 223 11.5   68 9  30
Browse[1]> name
[1] "O"
Browse[1]> names
[1] "Ozone"   "Solar.R" "Wind""Temp""Month"   "Day"

-pd

> 
> Regards
> Petr
> 
>> -Original Message-
>> From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of
>> g.maub...@weinwolf.de
>> Sent: Tuesday, June 14, 2016 4:12 PM
>> To: r-help@r-project.org
>> Subject: [R] Warning message in openxlsx
>> 
>> Hi All,
>> 
>> I get the warning message
>> 
>> Warning message:
>> In styles$font : partial match of 'font' to 'fonts'
>> 
>> when executing
>> 
>> 
>>> xls_workbook <- t_create_workbook()
>>> xls_sheetname <- "Kunden"
>>> xls_ds_to_save <- ds_merge1
>>> xls_filename <- paste0(data_created,
>> "_Merge1_BW-SAP-Kunden_cleaned.xlsx")
>>> t_add_sheet(workbook = xls_workbook,
>> + sheetname = xls_sheetname,
>> + dataset = xls_ds_to_save)
>>> t_write_xlsx(workbook = xls_workbook,
>> +  path = path_output,
>> +  filename = xls_filename,
>> +  overwrite = TRUE)
>> 
>> where t_create_workbook() is
>> 
>> return(createWorkbook())
>> 
>> and t_add_sheet() is
>> 
>> addWorksheet(workbook,
>>sheetName = sheetname)
>>  writeDataTable(workbook,
>>sheet = sheetname,
>>x = dataset)
>>  ### writeDataTable writes data to a sheet an adds
>>  ### autofilter to the first line
>>  if (freeze_row <= 1 | freeze_col <= 1) {
>>NULL # do nothing
>>  }
>>  else {
>>freezePane(workbook,
>>  sheet = sheetname,
>>  firstActiveRow = freeze_row,
>>  firstActiveCol = freeze_col)
>>  }
>> 
>>  setColWidths(workbook,
>>sheet = sheetname,
>>cols = 1:ncol(dataset),
>>widths = "auto")
>> 
>> and t_write_xlsx is
>> 
>> saveWorkbook(workbook,
>>file = file.path(path, filename),
>>overwrite = overwrite)
>> 
>> I am woundring what "partial match of 'font' to 'fonts'" means cause I do not
>> call it in the functions calls. I use these calls a lot in my programs but 
>> never got
>> this message before.
>> 
>> What does this message mean? How can I avoid this message?
>> 
>> Kind regards
>> 
>> Georg Maubach
>> 
>> PS: You can find more information about the used functions by going to
>> https://sourceforge.net/projects/r-project-utilities/files/?source=navbar
>> .
>> 
>> __

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

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


Re: [R] Warning message in openxlsx

2016-06-15 Thread PIKAL Petr
Hi

not completely sure but is there a variable with name "fonts" in some of your 
data frames?

Regards
Petr

> -Original Message-
> From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of
> g.maub...@weinwolf.de
> Sent: Tuesday, June 14, 2016 4:12 PM
> To: r-help@r-project.org
> Subject: [R] Warning message in openxlsx
>
> Hi All,
>
> I get the warning message
>
> Warning message:
> In styles$font : partial match of 'font' to 'fonts'
>
> when executing
>
>
> > xls_workbook <- t_create_workbook()
> > xls_sheetname <- "Kunden"
> > xls_ds_to_save <- ds_merge1
> > xls_filename <- paste0(data_created,
> "_Merge1_BW-SAP-Kunden_cleaned.xlsx")
> > t_add_sheet(workbook = xls_workbook,
> + sheetname = xls_sheetname,
> + dataset = xls_ds_to_save)
> > t_write_xlsx(workbook = xls_workbook,
> +  path = path_output,
> +  filename = xls_filename,
> +  overwrite = TRUE)
>
> where t_create_workbook() is
>
> return(createWorkbook())
>
> and t_add_sheet() is
>
>  addWorksheet(workbook,
> sheetName = sheetname)
>   writeDataTable(workbook,
> sheet = sheetname,
> x = dataset)
>   ### writeDataTable writes data to a sheet an adds
>   ### autofilter to the first line
>   if (freeze_row <= 1 | freeze_col <= 1) {
> NULL # do nothing
>   }
>   else {
> freezePane(workbook,
>   sheet = sheetname,
>   firstActiveRow = freeze_row,
>   firstActiveCol = freeze_col)
>   }
>
>   setColWidths(workbook,
> sheet = sheetname,
> cols = 1:ncol(dataset),
> widths = "auto")
>
> and t_write_xlsx is
>
> saveWorkbook(workbook,
> file = file.path(path, filename),
> overwrite = overwrite)
>
> I am woundring what "partial match of 'font' to 'fonts'" means cause I do not
> call it in the functions calls. I use these calls a lot in my programs but 
> never got
> this message before.
>
> What does this message mean? How can I avoid this message?
>
> Kind regards
>
> Georg Maubach
>
> PS: You can find more information about the used functions by going to
> https://sourceforge.net/projects/r-project-utilities/files/?source=navbar
> .
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-
> guide.html
> and provide commented, minimal, self-contained, reproducible code.


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

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

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

In case that this e-mail forms part of business dealings:
- the sender reserves the right to end negotiations about entering into a 
contract in any time, for any reason, and without stating any reasoning.
- if the e-mail contains an offer, the recipient is entitled to immediately 
accept such offer; The sender of this e-mail (offer) excludes any acceptance of 
the offer on the part of the recipient containing any amendment or variation.
- the sender insists on that the respective contract is concluded only upon an 
express mutual agreement on all its aspects.
- 

Re: [R] Factor levels in training set

2016-06-15 Thread PIKAL Petr
Hi Elahe

I get slightly different error when using scale to nonnumeric data so I am not 
sure if you use the scale function from base package.

> scale(raman[1:20,])
Error in colMeans(x, na.rm = TRUE) : 'x' must be numeric

Anyway, how do you expect scaling shall be done when you have nonumeric 
variable. What shall be the output of

scale(iris$Species)

The only workaround is either to scale only numeric variables from your data 
and add nonnumeric in folowing step or to change all factor variable to numeric 
before scaling (which I would not recommend).

If your data are supposed to be numeric you can check if they really are by

str(df)

Cheers
Petr

> -Original Message-
> From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of ch.elahe
> via R-help
> Sent: Tuesday, June 14, 2016 5:29 PM
> To: R-help Mailing List 
> Subject: [R] Factor levels in training set
>
>
>  Hi all,
> I want to use Supervised Self organizing Maps from Kohonen package for my
> data. I need to divide my df into training set and test set, but a part of my 
> df
> contains column with factor levels and I don't know how to bring them into
> my training set. Currently I use the following command for my training set:
>
> dt=sort(sample(nrow(df),nrow(df)*.7))
> training=m[dt,]
> till here I get no error but in the next step which I need to bring my 
> training
> set in a matrix I face this error:
>
> scale(df[training,])
> error: 'x' should be numeric
> Does anyone know how should I include column with factor levels in my df so
> that I don't get this error?
> Thanks for any help,
> Elahe
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-
> guide.html
> and provide commented, minimal, self-contained, reproducible code.


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

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

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

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

[R-es] Hadoop

2016-06-15 Thread Javier Villacampa González
Hola buenas,

me preguntaba si alguno usa hadoop Spark en su día día y si me podíais
recomendar un buen curso para empezar. Estuve en la charla de meetup de
madrid hace unos meses de Rspark y estuvo bien, ahora me preguntaba si es
posible profundizar.

Pero me gustaría tener recomendaciones de cualquier material que podáis
recomendar, cursos de coursera que hayais hecho, libros que hayais leido,
charlas de youtube que hayais visto. Los objetivo son:

   1. que sea simple,  un poco para tontitos y si puede ser que usen R por
   no meterme con una cosa más.
   2. que lo hayáis mirado, la red esta llena de cosas de estas me gustaría
   que me dieses opinión. Estoy intentando hacer alguno a ciegas pero no es la
   mejor opción
   3. que sea simple y con R


Gracias por adelantado.

--

[[alternative HTML version deleted]]

___
R-help-es mailing list
R-help-es@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-help-es


Re: [R] [FORGED] Re: help with r package "trip"

2016-06-15 Thread Rolf Turner

On 15/06/16 20:18, Jim Lemon wrote:

Hi Alice,
Have you tried creating a vector of the start position (xpos[1],ypos[1]):

xstart<-rep(xpos[1],n)
ystart<-rep(ypos[1],n)
# where "n" is the number of subsequent positions in the trip
max(trackDistance(xstart,ystart,xpos[2:n],ypos[2:n],...))

may then give you the value of the longest distance from the start. I
don't have the trip package or I could see if you really need to
replicate the start positions.


Jim:  This seems to me to be somewhat off the point.  The OP was faced 
with the problem of not being able to access the function homedist(). 
This function seems *not* to be exported from the trip package, and yet 
it is a *documented* function which I would assume to imply that users 
should be able to invoke it directly.


It is possible that in the past the OP was dealing with a version of the 
trip package that was created before namespaces came into the picture, 
whence "exporting" was not relevant.  I would suggest that the OP 
contact the package maintainer (maintainer("trip") will give you the 
email address) and enquire as to what is going on.


In the interim, a workaround *might* be to invoke homedist() as

trip:::homedist()

Note the *triple* colon in the foregoing.  I am not at all familiar with 
the trip package so my advice should probably be taken with several 
grains of salt.


cheers,

Rolf Turner

--
Technical Editor ANZJS
Department of Statistics
University of Auckland
Phone: +64-9-373-7599 ext. 88276


On Wed, Jun 15, 2016 at 1:43 PM, Alice Domalik  wrote:

Hi List,

I'm relatively new to R, so apologies if my question is rather elementary.
I'm working with some bird tracking data and I would like to calculate the 
maximum distance traveled from the colony.
For the maximum distance traveled, I was going to use the function homedist(). 
However, when I try to use this function I get the following error:
Error: could not find function "homedist"
Anyone know why I would get this error? I have been using other functions in 
"trip" without an issue. Is there an alternative way I can calculate this?

Thanks in advance for any help!


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


Re: [R] help with r package "trip"

2016-06-15 Thread Jim Lemon
Hi Alice,
Have you tried creating a vector of the start position (xpos[1],ypos[1]):

xstart<-rep(xpos[1],n)
ystart<-rep(ypos[1],n)
# where "n" is the number of subsequent positions in the trip
max(trackDistance(xstart,ystart,xpos[2:n],ypos[2:n],...))

may then give you the value of the longest distance from the start. I
don't have the trip package or I could see if you really need to
replicate the start positions.

JIm


On Wed, Jun 15, 2016 at 1:43 PM, Alice Domalik  wrote:
> Hi List,
>
> I'm relatively new to R, so apologies if my question is rather elementary.
> I'm working with some bird tracking data and I would like to calculate the 
> maximum distance traveled from the colony.
> For the maximum distance traveled, I was going to use the function 
> homedist(). However, when I try to use this function I get the following 
> error:
> Error: could not find function "homedist"
> Anyone know why I would get this error? I have been using other functions in 
> "trip" without an issue. Is there an alternative way I can calculate this?
>
> Thanks in advance for any help!
>
> [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

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