Re: [R] dput( list(,..) ) could be improved

2016-01-05 Thread Martin Maechler

> > On Jan 4, 2016, at 11:17 PM, Lietz, Haiko  wrote:
> > 
> > hi all,
> > 
> > when dputting a list of sparse matrices (Matrix package), the output does 
> > not contain the data but the information that the list contains sparse 
> > matrices.
> > 
> > M <- sparseMatrix(i = c(2, 1), j = c(1, 2), x = c(1, 1))
> > 
> > dput(M) ... works.
> > 
> > dput(list(M, M)) ... does not work.
> > 
> > how can I dput a list of sparse matrices?

> > MM <- list(M,M)
> > dput(MM)
> list(, 
> )

> No problem.

> I do get an error (clarifying the "did not work" statement), as (perhaps) did 
> you?

> > dput(M,M)
> Error in cat("new(\"", clx, "\"\n", file = file, sep = "") : 
>   invalid connection

> Perhaps the `dput` function was not configured to handle two S4 objects in  a 
> list?

Indeed.  As a matter of fact,  a long time I ago I had added a 'FIXME'
comment to the R source code of dput:

see  https://svn.r-project.org/R/trunk/src/library/base/R/dput.R

which contains

## FIXME: this should happen in C {deparse2() in ../../../main/deparse.c}
##but we are missing a C-level slotNames()
## Fails e.g. if an S3 list-like object has S4 components
if(isS4(x)) {
clx <- class(x)
cat('new("', clx,'"\n', file = file, sep = "")
for(n in methods::.slotNames(clx)) {
cat(",", n, "= ", file = file)
dput(methods::slot(x, n), file = file, control = control)
}
cat(")\n", file = file)
invisible()
}
else .Internal(dput(x, file, opts))

Ideally the above code would be replaced by simply

.Internal(dput(x, file, opts))

and the C code called in do_dput()  in
  https://svn.r-project.org/R/trunk/src/main/deparse.c
would be improved to do the above in C and be properly
recursive.

(Tested) patches are very welcome!

Martin Maechler,
ETH Zurich and R Core Team

__
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] R package built using newer version of R

2016-01-05 Thread Harrie Robins
If that fails (sometimes R gives a version error, package not available for
R version X.X.X), you could try downloading the source package
(package.tar.gz) and compile it with running from console (or prompt):

R CMD INSTALL packagename.tar.gz library-location

Regards,

Harrie

-Original Message-
From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Duncan
Murdoch
Sent: maandag 4 januari 2016 20:16
To: Tyler Auerbeck ; r-help@r-project.org
Subject: Re: [R] R package built using newer version of R

On 04/01/2016 2:02 PM, Tyler Auerbeck wrote:
> We're currently looking at using the R eclipse plugin StatET as our 
> development environment. Due to certain requirements, we're still 
> using 2.15.1. However a required package of StatET was built using 
> 2.15.3, which results in the following warning:
>
> Warning message:
> package 'rj' was built under R version 2.15.3
>
> I'm still fairly new to R, but is there any way for us to rebuild this 
> package using 2.15.1? It doesn't appear to cause us any issues, but 
> it's still not desirable for users to see that warning.
>
> Any help would be appreciated.

Yes, it's quite easy to do so.  StatET probably gives menu options to do it,
but I don't know them:  you might want to ask them.  From the R console, try

install.packages("pkgname", type="source")

and if you have the necessary prerequisites (e.g. compilers), you'll get 
it installed from source.   If it fails, post the errors and the results 
of sessionInfo() here, and we'll probably be able to tell you what to do
next.

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-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] Merging two data files based on common dates

2016-01-05 Thread Santosh.Aryal
Hello there
Pardon my ignorance but, I have two data files with different series of dates 
and x and y values.
There are common dates in both files. For example
>datafile1
date1 xval
31/12/1982 20
1/01/198330
2/01/198340
3/01/198350
4/01/198360
5/01/1983  70
...
01/01/2010   77
...
31/12/1012   99

>datafile2
date2  yval
3/01/19830.4
4/01/19830.5
5/01/19830.6
..
01/01/201088

All I want is a file/object that merges the two files with data for common 
dates to look like this.
dateyval  xval
3/01/19830.4  50
4/01/19830.5  60
5/01/19830.6  70
..
01/01/201088 77

I tried ' merge' and ' join' commands but somehow I have not been able to get 
that. Any help will be appreciated.
Thank you.


Best regards

Santosh Aryal
CSIRO Land and Water
GPO Box 1666, Canberra ACT 2601
Ph:   02 6246 5963
Email: santosh.ar...@csiro.au







[[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] Merging two data files based on common dates

2016-01-05 Thread William Dunlap via R-help
You did not show the structure of your datasets (with, e.g.,
 dump(c("datafile1","datafile2"),file=stdout())) nor what your call to
merge() was.  However, it may be that you did not use the by.x and by.y
arguments to merge() to specify which columns to match.

txt1 <- "date1 xval
31/12/1982 20
1/01/198330
2/01/198340
3/01/198350
4/01/198360
5/01/1983  70"

txt2 <- "date2  yval
3/01/19830.4
4/01/19830.5
5/01/19830.6"

df1 <- read.table(text=txt1, header=TRUE)
df2 <- read.table(text=txt2, header=TRUE)
merge(x=df2, y=df1, by.x="date2", by.y="date1")
#   date2 yval xval
# 1 3/01/1983  0.4   50
# 2 4/01/1983  0.5   60
# 3 5/01/1983  0.6   70


Bill Dunlap
TIBCO Software
wdunlap tibco.com

On Mon, Jan 4, 2016 at 10:19 PM,  wrote:

> Hello there
> Pardon my ignorance but, I have two data files with different series of
> dates and x and y values.
> There are common dates in both files. For example
> >datafile1
> date1 xval
> 31/12/1982 20
> 1/01/198330
> 2/01/198340
> 3/01/198350
> 4/01/198360
> 5/01/1983  70
> ...
> 01/01/2010   77
> ...
> 31/12/1012   99
>
> >datafile2
> date2  yval
> 3/01/19830.4
> 4/01/19830.5
> 5/01/19830.6
> ..
> 01/01/201088
>
> All I want is a file/object that merges the two files with data for common
> dates to look like this.
> dateyval  xval
> 3/01/19830.4  50
> 4/01/19830.5  60
> 5/01/19830.6  70
> ..
> 01/01/201088 77
>
> I tried ' merge' and ' join' commands but somehow I have not been able to
> get that. Any help will be appreciated.
> Thank you.
>
>
> Best regards
>
> Santosh Aryal
> CSIRO Land and Water
> GPO Box 1666, Canberra ACT 2601
> Ph:   02 6246 5963
> Email: santosh.ar...@csiro.au
>
>
>
>
>
>
>
> [[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] store results from loop into a dataframe

2016-01-05 Thread DIGHE, NILESH [AG/2362]
Dear R users:

I am trying to create a function that will loop over three dependent variables 
in my aov model, and then get the HSD.test for each variable.  I like to store 
the results from each loop in a data frame.



When I run my function (funx) on my data (dat), results from only yield gets 
populated in all three columns of the dataframe.  I am not able to store the 
results for each variable in a dataframe. Any help will be highly appreciated.







function (x)

{

trait_names <- c("yield", "lp", "lnth")

d = data.frame(yield = rep(0, 6), lp = rep(0, 6), lnth = rep(0,

6))

for (i in trait_names) {

mod <- aov(formula(paste(trait_names, "~ PEDIGREE + FIELD + 
PEDIGREE*FIELD + FIELD%in%REP")),

data = x)

out <- HSD.test(mod, "PEDIGREE", group = TRUE, console = FALSE)

d[, i] <- out$means[, 1]

}

d

}


structure(list(FIELD = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L,
3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3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, 6L, 6L, 1L, 1L, 1L, 2L, 2L, 2L, 3L, 3L, 3L, 4L, 4L, 4L,
5L, 5L, 5L, 6L, 6L, 6L, 1L, 1L, 1L, 2L, 2L, 2L, 3L, 3L, 3L, 4L,
4L, 4L, 5L, 5L, 5L, 6L, 6L, 6L), .Label = c("A", "B", "C", "D",
"E", "F"), class = "factor"), yield = c(1003L, 923L, 1268L, 1226L,
1059L, 1150L, 900L, 816L, 1072L, 1158L, 1026L, 1299L, 1083L,
1038L, 1236L, 1287L, 1270L, 1612L, 1513L, 1676L, 1504L, 1417L,
1932L, 1644L, 1293L, 1542L, 1452L, 1180L, 1248L, 1764L, 1326L,
1877L, 1788L, 1606L, 1809L, 1791L, 2294L, 2315L, 2320L, 2083L,
1895L, 2284L, 2000L, 2380L, 1952L, 2414L, 2354L, 2095L, 2227L,
2093L, 2019L, 2505L, 2410L, 2287L, 2507L, 2507L, 2349L, 2162L,
2108L, 2319L, 2028L, 1947L, 2352L, 2698L, 2369L, 1798L, 2422L,
2509L, 2234L, 2451L, 2139L, 1957L, 799L, 787L, 701L, 781L, 808L,
582L, 770L, 752L, 801L, 865L, 608L, 620L, 677L, 775L, 722L, 1030L,
606L, 729L, 1638L, 1408L, 1045L, 1685L, 1109L, 1210L, 1419L,
1048L, 1129L, 1549L, 1325L, 1315L, 1838L, 1066L, 1295L, 1499L,
1472L, 1139L), lp = c(NA, NA, 46.31, NA, NA, 43.8, NA, NA, 43.91,
NA, NA, 44.47, NA, NA, 45.16, NA, NA, 43.57, 40.65, NA, NA, 40.04,
NA, NA, 41.33, NA, NA, 40.75, NA, NA, 42.04, NA, NA, 40.35, NA,
NA, 43.682, NA, NA, 41.712, NA, NA, 42.566, NA, NA, 43.228, NA,
NA, 43.63, NA, NA, 42.058, NA, NA, NA, 45.19, NA, NA, 41.91,
NA, NA, 43.86, NA, NA, 44.48, NA, NA, 44.34, NA, NA, 43.03, NA,
NA, NA, 44.08, NA, NA, 41.39, NA, NA, 42.48, NA, NA, 44.13, NA,
NA, 43.39, NA, NA, 42.82, 42.18, NA, NA, 41.42, NA, NA, 41.25,
NA, NA, 42.31, NA, NA, 43.22, NA, NA, 40.52, NA, NA), lnth = c(NA,
NA, 1.151, NA, NA, 1.135, NA, NA, 1.109, NA, NA, 1.117, NA, NA,
1.107, NA, NA, 1.196, 1.255, NA, NA, 1.229, NA, NA, 1.158, NA,
NA, 1.214, NA, NA, 1.152, NA, NA, 1.194, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
1.2, NA, NA, 1.219, NA, NA, 1.115, NA, NA, 1.205, NA, NA, 1.238,
NA, NA, 1.244, NA, NA, NA, 1.096, NA, NA, 1.021, NA, NA, 1.055,
NA, NA, 1.058, NA, NA, 1.026, NA, NA, 1.115, 1.202, NA, NA, 1.161,
NA, NA, 1.168, NA, NA, 1.189, NA, NA, 1.204, NA, NA, 1.277, NA,
NA)), .Names = c("FIELD", "REP", "PEDIGREE", "yield", "lp", "lnth"
), row.names = c(NA, -108L), class = "data.frame")






R version 3.2.1 (2015-06-18)

Platform: i386-w64-mingw32/i386 (32-bit)

Running under: Windows 7 x64 (build 7601) Service Pack 1



locale:

[1] LC_COLLATE=English_United States.1252  LC_CTYPE=English_United States.1252

[3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C

[5] LC_TIME=English_United States.1252



attached base packages:

[1] stats graphics  grDevices utils datasets  methods   base



other attached packages:

[1] agricolae_1.2-1 asreml_3.0  lattice_0.20-31 ggplot2_1.0.1   dplyr_0.4.2 
plyr_1.8.3



loaded via a namespace (and not attached):

 [1] 

Re: [R] store results from loop into a dataframe

2016-01-05 Thread DIGHE, NILESH [AG/2362]
Sarah: Thanks for pointing out the errors in my function.

Below are the errors I am getting after I run the corrected quote:
Error in if (s) { : missing value where TRUE/FALSE needed
In addition: Warning message:
In qtukey(1 - alpha, ntr, DFerror) : NaNs produced

You are right, I have no idea to handle these errors.

Do you recommend any other approach to solve my problem? 

Thanks for your time.
Nilesh 



-Original Message-
From: Sarah Goslee [mailto:sarah.gos...@gmail.com] 
Sent: Tuesday, January 05, 2016 11:20 AM
To: DIGHE, NILESH [AG/2362]
Cc: r-help@r-project.org
Subject: Re: [R] store results from loop into a dataframe

Leaving aside the question of whether this is the best way to approach your 
problem (unlikely), there's a couple of errors in your code involving indexing. 
Once fixed, the code demonstrates some errors in your use of HSD.test that will 
be harder for you to deal with.

Thanks for the complete reproducible example.

fun2 <- function (x)

{

trait_names <- c("yield", "lp", "lnth")

d = data.frame(yield = rep(0, 6), lp = rep(0, 6), lnth = rep(0,

6))

for (i in trait_names) {
# your formula has all the trait names, not the selected one
# mod <- aov(formula(paste(trait_names, "~ PEDIGREE + FIELD + 
PEDIGREE*FIELD + FIELD%in%REP")), data = x)
mod <- aov(formula(paste(i, "~ PEDIGREE + FIELD + PEDIGREE*FIELD + 
FIELD%in%REP")), data = x)

out <- HSD.test(mod, "PEDIGREE", group = TRUE, console = FALSE)

# you're indexing by the trait name, instead of its position
# d[, i] <- out$means[, 1]
d[, which(trait_names == i)] <- out$means[, 1]

}

d

}

Sarah

On Tue, Jan 5, 2016 at 11:48 AM, DIGHE, NILESH [AG/2362] 
 wrote:
> Dear R users:
>
> I am trying to create a function that will loop over three dependent 
> variables in my aov model, and then get the HSD.test for each variable.  I 
> like to store the results from each loop in a data frame.
>
>
>
> When I run my function (funx) on my data (dat), results from only yield gets 
> populated in all three columns of the dataframe.  I am not able to store the 
> results for each variable in a dataframe. Any help will be highly appreciated.
>
>
>
>
>
>
>
> function (x)
>
> {
>
> trait_names <- c("yield", "lp", "lnth")
>
> d = data.frame(yield = rep(0, 6), lp = rep(0, 6), lnth = rep(0,
>
> 6))
>
> for (i in trait_names) {
>
> mod <- aov(formula(paste(trait_names, "~ PEDIGREE + FIELD + 
> PEDIGREE*FIELD + FIELD%in%REP")),
>
> data = x)
>
> out <- HSD.test(mod, "PEDIGREE", group = TRUE, console = 
> FALSE)
>
> d[, i] <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= "factor"), PEDIGREE = structure(c(1L, 1L, 1L, 2L, 2L, 2L, 3L, 
> 3L, 3L, 4L, 4L, 4L, 5L, 5L, 5L, 6L, 6L, 6L, 1L, 1L, 1L, 2L, 2L, 2L, 
> 3L, 3L, 3L, 4L, 4L, 4L, 5L, 5L, 5L, 6L, 6L, 6L, 1L, 1L, 1L, 2L, 2L, 
> 2L, 3L, 3L, 3L, 4L, 4L, 4L, 5L, 5L, 5L, 6L, 6L, 6L, 1L, 1L, 1L, 2L, 
> 2L, 2L, 3L, 3L, 3L, 4L, 4L, 4L, 5L, 5L, 5L, 6L, 6L, 6L, 1L, 1L, 1L, 
> 2L, 2L, 2L, 3L, 3L, 3L, 4L, 4L, 4L, 5L, 5L, 5L, 6L, 6L, 6L, 1L, 1L, 
> 1L, 2L, 2L, 2L, 3L, 3L, 3L, 4L, 4L, 4L, 5L, 5L, 5L, 6L, 6L, 6L), 
> .Label = c("A", "B", "C", "D", "E", "F"), class = "factor"), yield = 
> c(1003L, 923L, 1268L, 1226L, 1059L, 1150L, 900L, 816L, 1072L, 1158L, 
> 1026L, 1299L, 1083L, 1038L, 1236L, 1287L, 1270L, 1612L, 1513L, 1676L, 
> 1504L, 1417L, 1932L, 1644L, 1293L, 1542L, 1452L, 1180L, 1248L, 1764L, 
> 1326L, 1877L, 1788L, 1606L, 1809L, 1791L, 2294L, 2315L, 2320L, 2083L, 
> 1895L, 2284L, 2000L, 2380L, 1952L, 2414L, 2354L, 2095L, 2227L, 2093L, 
> 2019L, 2505L, 2410L, 2287L, 2507L, 2507L, 2349L, 2162L, 2108L, 2319L, 
> 2028L, 1947L, 2352L, 2698L, 2369L, 1798L, 2422L, 2509L, 2234L, 2451L, 
> 2139L, 1957L, 799L, 787L, 701L, 781L, 808L, 582L, 770L, 752L, 801L, 
> 865L, 608L, 620L, 677L, 775L, 722L, 1030L, 606L, 

Re: [R] Equality of factor levels problem

2016-01-05 Thread Martín Cañón
Thank you, Sarah.

This works just fine. 

So simple. 

I didn't know I had to change the factor to character before making the 
comparison.

Regards,

Mart�n


  
[[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] Equality of factor levels problem

2016-01-05 Thread Sarah Goslee
You want to compare the values of the levels, I think?

What about:
> as.character(dat$var1) == as.character(dat$var2)
[1]  TRUE FALSE  TRUE FALSE FALSE

Sarah


On Tue, Jan 5, 2016 at 10:58 AM, Martín Cañón  wrote:
> Hi to all useRs on the list.
>
> I want to know if there is a function in R which evaluates if observations of 
> two factors (similar but with unequal levels) in a data frame are equal at 
> row level.
>
> Example of dataset:
>
> var1 <- c(1, 2, 3, 2, 1)
> var2 <- c(1, 3, 3, 4, 2)
> dat <- data.frame(var1, var2)
> dat$var1 <- factor(dat$var1, labels = c("low", "medium", "high"))
> dat$var2 <- factor(dat$var2, labels = c("low", "medium", "high", "very high"))
>
> What I want as a result is a logical vector that says if observation [i, 1] 
> is equal to observation [i, 2].
>
> Something like...
>
> var1[1] == var2[1]  # TRUE
> var1[2] == var2[2]  # FALSE
> var1[3] == var2[3]  # TRUE
> var1[4] == var2[4]  # FALSE
> var1[4] == var2[4]  # FALSE
>
> I've tried equal signs (==), commands such as "identical" and "all.equal" in 
> "for loops" and I can't make it work for factors.
>
> It seems very simple but I just don't find the way to do it.
>
> Regards,
>
> Martín
>
-- 
Sarah Goslee
http://www.numberwright.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] store results from loop into a dataframe

2016-01-05 Thread Sarah Goslee
Leaving aside the question of whether this is the best way to approach
your problem (unlikely), there's a couple of errors in your code
involving indexing. Once fixed, the code demonstrates some errors in
your use of HSD.test that will be harder for you to deal with.

Thanks for the complete reproducible example.

fun2 <- function (x)

{

trait_names <- c("yield", "lp", "lnth")

d = data.frame(yield = rep(0, 6), lp = rep(0, 6), lnth = rep(0,

6))

for (i in trait_names) {
# your formula has all the trait names, not the selected one
# mod <- aov(formula(paste(trait_names, "~ PEDIGREE + FIELD +
PEDIGREE*FIELD + FIELD%in%REP")), data = x)
mod <- aov(formula(paste(i, "~ PEDIGREE + FIELD +
PEDIGREE*FIELD + FIELD%in%REP")), data = x)

out <- HSD.test(mod, "PEDIGREE", group = TRUE, console = FALSE)

# you're indexing by the trait name, instead of its position
# d[, i] <- out$means[, 1]
d[, which(trait_names == i)] <- out$means[, 1]

}

d

}

Sarah

On Tue, Jan 5, 2016 at 11:48 AM, DIGHE, NILESH [AG/2362]
 wrote:
> Dear R users:
>
> I am trying to create a function that will loop over three dependent 
> variables in my aov model, and then get the HSD.test for each variable.  I 
> like to store the results from each loop in a data frame.
>
>
>
> When I run my function (funx) on my data (dat), results from only yield gets 
> populated in all three columns of the dataframe.  I am not able to store the 
> results for each variable in a dataframe. Any help will be highly appreciated.
>
>
>
>
>
>
>
> function (x)
>
> {
>
> trait_names <- c("yield", "lp", "lnth")
>
> d = data.frame(yield = rep(0, 6), lp = rep(0, 6), lnth = rep(0,
>
> 6))
>
> for (i in trait_names) {
>
> mod <- aov(formula(paste(trait_names, "~ PEDIGREE + FIELD + 
> PEDIGREE*FIELD + FIELD%in%REP")),
>
> data = x)
>
> out <- HSD.test(mod, "PEDIGREE", group = TRUE, console = FALSE)
>
> d[, i] <- out$means[, 1]
>
> }
>
> d
>
> }
>
>
> structure(list(FIELD = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L,
> 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L,
> 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L,
> 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3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, 2L, 2L, 2L, 3L, 3L, 3L, 4L, 4L, 4L, 5L, 5L,
> 5L, 6L, 6L, 6L, 1L, 1L, 1L, 2L, 2L, 2L, 3L, 3L, 3L, 4L, 4L, 4L,
> 5L, 5L, 5L, 6L, 6L, 6L, 1L, 1L, 1L, 2L, 2L, 2L, 3L, 3L, 3L, 4L,
> 4L, 4L, 5L, 5L, 5L, 6L, 6L, 6L), .Label = c("A", "B", "C", "D",
> "E", "F"), class = "factor"), yield = c(1003L, 923L, 1268L, 1226L,
> 1059L, 1150L, 900L, 816L, 1072L, 1158L, 1026L, 1299L, 1083L,
> 1038L, 1236L, 1287L, 1270L, 1612L, 1513L, 1676L, 1504L, 1417L,
> 1932L, 1644L, 1293L, 1542L, 1452L, 1180L, 1248L, 1764L, 1326L,
> 1877L, 1788L, 1606L, 1809L, 1791L, 2294L, 2315L, 2320L, 2083L,
> 1895L, 2284L, 2000L, 2380L, 1952L, 2414L, 2354L, 2095L, 2227L,
> 2093L, 2019L, 2505L, 2410L, 2287L, 2507L, 2507L, 2349L, 2162L,
> 2108L, 2319L, 2028L, 1947L, 2352L, 2698L, 2369L, 1798L, 2422L,
> 2509L, 2234L, 2451L, 2139L, 1957L, 799L, 787L, 701L, 781L, 808L,
> 582L, 770L, 752L, 801L, 865L, 608L, 620L, 677L, 775L, 722L, 1030L,
> 606L, 729L, 1638L, 1408L, 1045L, 1685L, 1109L, 1210L, 1419L,
> 1048L, 1129L, 1549L, 1325L, 1315L, 1838L, 1066L, 1295L, 1499L,
> 1472L, 1139L), lp = c(NA, NA, 46.31, NA, NA, 43.8, NA, NA, 43.91,
> NA, NA, 44.47, NA, NA, 45.16, NA, NA, 43.57, 40.65, NA, NA, 40.04,
> NA, NA, 41.33, NA, NA, 40.75, NA, NA, 42.04, NA, NA, 40.35, NA,
> NA, 43.682, NA, NA, 41.712, NA, NA, 42.566, NA, NA, 43.228, NA,
> NA, 43.63, NA, NA, 42.058, NA, NA, NA, 45.19, NA, NA, 41.91,
> NA, NA, 43.86, NA, NA, 44.48, NA, NA, 44.34, NA, NA, 43.03, NA,
> NA, NA, 44.08, NA, NA, 41.39, NA, NA, 42.48, NA, NA, 44.13, NA,
> NA, 43.39, NA, NA, 42.82, 42.18, NA, NA, 41.42, NA, NA, 41.25,
> NA, NA, 42.31, NA, NA, 43.22, 

[R] Equality of factor levels problem

2016-01-05 Thread Martín Cañón
Hi to all useRs on the list.

I want to know if there is a function in R which evaluates if observations of 
two factors (similar but with unequal levels) in a data frame are equal at row 
level.

Example of dataset:

var1 <- c(1, 2, 3, 2, 1)
var2 <- c(1, 3, 3, 4, 2)
dat <- data.frame(var1, var2)
dat$var1 <- factor(dat$var1, labels = c("low", "medium", "high"))
dat$var2 <- factor(dat$var2, labels = c("low", "medium", "high", "very high"))

What I want as a result is a logical vector that says if observation [i, 1] is 
equal to observation [i, 2].

Something like...

var1[1] == var2[1]  # TRUE
var1[2] == var2[2]  # FALSE
var1[3] == var2[3]  # TRUE
var1[4] == var2[4]  # FALSE
var1[4] == var2[4]  # FALSE

I've tried equal signs (==), commands such as "identical" and "all.equal" in 
"for loops" and I can't make it work for factors. 

It seems very simple but I just don't find the way to do it.

Regards,

Mart�n 

  
[[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] Subsetting a square marix

2016-01-05 Thread Sarah Goslee
It really isn't clear what you want, and posting in HTML has mangled
what you did provide.

Please use dput() to provide sample data, and give us a clear idea of
what you want, ideally an example of what the output should look like.
Adding the R code you've tried to use is also a good idea.

Sarah

On Tue, Jan 5, 2016 at 4:06 AM, Tawanda Tarakini
 wrote:
> I have a global matrix (e.g. table below) of species feeding. I am trying
> to create specific matrix for specific sites. If for example a subset is to
> have sp1, sp3 and spp only these 3 species should be appearing in the
> subset (both column and rows).
>
> I have been checking online help but I seem not to get my scenario
>
>
>
> Sp1
>
> Sp2
>
> Sp3
>
> Sp4
>
> Sp5
>
> Sp6
>
> Sp1
>
> 0
>
> 0
>
> 1
>
> 0
>
> 0
>
> 0
>
> Sp2
>
> 1
>
> 0
>
> 0
>
> 0
>
> 1
>
> 0
>
> Sp3
>
> 0
>
> 0
>
> 0
>
> 1
>
> 0
>
> 0
>
> Sp4
>
> 0
>
> 1
>
> 0
>
> 1
>
> 0
>
> 0
>
> Sp5
>
> 0
>
> 0
>
> 1
>
> 0
>
> 0
>
> 0
>
> Sp6
>
> 0
>
> 0
>
> 0
>
> 1
>
> 1
>
> 0
>
> --
> Kind Regards
>
> Tawanda Tarakini
>
> Lecturer and Industrial attachment coordinator
> Department of Wildlife, Ecology and Conservation
> Chinhoyi University of Technology
> Bag 7724, Chinhoyi
> Cell: +263 775 321 722
> Alternative email: ttarak...@cut.ac.zw
>
> [[alternative HTML version deleted]]
>


-- 
Sarah Goslee
http://www.numberwright.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] Subsetting a square marix

2016-01-05 Thread Tawanda Tarakini
I have a global matrix (e.g. table below) of species feeding. I am trying
to create specific matrix for specific sites. If for example a subset is to
have sp1, sp3 and spp only these 3 species should be appearing in the
subset (both column and rows).

I have been checking online help but I seem not to get my scenario



Sp1

Sp2

Sp3

Sp4

Sp5

Sp6

Sp1

0

0

1

0

0

0

Sp2

1

0

0

0

1

0

Sp3

0

0

0

1

0

0

Sp4

0

1

0

1

0

0

Sp5

0

0

1

0

0

0

Sp6

0

0

0

1

1

0

-- 
Kind Regards

Tawanda Tarakini

Lecturer and Industrial attachment coordinator
Department of Wildlife, Ecology and Conservation
Chinhoyi University of Technology
Bag 7724, Chinhoyi
Cell: +263 775 321 722
Alternative email: ttarak...@cut.ac.zw

[[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] Merging two data files based on common dates

2016-01-05 Thread Sarah Goslee
Since the date columns have different names, you need to specify the
by.x and by.y arguments to merge().

Other than that, it should work.

If you need more help, please use dput() to provide some of your data,
and include both the code you used and the error message or incorrect
result you got (that is, a reproducible example). And also, post this
information in plain text rather than HTML.

Sarah

On Tue, Jan 5, 2016 at 1:19 AM,   wrote:
> Hello there
> Pardon my ignorance but, I have two data files with different series of dates 
> and x and y values.
> There are common dates in both files. For example
>>datafile1
> date1 xval
> 31/12/1982 20
> 1/01/198330
> 2/01/198340
> 3/01/198350
> 4/01/198360
> 5/01/1983  70
> ...
> 01/01/2010   77
> ...
> 31/12/1012   99
>
>>datafile2
> date2  yval
> 3/01/19830.4
> 4/01/19830.5
> 5/01/19830.6
> ..
> 01/01/201088
>
> All I want is a file/object that merges the two files with data for common 
> dates to look like this.
> dateyval  xval
> 3/01/19830.4  50
> 4/01/19830.5  60
> 5/01/19830.6  70
> ..
> 01/01/201088 77
>
> I tried ' merge' and ' join' commands but somehow I have not been able to get 
> that. Any help will be appreciated.
> Thank you.
>
>
> Best regards
>
> Santosh Aryal
> CSIRO Land and Water
> GPO Box 1666, Canberra ACT 2601
> Ph:   02 6246 5963
> Email: santosh.ar...@csiro.au
>
>
>

-- 
Sarah Goslee
http://www.numberwright.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] R package built using newer version of R

2016-01-05 Thread Marc Schwartz
Hi,

You appear to have downloaded and attempted to install the '.zip' version of 
the package, which is the pre-built Windows **binary** version of the package.

As Harrie noted below, you want to download the '.tar.gz' version of the 
package, which is the "source" version.

Regards,

Marc Schwartz


> On Jan 5, 2016, at 1:15 PM, Tyler Auerbeck  wrote:
> 
> When I run the install.packages("rj",type="source") I get the following:
> 
>> install.packages("rj",type="source")
> Warning message:
> package ‘rj’ is not available (for R version 2.15.1)
> 
> I believe this is because this is a package available directly from the
> creators of StatET. I tried pulling the zip down directly from their
> website and ran the following:
> 
>> 
> install.packages("C:\\users\\admin\\Downloads\\rj_2.0.3-1.zip",type="source",repos=NULL)
> package 'rj' successfully unpacked and MD5 sums checked
> 
> This installs it directly, but it still installs it as compiled for 2.15.3,
> which we see the same warning I originally mentioned.
> 
> Here is the sessionInfo() you asked for:
> 
>> sessionInfo()
> R version 2.15.1 (2012-06-22)
> Platform: x86_64-pc-mingw32/x64 (64-bit)
> 
> locale:
> [1] LC_COLLATE=English_United States.1252  LC_CTYPE=English_United
> States.1252LC_MONETARY=English_United States.1252
> [4] LC_NUMERIC=C   LC_TIME=English_United
> States.1252
> 
> attached base packages:
> [1] stats graphics  grDevices utils datasets  methods   base
> 
> loaded via a namespace (and not attached):
> [1] tools_2.15.1
> 
> 
> If there isn't a good way to compile this for 2.15.1, is there any way to
> just ignore the warning? I've seen that you can do something like
> 
> options( warn = -1 )
> 
> I know this isn't recommended to do on an extended timeframe, but this
> message only occurs during the first command that you run. Even if we
> could set up some sort of profile that would set this suppression, run
> a dummy command and then unset the suppression. I know this is a
> workaround, but I just wasn't sure what would be the simpler solution.
> 
> Let me know what you think or what I may be missing.
> 
> On Tue, Jan 5, 2016 at 3:41 AM, Harrie Robins  wrote:
> 
>> If that fails (sometimes R gives a version error, package not available for
>> R version X.X.X), you could try downloading the source package
>> (package.tar.gz) and compile it with running from console (or prompt):
>> 
>> R CMD INSTALL packagename.tar.gz library-location
>> 
>> Regards,
>> 
>> Harrie
>> 
>> -Original Message-
>> From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Duncan
>> Murdoch
>> Sent: maandag 4 januari 2016 20:16
>> To: Tyler Auerbeck ; r-help@r-project.org
>> Subject: Re: [R] R package built using newer version of R
>> 
>> On 04/01/2016 2:02 PM, Tyler Auerbeck wrote:
>>> We're currently looking at using the R eclipse plugin StatET as our
>>> development environment. Due to certain requirements, we're still
>>> using 2.15.1. However a required package of StatET was built using
>>> 2.15.3, which results in the following warning:
>>> 
>>> Warning message:
>>> package 'rj' was built under R version 2.15.3
>>> 
>>> I'm still fairly new to R, but is there any way for us to rebuild this
>>> package using 2.15.1? It doesn't appear to cause us any issues, but
>>> it's still not desirable for users to see that warning.
>>> 
>>> Any help would be appreciated.
>> 
>> Yes, it's quite easy to do so.  StatET probably gives menu options to do
>> it,
>> but I don't know them:  you might want to ask them.  From the R console,
>> try
>> 
>> install.packages("pkgname", type="source")
>> 
>> and if you have the necessary prerequisites (e.g. compilers), you'll get
>> it installed from source.   If it fails, post the errors and the results
>> of sessionInfo() here, and we'll probably be able to tell you what to do
>> next.
>> 
>> 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.

Re: [R] Subsetting a square marix

2016-01-05 Thread David L Carlson
Assuming I've reconstructed your data correctly:

> dta
Sp1 Sp2 Sp3 Sp4 Sp5 Sp6
Sp1   0   1   0   0   0   0
Sp2   0   0   0   1   0   0
Sp3   1   0   0   0   1   0
Sp4   0   0   1   1   0   1
Sp5   0   1   0   0   0   1
Sp6   0   0   0   0   0   0
> dput(dta)
structure(list(Sp1 = c(0L, 0L, 1L, 0L, 0L, 0L), Sp2 = c(1L, 0L, 
0L, 0L, 1L, 0L), Sp3 = c(0L, 0L, 0L, 1L, 0L, 0L), Sp4 = c(0L, 
1L, 0L, 1L, 0L, 0L), Sp5 = c(0L, 0L, 1L, 0L, 0L, 0L), Sp6 = c(0L, 
0L, 0L, 1L, 1L, 0L)), .Names = c("Sp1", "Sp2", "Sp3", "Sp4", 
"Sp5", "Sp6"), class = "data.frame", row.names = c("Sp1", "Sp2", 
"Sp3", "Sp4", "Sp5", "Sp6"))

The results of dput(dta) is what you should include in your plain text email.

As for the subset, your email indicated: sp1, sp3 and spp. But none of these 
are labels in your data set since R is case sensitive. Try for example:

> sub <- c("Sp1", "Sp3", "Sp5") 
> dta[sub, sub]
Sp1 Sp3 Sp5
Sp1   0   0   0
Sp3   1   0   1
Sp5   0   0   0

And definitely spend some time with the available free R tutorials so that you 
understand how R works.

-
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 Sarah Goslee
Sent: Tuesday, January 5, 2016 10:15 AM
To: Tawanda Tarakini
Cc: r-help
Subject: Re: [R] Subsetting a square marix

It really isn't clear what you want, and posting in HTML has mangled
what you did provide.

Please use dput() to provide sample data, and give us a clear idea of
what you want, ideally an example of what the output should look like.
Adding the R code you've tried to use is also a good idea.

Sarah

On Tue, Jan 5, 2016 at 4:06 AM, Tawanda Tarakini
 wrote:
> I have a global matrix (e.g. table below) of species feeding. I am trying
> to create specific matrix for specific sites. If for example a subset is to
> have sp1, sp3 and spp only these 3 species should be appearing in the
> subset (both column and rows).
>
> I have been checking online help but I seem not to get my scenario
>
>
>
> Sp1
>
> Sp2
>
> Sp3
>
> Sp4
>
> Sp5
>
> Sp6
>
> Sp1
>
> 0
>
> 0
>
> 1
>
> 0
>
> 0
>
> 0
>
> Sp2
>
> 1
>
> 0
>
> 0
>
> 0
>
> 1
>
> 0
>
> Sp3
>
> 0
>
> 0
>
> 0
>
> 1
>
> 0
>
> 0
>
> Sp4
>
> 0
>
> 1
>
> 0
>
> 1
>
> 0
>
> 0
>
> Sp5
>
> 0
>
> 0
>
> 1
>
> 0
>
> 0
>
> 0
>
> Sp6
>
> 0
>
> 0
>
> 0
>
> 1
>
> 1
>
> 0
>
> --
> Kind Regards
>
> Tawanda Tarakini
>
> Lecturer and Industrial attachment coordinator
> Department of Wildlife, Ecology and Conservation
> Chinhoyi University of Technology
> Bag 7724, Chinhoyi
> Cell: +263 775 321 722
> Alternative email: ttarak...@cut.ac.zw
>
> [[alternative HTML version deleted]]
>


-- 
Sarah Goslee
http://www.numberwright.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-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] store results from loop into a dataframe

2016-01-05 Thread Sarah Goslee
If you run each variable individually, you'll discover that the NAs in
your data are causing problems. It's up to you to figure out what the
best way to handle those missing values for your research is.

Sarah

On Tue, Jan 5, 2016 at 12:39 PM, DIGHE, NILESH [AG/2362]
 wrote:
> Sarah: Thanks for pointing out the errors in my function.
>
> Below are the errors I am getting after I run the corrected quote:
> Error in if (s) { : missing value where TRUE/FALSE needed
> In addition: Warning message:
> In qtukey(1 - alpha, ntr, DFerror) : NaNs produced
>
> You are right, I have no idea to handle these errors.
>
> Do you recommend any other approach to solve my problem?
>
> Thanks for your time.
> Nilesh
>
>
>
> -Original Message-
> From: Sarah Goslee [mailto:sarah.gos...@gmail.com]
> Sent: Tuesday, January 05, 2016 11:20 AM
> To: DIGHE, NILESH [AG/2362]
> Cc: r-help@r-project.org
> Subject: Re: [R] store results from loop into a dataframe
>
> Leaving aside the question of whether this is the best way to approach your 
> problem (unlikely), there's a couple of errors in your code involving 
> indexing. Once fixed, the code demonstrates some errors in your use of 
> HSD.test that will be harder for you to deal with.
>
> Thanks for the complete reproducible example.
>
> fun2 <- function (x)
>
> {
>
> trait_names <- c("yield", "lp", "lnth")
>
> d = data.frame(yield = rep(0, 6), lp = rep(0, 6), lnth = rep(0,
>
> 6))
>
> for (i in trait_names) {
> # your formula has all the trait names, not the selected one
> # mod <- aov(formula(paste(trait_names, "~ PEDIGREE + FIELD + 
> PEDIGREE*FIELD + FIELD%in%REP")), data = x)
> mod <- aov(formula(paste(i, "~ PEDIGREE + FIELD + PEDIGREE*FIELD + 
> FIELD%in%REP")), data = x)
>
> out <- HSD.test(mod, "PEDIGREE", group = TRUE, console = FALSE)
>
> # you're indexing by the trait name, instead of its position
> # d[, i] <- out$means[, 1]
> d[, which(trait_names == i)] <- out$means[, 1]
>
> }
>
> d
>
> }
>
> Sarah
>
> On Tue, Jan 5, 2016 at 11:48 AM, DIGHE, NILESH [AG/2362] 
>  wrote:
>> Dear R users:
>>
>> I am trying to create a function that will loop over three dependent 
>> variables in my aov model, and then get the HSD.test for each variable.  I 
>> like to store the results from each loop in a data frame.
>>
>>
>>
>> When I run my function (funx) on my data (dat), results from only yield gets 
>> populated in all three columns of the dataframe.  I am not able to store the 
>> results for each variable in a dataframe. Any help will be highly 
>> appreciated.
>>
>>
>>
>>
>>
>>
>>
>> function (x)
>>
>> {
>>
>> trait_names <- c("yield", "lp", "lnth")
>>
>> d = data.frame(yield = rep(0, 6), lp = rep(0, 6), lnth = rep(0,
>>
>> 6))
>>
>> for (i in trait_names) {
>>
>> mod <- aov(formula(paste(trait_names, "~ PEDIGREE + FIELD +
>> PEDIGREE*FIELD + FIELD%in%REP")),
>>
>> data = x)
>>
>> out <- HSD.test(mod, "PEDIGREE", group = TRUE, console =
>> FALSE)
>>
>> d[, i] <- out$means[, 1]
>>
>> }
>>
>> d
>>
>> }
>>
>>
>> structure(list(FIELD = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
>> 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
>> 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L,
>> 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 4L, 4L, 4L, 4L, 4L, 4L,
>> 4L, 4L, 4L, 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, 6L, 6L, 1L, 1L, 1L,
>> 2L, 2L, 2L, 3L, 3L, 3L, 4L, 4L, 4L, 5L, 5L, 5L, 6L, 6L, 6L, 1L, 1L,
>> 1L, 2L, 2L, 2L, 3L, 3L, 3L, 4L, 4L, 4L, 5L, 5L, 5L, 6L, 6L, 6L),
>> .Label = c("A", "B", "C", "D", "E", "F"), class = "factor"), yield =
>> c(1003L, 923L, 1268L, 1226L, 1059L, 1150L, 900L, 816L, 1072L, 1158L,
>> 1026L, 1299L, 1083L, 1038L, 1236L, 1287L, 1270L, 1612L, 1513L, 1676L,
>> 1504L, 1417L, 1932L, 1644L, 

Re: [R] R package built using newer version of R

2016-01-05 Thread Tyler Auerbeck
When I run the install.packages("rj",type="source") I get the following:

> install.packages("rj",type="source")
Warning message:
package ‘rj’ is not available (for R version 2.15.1)

I believe this is because this is a package available directly from the
creators of StatET. I tried pulling the zip down directly from their
website and ran the following:

>
install.packages("C:\\users\\admin\\Downloads\\rj_2.0.3-1.zip",type="source",repos=NULL)
package 'rj' successfully unpacked and MD5 sums checked

This installs it directly, but it still installs it as compiled for 2.15.3,
which we see the same warning I originally mentioned.

Here is the sessionInfo() you asked for:

> sessionInfo()
R version 2.15.1 (2012-06-22)
Platform: x86_64-pc-mingw32/x64 (64-bit)

locale:
[1] LC_COLLATE=English_United States.1252  LC_CTYPE=English_United
States.1252LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C   LC_TIME=English_United
States.1252

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

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


If there isn't a good way to compile this for 2.15.1, is there any way to
just ignore the warning? I've seen that you can do something like

options( warn = -1 )

I know this isn't recommended to do on an extended timeframe, but this
message only occurs during the first command that you run. Even if we
could set up some sort of profile that would set this suppression, run
a dummy command and then unset the suppression. I know this is a
workaround, but I just wasn't sure what would be the simpler solution.

Let me know what you think or what I may be missing.

On Tue, Jan 5, 2016 at 3:41 AM, Harrie Robins  wrote:

> If that fails (sometimes R gives a version error, package not available for
> R version X.X.X), you could try downloading the source package
> (package.tar.gz) and compile it with running from console (or prompt):
>
> R CMD INSTALL packagename.tar.gz library-location
>
> Regards,
>
> Harrie
>
> -Original Message-
> From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Duncan
> Murdoch
> Sent: maandag 4 januari 2016 20:16
> To: Tyler Auerbeck ; r-help@r-project.org
> Subject: Re: [R] R package built using newer version of R
>
> On 04/01/2016 2:02 PM, Tyler Auerbeck wrote:
> > We're currently looking at using the R eclipse plugin StatET as our
> > development environment. Due to certain requirements, we're still
> > using 2.15.1. However a required package of StatET was built using
> > 2.15.3, which results in the following warning:
> >
> > Warning message:
> > package 'rj' was built under R version 2.15.3
> >
> > I'm still fairly new to R, but is there any way for us to rebuild this
> > package using 2.15.1? It doesn't appear to cause us any issues, but
> > it's still not desirable for users to see that warning.
> >
> > Any help would be appreciated.
>
> Yes, it's quite easy to do so.  StatET probably gives menu options to do
> it,
> but I don't know them:  you might want to ask them.  From the R console,
> try
>
> install.packages("pkgname", type="source")
>
> and if you have the necessary prerequisites (e.g. compilers), you'll get
> it installed from source.   If it fails, post the errors and the results
> of sessionInfo() here, and we'll probably be able to tell you what to do
> next.
>
> 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.
>
>

[[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] store results from loop into a dataframe

2016-01-05 Thread DIGHE, NILESH [AG/2362]
Sarah:  Thanks a lot for taking time to guide me to the right direction.  I now 
see how the missing data is causing the problem.
Thanks again!
Nilesh

-Original Message-
From: Sarah Goslee [mailto:sarah.gos...@gmail.com] 
Sent: Tuesday, January 05, 2016 12:13 PM
To: DIGHE, NILESH [AG/2362]
Cc: r-help@r-project.org
Subject: Re: [R] store results from loop into a dataframe

If you run each variable individually, you'll discover that the NAs in your 
data are causing problems. It's up to you to figure out what the best way to 
handle those missing values for your research is.

Sarah

On Tue, Jan 5, 2016 at 12:39 PM, DIGHE, NILESH [AG/2362] 
 wrote:
> Sarah: Thanks for pointing out the errors in my function.
>
> Below are the errors I am getting after I run the corrected quote:
> Error in if (s) { : missing value where TRUE/FALSE needed In addition: 
> Warning message:
> In qtukey(1 - alpha, ntr, DFerror) : NaNs produced
>
> You are right, I have no idea to handle these errors.
>
> Do you recommend any other approach to solve my problem?
>
> Thanks for your time.
> Nilesh
>
>
>
> -Original Message-
> From: Sarah Goslee [mailto:sarah.gos...@gmail.com]
> Sent: Tuesday, January 05, 2016 11:20 AM
> To: DIGHE, NILESH [AG/2362]
> Cc: r-help@r-project.org
> Subject: Re: [R] store results from loop into a dataframe
>
> Leaving aside the question of whether this is the best way to approach your 
> problem (unlikely), there's a couple of errors in your code involving 
> indexing. Once fixed, the code demonstrates some errors in your use of 
> HSD.test that will be harder for you to deal with.
>
> Thanks for the complete reproducible example.
>
> fun2 <- function (x)
>
> {
>
> trait_names <- c("yield", "lp", "lnth")
>
> d = data.frame(yield = rep(0, 6), lp = rep(0, 6), lnth = rep(0,
>
> 6))
>
> for (i in trait_names) {
> # your formula has all the trait names, not the selected one
> # mod <- aov(formula(paste(trait_names, "~ PEDIGREE + FIELD + 
> PEDIGREE*FIELD + FIELD%in%REP")), data = x)
> mod <- aov(formula(paste(i, "~ PEDIGREE + FIELD + 
> PEDIGREE*FIELD + FIELD%in%REP")), data = x)
>
> out <- HSD.test(mod, "PEDIGREE", group = TRUE, console = 
> FALSE)
>
> # you're indexing by the trait name, instead of its position
> # d[, i] <- out$means[, 1]
> d[, which(trait_names == i)] <- out$means[, 1]
>
> }
>
> d
>
> }
>
> Sarah
>
> On Tue, Jan 5, 2016 at 11:48 AM, DIGHE, NILESH [AG/2362] 
>  wrote:
>> Dear R users:
>>
>> I am trying to create a function that will loop over three dependent 
>> variables in my aov model, and then get the HSD.test for each variable.  I 
>> like to store the results from each loop in a data frame.
>>
>>
>>
>> When I run my function (funx) on my data (dat), results from only yield gets 
>> populated in all three columns of the dataframe.  I am not able to store the 
>> results for each variable in a dataframe. Any help will be highly 
>> appreciated.
>>
>>
>>
>>
>>
>>
>>
>> function (x)
>>
>> {
>>
>> trait_names <- c("yield", "lp", "lnth")
>>
>> d = data.frame(yield = rep(0, 6), lp = rep(0, 6), lnth = rep(0,
>>
>> 6))
>>
>> for (i in trait_names) {
>>
>> mod <- aov(formula(paste(trait_names, "~ PEDIGREE + FIELD + 
>> PEDIGREE*FIELD + FIELD%in%REP")),
>>
>> data = x)
>>
>> out <- HSD.test(mod, "PEDIGREE", group = TRUE, console =
>> FALSE)
>>
>> d[, i] <- out$means[, 1]
>>
>> }
>>
>> d
>>
>> }
>>
>>
>> structure(list(FIELD = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 
>> 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 
>> 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 
>> 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 4L, 4L, 4L, 4L, 4L, 
>> 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 5L, 5L, 5L, 5L, 
>> 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 6L, 6L, 6L, 
>> 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L), .Label = 
>> c("FYLS", "HKI1", "KIS1", "LMLS", "SELS", "SGL1"), class = "factor"), 
>> REP = structure(c(1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 
>> 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 
>> 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 
>> 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 
>> 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 
>> 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 
>> 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L), .Label = c("1", "2", "3"), 
>> class = "factor"), PEDIGREE = structure(c(1L, 1L, 1L, 2L, 2L, 2L, 3L, 
>> 3L, 3L, 4L, 4L, 4L, 5L, 5L, 5L, 6L, 6L, 6L, 1L, 1L, 1L, 2L, 2L, 2L, 
>> 3L, 3L, 3L, 4L, 4L, 4L, 5L, 5L, 5L, 6L, 6L, 6L, 1L, 1L, 1L, 2L, 2L, 
>> 2L, 3L, 3L, 3L, 4L, 4L, 4L, 5L, 5L, 5L, 6L, 6L, 6L, 1L, 1L, 1L, 2L, 
>> 2L, 2L, 3L, 3L, 3L, 4L, 4L, 4L, 5L, 5L, 5L, 6L, 

Re: [R] R package built using newer version of R

2016-01-05 Thread David Winsemius

> On Jan 5, 2016, at 11:15 AM, Tyler Auerbeck  wrote:
> 
> When I run the install.packages("rj",type="source") I get the following:
> 
>> install.packages("rj",type="source")
> Warning message:
> package ‘rj’ is not available (for R version 2.15.1)
> 
> I believe this is because this is a package available directly from the
> creators of StatET. I tried pulling the zip down directly from their
> website and ran the following:
> 
>> 
> install.packages("C:\\users\\admin\\Downloads\\rj_2.0.3-1.zip",type="source",repos=NULL)
> package 'rj' successfully unpacked and MD5 sums checked

Despite the your "source" for the type parameter, you still gave it a Windows 
binary file. This is the place to get a source version of rj-2.0.3-1:

http://download.walware.de/rj-2.0/src/contrib/rj_2.0.3-2.tar.gz

-- 
David.


> 
> This installs it directly, but it still installs it as compiled for 2.15.3,
> which we see the same warning I originally mentioned.
> 
> Here is the sessionInfo() you asked for:
> 
>> sessionInfo()
> R version 2.15.1 (2012-06-22)
> Platform: x86_64-pc-mingw32/x64 (64-bit)
> 
> locale:
> [1] LC_COLLATE=English_United States.1252  LC_CTYPE=English_United
> States.1252LC_MONETARY=English_United States.1252
> [4] LC_NUMERIC=C   LC_TIME=English_United
> States.1252
> 
> attached base packages:
> [1] stats graphics  grDevices utils datasets  methods   base
> 
> loaded via a namespace (and not attached):
> [1] tools_2.15.1
> 
> 
> If there isn't a good way to compile this for 2.15.1, is there any way to
> just ignore the warning? I've seen that you can do something like
> 
> options( warn = -1 )
> 
> I know this isn't recommended to do on an extended timeframe, but this
> message only occurs during the first command that you run. Even if we
> could set up some sort of profile that would set this suppression, run
> a dummy command and then unset the suppression. I know this is a
> workaround, but I just wasn't sure what would be the simpler solution.
> 
> Let me know what you think or what I may be missing.
> 
> On Tue, Jan 5, 2016 at 3:41 AM, Harrie Robins  wrote:
> 
>> If that fails (sometimes R gives a version error, package not available for
>> R version X.X.X), you could try downloading the source package
>> (package.tar.gz) and compile it with running from console (or prompt):
>> 
>> R CMD INSTALL packagename.tar.gz library-location
>> 
>> Regards,
>> 
>> Harrie
>> 
>> -Original Message-
>> From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Duncan
>> Murdoch
>> Sent: maandag 4 januari 2016 20:16
>> To: Tyler Auerbeck ; r-help@r-project.org
>> Subject: Re: [R] R package built using newer version of R
>> 
>> On 04/01/2016 2:02 PM, Tyler Auerbeck wrote:
>>> We're currently looking at using the R eclipse plugin StatET as our
>>> development environment. Due to certain requirements, we're still
>>> using 2.15.1. However a required package of StatET was built using
>>> 2.15.3, which results in the following warning:
>>> 
>>> Warning message:
>>> package 'rj' was built under R version 2.15.3
>>> 
>>> I'm still fairly new to R, but is there any way for us to rebuild this
>>> package using 2.15.1? It doesn't appear to cause us any issues, but
>>> it's still not desirable for users to see that warning.
>>> 
>>> Any help would be appreciated.
>> 
>> Yes, it's quite easy to do so.  StatET probably gives menu options to do
>> it,
>> but I don't know them:  you might want to ask them.  From the R console,
>> try
>> 
>> install.packages("pkgname", type="source")
>> 
>> and if you have the necessary prerequisites (e.g. compilers), you'll get
>> it installed from source.   If it fails, post the errors and the results
>> of sessionInfo() here, and we'll probably be able to tell you what to do
>> next.
>> 
>> 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.
>> 
>> 
> 
>   [[alternative HTML version deleted]]
> 
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

David Winsemius
Alameda, CA, USA

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

[R] Bezier to line segments

2016-01-05 Thread Adrian Dușa
Dear All,

I am interested into transforming Bezier curves (or general splines) to a
series of line segments.
For simplicity, the Bezier curves are either cubic (arches, no inflection
points) or they have at most one inflection point.

The entry parameters are exactly four points (with x and y coordinates):
- start point
- end point
- and two control points to define the curve.

I read a lot about parabolic approximation, and there is also a famous
deCasteljau algorithm.

Before attempting to create my own function, I wonder if something like
this already exists in R (or can easily be adapted to R).

Thanks in advance for any hint,
Adrian

-- 
Adrian Dusa
University of Bucharest
Romanian Social Data Archive
Soseaua Panduri nr.90
050663 Bucharest sector 5
Romania

[[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] R package built using newer version of R

2016-01-05 Thread Tyler Auerbeck
Alright, I believe I'm making some progress. I'm now running into the
following error. As I mentioned, I'm new to this whole process, so this may
be something simple. When I run the following:

R.exe CMD INSTALL rj_2.0.3-1.tar.gz

I get the following error:

C:\users\admin\> R.exe CMD INSTALL rj_2.0.3-1.tar.gz
* installing to library 'C:/Program Files/R/R-2.15.1/library'
* installing *source* package 'rj' ...
/bin/sh: h.exe: No such file or directory
ERROR: configuration failed for package 'rj'

In case I hadn't mentioned, I am attempting to do all of this on windows. I
had looked around a little more and noticed that there is a lot of mention
of installing Rtools on the machine as well and making sure certain bin
directories are added to the path. I've ensured the following directories
were added to my path:

C:\Program Files\R\R-2.15.1\bin\x64;
C:\Program Files\R\Rtools\bin
;C:\Program Files\R\Rtools\gcc-4.6.3\bin;
C:\Program Files\R\Rtools\gcc-4.6.3\bin64;
C:\Program Files\R\Rtools\gcc-4.6.3\i686-w64-mingw32\bin

Is there anything that I may be missing that is required. I see the main
problem is that it can't seem to locate h.exe. Is there something I need to
pull down that would provide this? Do I need to add something to my path in
order for the install to find this?

As always, any help would be greatly appreciated.

On Tue, Jan 5, 2016 at 2:34 PM, David Winsemius 
wrote:

>
> > On Jan 5, 2016, at 11:15 AM, Tyler Auerbeck 
> wrote:
> >
> > When I run the install.packages("rj",type="source") I get the following:
> >
> >> install.packages("rj",type="source")
> > Warning message:
> > package ‘rj’ is not available (for R version 2.15.1)
> >
> > I believe this is because this is a package available directly from the
> > creators of StatET. I tried pulling the zip down directly from their
> > website and ran the following:
> >
> >>
> >
> install.packages("C:\\users\\admin\\Downloads\\rj_2.0.3-1.zip",type="source",repos=NULL)
> > package 'rj' successfully unpacked and MD5 sums checked
>
> Despite the your "source" for the type parameter, you still gave it a
> Windows binary file. This is the place to get a source version of
> rj-2.0.3-1:
>
> http://download.walware.de/rj-2.0/src/contrib/rj_2.0.3-2.tar.gz
>
> --
> David.
>
>
> >
> > This installs it directly, but it still installs it as compiled for
> 2.15.3,
> > which we see the same warning I originally mentioned.
> >
> > Here is the sessionInfo() you asked for:
> >
> >> sessionInfo()
> > R version 2.15.1 (2012-06-22)
> > Platform: x86_64-pc-mingw32/x64 (64-bit)
> >
> > locale:
> > [1] LC_COLLATE=English_United States.1252  LC_CTYPE=English_United
> > States.1252LC_MONETARY=English_United States.1252
> > [4] LC_NUMERIC=C   LC_TIME=English_United
> > States.1252
> >
> > attached base packages:
> > [1] stats graphics  grDevices utils datasets  methods   base
> >
> > loaded via a namespace (and not attached):
> > [1] tools_2.15.1
> >
> >
> > If there isn't a good way to compile this for 2.15.1, is there any way to
> > just ignore the warning? I've seen that you can do something like
> >
> > options( warn = -1 )
> >
> > I know this isn't recommended to do on an extended timeframe, but this
> > message only occurs during the first command that you run. Even if we
> > could set up some sort of profile that would set this suppression, run
> > a dummy command and then unset the suppression. I know this is a
> > workaround, but I just wasn't sure what would be the simpler solution.
> >
> > Let me know what you think or what I may be missing.
> >
> > On Tue, Jan 5, 2016 at 3:41 AM, Harrie Robins 
> wrote:
> >
> >> If that fails (sometimes R gives a version error, package not available
> for
> >> R version X.X.X), you could try downloading the source package
> >> (package.tar.gz) and compile it with running from console (or prompt):
> >>
> >> R CMD INSTALL packagename.tar.gz library-location
> >>
> >> Regards,
> >>
> >> Harrie
> >>
> >> -Original Message-
> >> From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Duncan
> >> Murdoch
> >> Sent: maandag 4 januari 2016 20:16
> >> To: Tyler Auerbeck ; r-help@r-project.org
> >> Subject: Re: [R] R package built using newer version of R
> >>
> >> On 04/01/2016 2:02 PM, Tyler Auerbeck wrote:
> >>> We're currently looking at using the R eclipse plugin StatET as our
> >>> development environment. Due to certain requirements, we're still
> >>> using 2.15.1. However a required package of StatET was built using
> >>> 2.15.3, which results in the following warning:
> >>>
> >>> Warning message:
> >>> package 'rj' was built under R version 2.15.3
> >>>
> >>> I'm still fairly new to R, but is there any way for us to rebuild this
> >>> package using 2.15.1? It doesn't appear to cause us any issues, but
> >>> it's still not desirable for users to see that warning.
> >>>
> >>> Any help would 

Re: [R] R package built using newer version of R

2016-01-05 Thread Tyler Auerbeck
We can go ahead and ignore that last email. It looks like I had just
configured Rtools incorrectly. Once I resolved that issue I was able to get
this compiled appropriately. Thanks to everyone for the help!

On Wed, Jan 6, 2016 at 1:34 AM, Tyler Auerbeck  wrote:

> Alright, I believe I'm making some progress. I'm now running into the
> following error. As I mentioned, I'm new to this whole process, so this may
> be something simple. When I run the following:
>
> R.exe CMD INSTALL rj_2.0.3-1.tar.gz
>
> I get the following error:
>
> C:\users\admin\> R.exe CMD INSTALL rj_2.0.3-1.tar.gz
> * installing to library 'C:/Program Files/R/R-2.15.1/library'
> * installing *source* package 'rj' ...
> /bin/sh: h.exe: No such file or directory
> ERROR: configuration failed for package 'rj'
>
> In case I hadn't mentioned, I am attempting to do all of this on windows.
> I had looked around a little more and noticed that there is a lot of
> mention of installing Rtools on the machine as well and making sure certain
> bin directories are added to the path. I've ensured the following
> directories were added to my path:
>
> C:\Program Files\R\R-2.15.1\bin\x64;
> C:\Program Files\R\Rtools\bin
> ;C:\Program Files\R\Rtools\gcc-4.6.3\bin;
> C:\Program Files\R\Rtools\gcc-4.6.3\bin64;
> C:\Program Files\R\Rtools\gcc-4.6.3\i686-w64-mingw32\bin
>
> Is there anything that I may be missing that is required. I see the main
> problem is that it can't seem to locate h.exe. Is there something I need to
> pull down that would provide this? Do I need to add something to my path in
> order for the install to find this?
>
> As always, any help would be greatly appreciated.
>
> On Tue, Jan 5, 2016 at 2:34 PM, David Winsemius 
> wrote:
>
>>
>> > On Jan 5, 2016, at 11:15 AM, Tyler Auerbeck 
>> wrote:
>> >
>> > When I run the install.packages("rj",type="source") I get the following:
>> >
>> >> install.packages("rj",type="source")
>> > Warning message:
>> > package ‘rj’ is not available (for R version 2.15.1)
>> >
>> > I believe this is because this is a package available directly from the
>> > creators of StatET. I tried pulling the zip down directly from their
>> > website and ran the following:
>> >
>> >>
>> >
>> install.packages("C:\\users\\admin\\Downloads\\rj_2.0.3-1.zip",type="source",repos=NULL)
>> > package 'rj' successfully unpacked and MD5 sums checked
>>
>> Despite the your "source" for the type parameter, you still gave it a
>> Windows binary file. This is the place to get a source version of
>> rj-2.0.3-1:
>>
>> http://download.walware.de/rj-2.0/src/contrib/rj_2.0.3-2.tar.gz
>>
>> --
>> David.
>>
>>
>> >
>> > This installs it directly, but it still installs it as compiled for
>> 2.15.3,
>> > which we see the same warning I originally mentioned.
>> >
>> > Here is the sessionInfo() you asked for:
>> >
>> >> sessionInfo()
>> > R version 2.15.1 (2012-06-22)
>> > Platform: x86_64-pc-mingw32/x64 (64-bit)
>> >
>> > locale:
>> > [1] LC_COLLATE=English_United States.1252  LC_CTYPE=English_United
>> > States.1252LC_MONETARY=English_United States.1252
>> > [4] LC_NUMERIC=C   LC_TIME=English_United
>> > States.1252
>> >
>> > attached base packages:
>> > [1] stats graphics  grDevices utils datasets  methods   base
>> >
>> > loaded via a namespace (and not attached):
>> > [1] tools_2.15.1
>> >
>> >
>> > If there isn't a good way to compile this for 2.15.1, is there any way
>> to
>> > just ignore the warning? I've seen that you can do something like
>> >
>> > options( warn = -1 )
>> >
>> > I know this isn't recommended to do on an extended timeframe, but this
>> > message only occurs during the first command that you run. Even if we
>> > could set up some sort of profile that would set this suppression, run
>> > a dummy command and then unset the suppression. I know this is a
>> > workaround, but I just wasn't sure what would be the simpler solution.
>> >
>> > Let me know what you think or what I may be missing.
>> >
>> > On Tue, Jan 5, 2016 at 3:41 AM, Harrie Robins 
>> wrote:
>> >
>> >> If that fails (sometimes R gives a version error, package not
>> available for
>> >> R version X.X.X), you could try downloading the source package
>> >> (package.tar.gz) and compile it with running from console (or prompt):
>> >>
>> >> R CMD INSTALL packagename.tar.gz library-location
>> >>
>> >> Regards,
>> >>
>> >> Harrie
>> >>
>> >> -Original Message-
>> >> From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Duncan
>> >> Murdoch
>> >> Sent: maandag 4 januari 2016 20:16
>> >> To: Tyler Auerbeck ; r-help@r-project.org
>> >> Subject: Re: [R] R package built using newer version of R
>> >>
>> >> On 04/01/2016 2:02 PM, Tyler Auerbeck wrote:
>> >>> We're currently looking at using the R eclipse plugin StatET as our
>> >>> development environment. Due to certain requirements, we're still
>> >>> using 

Re: [R] (no subject)

2016-01-05 Thread Dimitri Liakhovitski
Jean and Dennis, thank you so much for your solutions!
They are super-fast, thanks a lot!
Happy new year!
Dimitri

On Thu, Dec 24, 2015 at 2:50 PM, Adams, Jean  wrote:
> Excellent job providing example data and a desired result.
>
> This code works on the example you provided.  Hope it helps.
>
> Jean
>
> # reshape the info data frame
> library(tidyr)
> info2 <- gather(myinfo, set, val, -game)
> info2$set <- as.numeric(gsub("[[:alpha:]]", "", info2$set))
>
> # add a new column to the x data frame
> y <- t(x[,grep("char", names(x))])
> newx <- x
> newx$char <- row(y)[y==1]
>
> # merge and define winner
> res <- merge(newx, info2)
> res$winner <- with(res, ifelse(char==val, 1, 0))
> res
>
>
> On Wed, Dec 23, 2015 at 3:35 PM, Dimitri Liakhovitski
>  wrote:
>>
>> Merry upcoming Christmas - for those of us who celebrate it!
>>
>> # I have data frame x.
>> x <- data.frame(game = c(rep(1, 4), rep(2, 4)), set = rep(c(1,1,2,2),
>> 2), player = rep(1:2, 4),
>> char1 = c(1,0,0,0,0,0,0,1), char2 =
>> c(0,0,1,0,0,1,0,0), char3 = c(0,1,0,1,0,0,0,0),
>> char4 = c(0,0,0,0,1,0,1,0))
>> x
>> # There are several games (2 here). Each game has several sets (2
>> here. In each set participate
>> # several players (2 here).
>> # Each player possesses 1 or 4 possible characteristics.
>> # For example, in game 1, set 1, player 1 has characteristic 1 and player
>> 2 -
>> # characteristic 3
>>
>> # I also have data frame myinfo:
>> (myinfo <- data.frame(game = 1:2, set1 = c(3, 4), set2 = c(2, 1)))
>> # It tells me:
>> # in game 1, set 1 the winner was the player with characteristic 3
>> # in game 1, set 2 the winner was the player with characteristic 2, etc.
>>
>> # I need to merge the 2 to produce the result below.
>> # I just need an additional column that - for each game and each set -
>> # has a 1 in the row of the player who had the winning characteristic
>> # (as per myinfo) and has a 0 otherwise.
>>
>> result <- x
>> result$winner <- c(0, 1, 1, 0, 1, 0, 0, 1)
>> result
>>
>> # I have written a long loop that loops through each set of each game,
>> identifies
>> # which characteristic wins in myinfo, and puts a 1 against the winning
>> row.
>> # But it's taking forever. Could it be done faster? Thanks a lot!
>>
>> # Important: In my real game the number of players could be more than
>> 2 and so can
>> # the number of games and the number of sets per game.
>> # However, we can assume that the number of sets per game is always the
>> same,
>> # and the number of players per set is always the same.
>>
>>
>> --
>> Dimitri Liakhovitski
>>
>> __
>> 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.
>
>



-- 
Dimitri Liakhovitski

__
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] SNG uz malo regresije

2016-01-05 Thread Petar Milin

> On Jan 5, 2016, at 12:01 PM, Bojana Dinic  wrote:
> 
> najpre, srecna Nova godina i sve najbolje tbi i tvojoj porodici. Nadam se da 
> ces se za praznike lepo odmoriti.
> Mene su vec zadesile neke obaveze, pa sam htela da te pitam da li znas neki 
> paket, makro, algoritam ili nesto slicno za hijerarhijsku ridge regresiju, 
> ili za hijerarhijski random forest, gde moze da se ubaci vise seta 
> prediktora? 

Zdravo Bojana!
Najlepse ti hvala! I ja tebi zelim sve naj naj naj! :-)

Sto se tice tvog pitanja, ne umem da ti odgovorim — ne znam mnogo o ridge 
regresiji, tj. ne koristim je cesto i nisam imao potrebe za necim 
sofisticiranim. Takodje, ne znam ni za hijerarhijski RF. Koristim obicni i 
mislim da i ne postoji mogucnost da se uvedu slucajni efekti. Koristim 
randomForest iz istoimenog paketa i cforest iz party paketa.

Mozda bi mogla da postavis pitanje na R-HELP listi > ili na http://stackoverflow.com/ 
 ? Na oba, naravno, moras da se prijavis.


PS: Nikako da ti pisem i da te pitam zbog cega je i kako ispao problem s 
Platonom i testiranjem instrumenta? Ja sam to tebi uredno prijavio. Istina, 
mnogo davno (mislim u maju-junu). Takodje, prijavio sam i Miladinu i poslao 
zahtev u dekanat. To se sve desavalo krajem juna, pocetkom jula. Jedina greska 
je do toga sto je Platon to odradio mnogo kasnije od planiranog. Ja sam cak i 
odustao od toga da ce se bilo sta realizovati, pa sam i zaboravio… Ispalo je da 
ti nisi nista znala, pa si digla paniku, pa ja (ponovo i ponovo) dobio po nosu… 
Malko mi dosadilo… (da dobijam po nosu ako se nesto (u)radi)… :-)

Pozdrav,
P



===
Eberhard Karls Universität Tübingen
Seminar für Sprachwissenschaft | Quantitative Linguistik
http://www.sfs.uni-tuebingen .de/~pmilin/




[[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] R Course in Dublin (February 3rd-5th)

2016-01-05 Thread Antony Unwin
The course will be given by Louis Aslett (Oxford University, author of the 
packages PhaseType and ReliabilityTheory) and Antony Unwin (author of the book 
“Graphical Data Analysis with R” CRC Press 2015).

Details at  

http://insightsc.ie/training/r-statistical-software/ 


Antony Unwin
University of Augsburg, Germany and Insight Statistical Consulting, Dublin, 
Ireland
[[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.