Re: [R] tidyquant error downloading symbols for Index

2017-08-06 Thread David Winsemius

> On Aug 6, 2017, at 5:10 PM, Sparks, John James  wrote:
> 
> Hi R Helpers,
> 
> I recently tried to take advantage of the ability to download all the
> tickers in the S 500 using the functionality of tidyquant, but it threw
> an error.
> 
> For summary, the set of commands that I ran was
> 
> library(tidyquant)
> tq_index_options()
> tq_index("SP500")
> sessionInfo()
> 
> 
> R feedback including error message and sessionInfo are provided below.
> 
> Guidance would be appreciated.
> 
> --John J. Sparks, Ph.D.
> 
> 
>> library(tidyquant)
> Loading required package: lubridate
> 
> Attaching package: ‘lubridate’
> 
> The following object is masked from ‘package:base’:
> 
>date
> 
> Loading required package: PerformanceAnalytics
> Loading required package: xts
> Loading required package: zoo
> 
> Attaching package: ‘zoo’
> 
> The following objects are masked from ‘package:base’:
> 
>as.Date, as.Date.numeric
> 
> 
> Package PerformanceAnalytics (1.4.3541) loaded.
> Copyright (c) 2004-2014 Peter Carl and Brian G. Peterson, GPL-2 | GPL-3
> http://r-forge.r-project.org/projects/returnanalytics/
> 
> 
> Attaching package: ‘PerformanceAnalytics’
> 
> The following object is masked from ‘package:graphics’:
> 
>legend
> 
> Loading required package: quantmod
> Loading required package: TTR
> Version 0.4-0 included new data defaults. See ?getSymbols.
> Learn from a quantmod author:
> https://www.datacamp.com/courses/importing-and-managing-financial-data-in-r
> Loading required package: tidyverse
> Loading tidyverse: ggplot2
> Loading tidyverse: tibble
> Loading tidyverse: tidyr
> Loading tidyverse: readr
> Loading tidyverse: purrr
> Loading tidyverse: dplyr
> Conflicts with tidy packages
> -
> as.difftime(): lubridate, base
> date():lubridate, base
> filter():  dplyr, stats
> first():   dplyr, xts
> intersect():   lubridate, base
> lag(): dplyr, stats
> last():dplyr, xts
> setdiff(): lubridate, base
> union():   lubridate, base
> 
> Attaching package: ‘tidyquant’
> 
> The following object is masked from ‘package:dplyr’:
> 
>as_tibble
> 
> The following object is masked from ‘package:tibble’:
> 
>as_tibble
> 
> There were 14 warnings (use warnings() to see them)
>> tq_index_options()
> [1] "RUSSELL1000" "RUSSELL2000" "RUSSELL3000" "DOW" "DOWGLOBAL"
> [6] "SP400"   "SP500"   "SP600"   "SP1000"
>> tq_index("SP500")
> Getting holdings for SP500
> # A tibble: 0 x 0
> Warning message:
> In tq_index("SP500") : Error at SP500 during download.
> Error: .onLoad failed in loadNamespace() for 'rJava', details:
>  call: fun(libname, pkgname)
>  error: No CurrentVersion entry in Software/JavaSoft registry! Try
> re-installing Java and make sure R and Java have matching architectures.

Looks like your Java installation is not correct. Unfortunately I see no 
details that would support commentary on this question. Googling with that 
error message test brings up quite o bit of material.

-- 
David.
> 
>> sessionInfo()
> R version 3.3.2 (2016-10-31)
> Platform: x86_64-w64-mingw32/x64 (64-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] tidyquant_0.5.3   dplyr_0.7.2
> [3] purrr_0.2.3   readr_1.1.1
> [5] tidyr_0.6.3   tibble_1.3.3
> [7] ggplot2_2.2.1 tidyverse_1.1.1
> [9] quantmod_0.4-10   TTR_0.23-2
> [11] PerformanceAnalytics_1.4.3541 xts_0.10-0
> [13] zoo_1.8-0 lubridate_1.6.0
> 
> loaded via a namespace (and not attached):
> [1] Rcpp_0.12.12 cellranger_1.1.0 plyr_1.8.4   bindr_0.1
> [5] forcats_0.2.0tools_3.3.2  jsonlite_1.5 nlme_3.1-131
> [9] gtable_0.2.0 lattice_0.20-35  pkgconfig_2.0.1  rlang_0.1.1
> [13] psych_1.7.5  curl_2.8.1   parallel_3.3.2   haven_1.1.0
> [17] bindrcpp_0.2 xml2_1.1.1   httr_1.2.1   stringr_1.2.0
> [21] hms_0.3  grid_3.3.2   glue_1.1.1   R6_2.2.2
> [25] Quandl_2.8.0 readxl_1.0.0 foreign_0.8-69   modelr_0.1.1
> [29] reshape2_1.4.2   magrittr_1.5 scales_0.4.1 rvest_0.3.2
> [33] assertthat_0.2.0 mnormt_1.5-5 colorspace_1.3-2 stringi_1.1.5
> [37] lazyeval_0.2.0   munsell_0.4.3broom_0.4.2
> 
> __
> 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] tidyquant error downloading symbols for Index

2017-08-06 Thread Sparks, John James
Hi R Helpers,

I recently tried to take advantage of the ability to download all the
tickers in the S 500 using the functionality of tidyquant, but it threw
an error.

For summary, the set of commands that I ran was

library(tidyquant)
tq_index_options()
tq_index("SP500")
sessionInfo()


R feedback including error message and sessionInfo are provided below.

Guidance would be appreciated.

--John J. Sparks, Ph.D.


> library(tidyquant)
Loading required package: lubridate

Attaching package: ‘lubridate’

The following object is masked from ‘package:base’:

date

Loading required package: PerformanceAnalytics
Loading required package: xts
Loading required package: zoo

Attaching package: ‘zoo’

The following objects are masked from ‘package:base’:

as.Date, as.Date.numeric


Package PerformanceAnalytics (1.4.3541) loaded.
Copyright (c) 2004-2014 Peter Carl and Brian G. Peterson, GPL-2 | GPL-3
http://r-forge.r-project.org/projects/returnanalytics/


Attaching package: ‘PerformanceAnalytics’

The following object is masked from ‘package:graphics’:

legend

Loading required package: quantmod
Loading required package: TTR
Version 0.4-0 included new data defaults. See ?getSymbols.
Learn from a quantmod author:
https://www.datacamp.com/courses/importing-and-managing-financial-data-in-r
Loading required package: tidyverse
Loading tidyverse: ggplot2
Loading tidyverse: tibble
Loading tidyverse: tidyr
Loading tidyverse: readr
Loading tidyverse: purrr
Loading tidyverse: dplyr
Conflicts with tidy packages
-
as.difftime(): lubridate, base
date():lubridate, base
filter():  dplyr, stats
first():   dplyr, xts
intersect():   lubridate, base
lag(): dplyr, stats
last():dplyr, xts
setdiff(): lubridate, base
union():   lubridate, base

Attaching package: ‘tidyquant’

The following object is masked from ‘package:dplyr’:

as_tibble

The following object is masked from ‘package:tibble’:

as_tibble

There were 14 warnings (use warnings() to see them)
> tq_index_options()
[1] "RUSSELL1000" "RUSSELL2000" "RUSSELL3000" "DOW" "DOWGLOBAL"
[6] "SP400"   "SP500"   "SP600"   "SP1000"
> tq_index("SP500")
Getting holdings for SP500
# A tibble: 0 x 0
Warning message:
In tq_index("SP500") : Error at SP500 during download.
Error: .onLoad failed in loadNamespace() for 'rJava', details:
  call: fun(libname, pkgname)
  error: No CurrentVersion entry in Software/JavaSoft registry! Try
re-installing Java and make sure R and Java have matching architectures.

> sessionInfo()
R version 3.3.2 (2016-10-31)
Platform: x86_64-w64-mingw32/x64 (64-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] tidyquant_0.5.3   dplyr_0.7.2
 [3] purrr_0.2.3   readr_1.1.1
 [5] tidyr_0.6.3   tibble_1.3.3
 [7] ggplot2_2.2.1 tidyverse_1.1.1
 [9] quantmod_0.4-10   TTR_0.23-2
[11] PerformanceAnalytics_1.4.3541 xts_0.10-0
[13] zoo_1.8-0 lubridate_1.6.0

loaded via a namespace (and not attached):
 [1] Rcpp_0.12.12 cellranger_1.1.0 plyr_1.8.4   bindr_0.1
 [5] forcats_0.2.0tools_3.3.2  jsonlite_1.5 nlme_3.1-131
 [9] gtable_0.2.0 lattice_0.20-35  pkgconfig_2.0.1  rlang_0.1.1
[13] psych_1.7.5  curl_2.8.1   parallel_3.3.2   haven_1.1.0
[17] bindrcpp_0.2 xml2_1.1.1   httr_1.2.1   stringr_1.2.0
[21] hms_0.3  grid_3.3.2   glue_1.1.1   R6_2.2.2
[25] Quandl_2.8.0 readxl_1.0.0 foreign_0.8-69   modelr_0.1.1
[29] reshape2_1.4.2   magrittr_1.5 scales_0.4.1 rvest_0.3.2
[33] assertthat_0.2.0 mnormt_1.5-5 colorspace_1.3-2 stringi_1.1.5
[37] lazyeval_0.2.0   munsell_0.4.3broom_0.4.2

__
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] Nested for loop

2017-08-06 Thread Kirsten Morehouse
Hi Ben,

That's exactly right! Except for each set it's the sample population that
is 400, 800 or 300. I want to take 3 samples, each of 100, where only the
population differs. I can do this separately, but I'm having trouble
putting them all on the same graph.

I'd like to have sample on the x axis (1-300) and estimate on the y axis. I
want to show how population affects the estimates.

Does this make more sense?

Thanks for your time!

Kirsten
On Sun, Aug 6, 2017 at 3:21 PM Ben Tupper  wrote:

> Hi Kirsten,
>
>
>
> I can run your example code but I can't quite follow your division of
> sampling.  Can you restate the the task?  Below is what I think you are
> asking for, but I have the feeling I may be off the mark.
>
>
>
>
>
> Set A: 400 samples, draw 100 in range of 5 to 15
>
>
>
> Set B: 800 samples, draw 100 in range of 5 to 15
>
>
>
> Set C: 300 samples, draw 100 in range of 5 to 15
>
>
>
> Ben
>
>
>
> > On Aug 5, 2017, at 9:21 AM, Kirsten Morehouse 
> wrote:
>
> >
>
> > Hi! Thanks for taking the time to read this.
>
> >
>
> > The code below creates a graph that takes 100 samples that are between 5%
>
> > and 15% of the population (400).
>
> >
>
> > What I'd like to do, however, is add two other sections to the graph. It
>
> > would look something like this:
>
> >
>
> > from 1-100 samples take 100 samples that are between 5% and 15% of the
>
> > population (400). From 101-200 take 100 samples that are between 5% and
> 15%
>
> > of the population (800). From 201-300 take 100 samples that are between
> 5%
>
> > and 15% of the population (300).
>
> >
>
> > I assume this would require a nested for loop. Does anyone have advice as
>
> > to how to do this?
>
> >
>
> > Thanks for your time. Kirsten
>
> >
>
> > ## Mark-Recapture
>
> > ## Estimate popoulation from repeated sampling
>
> >
>
> > ## Population size
>
> > N <- 400
>
> > N
>
> >
>
> > ## Vector labeling each item in the population
>
> > pop <- c(1:N)
>
> > pop
>
> >
>
> > ## Lower and upper bounds of sample size
>
> > lower.bound <- round(x = .05 * N, digits = 0)
>
> > lower.bound ## Smallest possible sample size
>
> >
>
> > upper.bound <- round(x = .15 * N, digits = 0)
>
> > upper.bound ## Largest possible sample size
>
> >
>
> > ## Length of sample size interval
>
> > length.ss.interval <- length(c(lower.bound:upper.bound))
>
> > length.ss.interval ## total possible sample sizes, ranging form
> lower.bound
>
> > to upper.bound
>
> >
>
> > ## Determine a sample size randomly (not a global variable...simply for
>
> > test purposes)
>
> > ## Between lower and upper bounds set previously
>
> > ## Give equal weight to each possible sample size in this interval
>
> > sample(x = c(lower.bound:upper.bound),
>
> >   size = 1,
>
> >   prob = c(rep(1/length.ss.interval, length.ss.interval)))
>
> >
>
> > ## Specify number of samples to take
>
> > n.samples <- 100
>
> >
>
> > ## Initiate empty matrix
>
> > ## 1st column is population (item 1 thorugh item 400)
>
> > ## 2nd through nth column are all rounds of sampling
>
> > dat <- matrix(data = NA,
>
> >  nrow = length(pop),
>
> >  ncol = n.samples + 1)
>
> >
>
> > dat[,1] <- pop
>
> >
>
> > dat
>
> >
>
> > ## Take samples of random sizes
>
> > ## Record results in columns 2 through n
>
> > ## 1 = sampled (marked)
>
> > ## 0 = not sampled (not marked)
>
> > for(i in 2:ncol(dat)) {
>
> >  a.sample <- sample(x = pop,
>
> > size = sample(x = c(lower.bound:upper.bound),
>
> >   size = 1,
>
> >   prob = c(rep(1/length.ss.interval,
>
> > length.ss.interval))),
>
> > replace = FALSE)
>
> >  dat[,i] <- dat[,1] %in% a.sample
>
> > }
>
> >
>
> > ## How large was each sample size?
>
> > apply(X = dat, MARGIN = 2, FUN = sum)
>
> > ## 1st element is irrelevant
>
> > ## 2nd element through nth element: sample size for each of the 100
> samples
>
> >
>
> > ## At this point, all computations can be done using dat
>
> >
>
> > ## Create Schnabel dataframe using dat
>
> > ## Google the Schnabel formula
>
> >
>
> > schnabel.comp <- data.frame(sample = 1:n.samples,
>
> >n.sampled = apply(X = dat, MARGIN = 2, FUN =
>
> > sum)[2:length(apply(X = dat, MARGIN = 2, FUN = sum))]
>
> > )
>
> >
>
> > ## First column: which sample, 1-100
>
> > ## Second column: number selected in that sample
>
> >
>
> >
>
> > ## How many items were previously sampled?
>
> > ## For 1st sample, it's 0
>
> > ## For 2nd sample, code is different than for remaning samples
>
> >
>
> > n.prev.sampled <- c(0, rep(NA, n.samples-1))
>
> > n.prev.sampled
>
> >
>
> > n.prev.sampled[2] <- sum(ifelse(test = dat[,3] == 1 & dat[,2] == 1,
>
> >yes = 1,
>
> >no = 0))
>
> >
>
> > n.prev.sampled
>
> >
>
> > for(i in 4:ncol(dat)) {
>
> >  n.prev.sampled[i-1] <- sum(ifelse(test = dat[,i] == 1 &
>
> > 

Re: [R] Nested for loop

2017-08-06 Thread Ben Tupper
Hi Kirsten,

I can run your example code but I can't quite follow your division of sampling. 
 Can you restate the the task?  Below is what I think you are asking for, but I 
have the feeling I may be off the mark.


Set A: 400 samples, draw 100 in range of 5 to 15

Set B: 800 samples, draw 100 in range of 5 to 15

Set C: 300 samples, draw 100 in range of 5 to 15

Ben

> On Aug 5, 2017, at 9:21 AM, Kirsten Morehouse  wrote:
> 
> Hi! Thanks for taking the time to read this.
> 
> The code below creates a graph that takes 100 samples that are between 5%
> and 15% of the population (400).
> 
> What I'd like to do, however, is add two other sections to the graph. It
> would look something like this:
> 
> from 1-100 samples take 100 samples that are between 5% and 15% of the
> population (400). From 101-200 take 100 samples that are between 5% and 15%
> of the population (800). From 201-300 take 100 samples that are between 5%
> and 15% of the population (300).
> 
> I assume this would require a nested for loop. Does anyone have advice as
> to how to do this?
> 
> Thanks for your time. Kirsten
> 
> ## Mark-Recapture
> ## Estimate popoulation from repeated sampling
> 
> ## Population size
> N <- 400
> N
> 
> ## Vector labeling each item in the population
> pop <- c(1:N)
> pop
> 
> ## Lower and upper bounds of sample size
> lower.bound <- round(x = .05 * N, digits = 0)
> lower.bound ## Smallest possible sample size
> 
> upper.bound <- round(x = .15 * N, digits = 0)
> upper.bound ## Largest possible sample size
> 
> ## Length of sample size interval
> length.ss.interval <- length(c(lower.bound:upper.bound))
> length.ss.interval ## total possible sample sizes, ranging form lower.bound
> to upper.bound
> 
> ## Determine a sample size randomly (not a global variable...simply for
> test purposes)
> ## Between lower and upper bounds set previously
> ## Give equal weight to each possible sample size in this interval
> sample(x = c(lower.bound:upper.bound),
>   size = 1,
>   prob = c(rep(1/length.ss.interval, length.ss.interval)))
> 
> ## Specify number of samples to take
> n.samples <- 100
> 
> ## Initiate empty matrix
> ## 1st column is population (item 1 thorugh item 400)
> ## 2nd through nth column are all rounds of sampling
> dat <- matrix(data = NA,
>  nrow = length(pop),
>  ncol = n.samples + 1)
> 
> dat[,1] <- pop
> 
> dat
> 
> ## Take samples of random sizes
> ## Record results in columns 2 through n
> ## 1 = sampled (marked)
> ## 0 = not sampled (not marked)
> for(i in 2:ncol(dat)) {
>  a.sample <- sample(x = pop,
> size = sample(x = c(lower.bound:upper.bound),
>   size = 1,
>   prob = c(rep(1/length.ss.interval,
> length.ss.interval))),
> replace = FALSE)
>  dat[,i] <- dat[,1] %in% a.sample
> }
> 
> ## How large was each sample size?
> apply(X = dat, MARGIN = 2, FUN = sum)
> ## 1st element is irrelevant
> ## 2nd element through nth element: sample size for each of the 100 samples
> 
> ## At this point, all computations can be done using dat
> 
> ## Create Schnabel dataframe using dat
> ## Google the Schnabel formula
> 
> schnabel.comp <- data.frame(sample = 1:n.samples,
>n.sampled = apply(X = dat, MARGIN = 2, FUN =
> sum)[2:length(apply(X = dat, MARGIN = 2, FUN = sum))]
> )
> 
> ## First column: which sample, 1-100
> ## Second column: number selected in that sample
> 
> 
> ## How many items were previously sampled?
> ## For 1st sample, it's 0
> ## For 2nd sample, code is different than for remaning samples
> 
> n.prev.sampled <- c(0, rep(NA, n.samples-1))
> n.prev.sampled
> 
> n.prev.sampled[2] <- sum(ifelse(test = dat[,3] == 1 & dat[,2] == 1,
>yes = 1,
>no = 0))
> 
> n.prev.sampled
> 
> for(i in 4:ncol(dat)) {
>  n.prev.sampled[i-1] <- sum(ifelse(test = dat[,i] == 1 &
> rowSums(dat[,2:(i-1)]) > 0,
>yes = 1,
>no = 0))
> }
> 
> schnabel.comp$n.prev.sampled <- n.prev.sampled
> 
> ## n.newly.sampled: in each sample, how many items were newly sampled?
> ## i.e., never seen before?
> schnabel.comp$n.newly.sampled <- with(schnabel.comp,
>  n.sampled - n.prev.sampled)
> 
> ## cum.sampled: how many total items have you seen?
> schnabel.comp$cum.sampled <- c(0,
> cumsum(schnabel.comp$n.newly.sampled)[2:n.samples-1])
> 
> ## numerator of schnabel formula
> schnabel.comp$numerator <- with(schnabel.comp,
>n.sampled * cum.sampled)
> 
> ## denominator of schnable formula is n.prev.sampled
> 
> ## pop.estimate -- after each sample (starting with 2nd -- need at least
> two samples)
> schnabel.comp$pop.estimate <- NA
> 
> for(i in 1:length(schnabel.comp$pop.estimate)) {
>  schnabel.comp$pop.estimate[i] <- sum(schnabel.comp$numerator[1:i]) /

Re: [R] Crash when installing heavy packages in remote server with R and Rstudio server

2017-08-06 Thread Duncan Murdoch

On 06/08/2017 2:57 PM, Duncan Murdoch wrote:

On 06/08/2017 9:17 AM, Jorge Cimentada wrote:

Hi,

I've been trying to install some very heavy packages from Github (~ 100MB -
300 MB) on my remote server using Rstudio server and I keep getting some
crashes. These packages are pretty much datasets.


Based on your description, this is RStudio Server specific.  You'll need
to write to their tech support for help.  This list is for R issues.


Oops, I see below that you found it happens with plain R as well.  Was 
that tested on your server machine as well?   It looks as though it has 
some execution time limit (or disk or memory limit) and you're exceeding 
it.  So you should talk to your sysadmin.


Duncan Murdoch



Duncan Murdoch



I try doing it with this code and get the error below.


install.packages("devtools")



devtools::install_github("pbiecek/PISA2000lite")

Downloading GitHub repo pbiecek/PISA2000lite@master
from URL https://api.github.com/repos/pbiecek/PISA2000lite/zipball/master
Installing PISA2000lite
'/usr/lib/R/bin/R' --no-site-file --no-environ --no-save --no-restore
--quiet CMD INSTALL  \
  '/tmp/Rtmp1GoUVG/devtools76a72d179d7/pbiecek-PISA2000lite-54f4765'  \
  --library='/home/cimentadaj/R/x86_64-pc-linux-gnu-library/3.4'
--install-tests

* installing *source* package ‘PISA2000lite’ ...
** data
*** moving datasets to lazyload DB
Killed
Installation failed: Command failed (137)



The package actually gets installed
any(grepl("PISA2012lite", installed.packages()[, 1]))

[1] TRUE


But I once I load the library it's as if none of the datasets are
available. I've used these packages for a long time on my local computer so
I'm sure it's not the packages. The server has enough space to handle the
packages, so it's not memory either. Below you can find the specs of the R
session and the server


R version 3.4.1 (2017-06-30)

Platform: x86_64-pc-linux-gnu (64-bit)

Running under: Ubuntu 16.04.3 LTS

Matrix products: default

BLAS: /usr/lib/libblas/libblas.so.3.6.0

LAPACK: /usr/lib/lapack/liblapack.so.3.6.0


locale:

 [1] LC_CTYPE=en_US.UTF-8   LC_NUMERIC=C
LC_TIME=en_US.UTF-8

 [4] LC_COLLATE=en_US.UTF-8 LC_MONETARY=en_US.UTF-8
 LC_MESSAGES=en_US.UTF-8

 [7] LC_PAPER=en_US.UTF-8   LC_NAME=C  LC_ADDRESS=C


[10] LC_TELEPHONE=C LC_MEASUREMENT=en_US.UTF-8
LC_IDENTIFICATION=C


attached base packages:

[1] stats graphics  grDevices utils datasets  methods   base


loaded via a namespace (and not attached):

 [1] httr_1.2.1  compiler_3.4.1  R6_2.2.2tools_3.4.1
withr_2.0.0 curl_2.8.1

 [7] memoise_1.1.0   git2r_0.19.0digest_0.6.12   devtools_1.13.3


The disk info:


Filesystem  Size  Used Avail Use% Mounted on

udev981M 0  981M   0% /dev

tmpfs   201M   21M  180M  11% /run

/dev/vda139G  9.1G   30G  24% /

tmpfs  1001M  840K 1000M   1% /dev/shm

tmpfs   5.0M 0  5.0M   0% /run/lock

tmpfs  1001M 0 1001M   0% /sys/fs/cgroup

/dev/vda15  105M  3.4M  102M   4% /boot/efi

tmpfs   201M 0  201M   0% /run/user/1000

And server specs from Digital Ocean:
2 GB Memory / 40 GB Disk / LON1 - Ubuntu 16.04.3 x64 from

I posted the question in this

stackoverflow thread and actually found out that the problem is not from
Rstudio server in itself because I get the exact same error with:
R CMD INSTALL PISA2000lite_1.0.tar.gz

Any idea why this might be occurring?

---

Jorge Cimentada

*https://cimentadaj.github.io/ *

[[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] Crash when installing heavy packages in remote server with R and Rstudio server

2017-08-06 Thread Duncan Murdoch

On 06/08/2017 9:17 AM, Jorge Cimentada wrote:

Hi,

I've been trying to install some very heavy packages from Github (~ 100MB -
300 MB) on my remote server using Rstudio server and I keep getting some
crashes. These packages are pretty much datasets.


Based on your description, this is RStudio Server specific.  You'll need 
to write to their tech support for help.  This list is for R issues.


Duncan Murdoch



I try doing it with this code and get the error below.


install.packages("devtools")



devtools::install_github("pbiecek/PISA2000lite")

Downloading GitHub repo pbiecek/PISA2000lite@master
from URL https://api.github.com/repos/pbiecek/PISA2000lite/zipball/master
Installing PISA2000lite
'/usr/lib/R/bin/R' --no-site-file --no-environ --no-save --no-restore
--quiet CMD INSTALL  \
  '/tmp/Rtmp1GoUVG/devtools76a72d179d7/pbiecek-PISA2000lite-54f4765'  \
  --library='/home/cimentadaj/R/x86_64-pc-linux-gnu-library/3.4'
--install-tests

* installing *source* package ‘PISA2000lite’ ...
** data
*** moving datasets to lazyload DB
Killed
Installation failed: Command failed (137)



The package actually gets installed
any(grepl("PISA2012lite", installed.packages()[, 1]))

[1] TRUE


But I once I load the library it's as if none of the datasets are
available. I've used these packages for a long time on my local computer so
I'm sure it's not the packages. The server has enough space to handle the
packages, so it's not memory either. Below you can find the specs of the R
session and the server


R version 3.4.1 (2017-06-30)

Platform: x86_64-pc-linux-gnu (64-bit)

Running under: Ubuntu 16.04.3 LTS

Matrix products: default

BLAS: /usr/lib/libblas/libblas.so.3.6.0

LAPACK: /usr/lib/lapack/liblapack.so.3.6.0


locale:

 [1] LC_CTYPE=en_US.UTF-8   LC_NUMERIC=C
LC_TIME=en_US.UTF-8

 [4] LC_COLLATE=en_US.UTF-8 LC_MONETARY=en_US.UTF-8
 LC_MESSAGES=en_US.UTF-8

 [7] LC_PAPER=en_US.UTF-8   LC_NAME=C  LC_ADDRESS=C


[10] LC_TELEPHONE=C LC_MEASUREMENT=en_US.UTF-8
LC_IDENTIFICATION=C


attached base packages:

[1] stats graphics  grDevices utils datasets  methods   base


loaded via a namespace (and not attached):

 [1] httr_1.2.1  compiler_3.4.1  R6_2.2.2tools_3.4.1
withr_2.0.0 curl_2.8.1

 [7] memoise_1.1.0   git2r_0.19.0digest_0.6.12   devtools_1.13.3


The disk info:


Filesystem  Size  Used Avail Use% Mounted on

udev981M 0  981M   0% /dev

tmpfs   201M   21M  180M  11% /run

/dev/vda139G  9.1G   30G  24% /

tmpfs  1001M  840K 1000M   1% /dev/shm

tmpfs   5.0M 0  5.0M   0% /run/lock

tmpfs  1001M 0 1001M   0% /sys/fs/cgroup

/dev/vda15  105M  3.4M  102M   4% /boot/efi

tmpfs   201M 0  201M   0% /run/user/1000

And server specs from Digital Ocean:
2 GB Memory / 40 GB Disk / LON1 - Ubuntu 16.04.3 x64 from

I posted the question in this

stackoverflow thread and actually found out that the problem is not from
Rstudio server in itself because I get the exact same error with:
R CMD INSTALL PISA2000lite_1.0.tar.gz

Any idea why this might be occurring?

---

Jorge Cimentada

*https://cimentadaj.github.io/ *

[[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] data frame question

2017-08-06 Thread Andras Farkas via R-help
thank you both... assumption is in fact that a and b are always the same 
length... these work for me well...

much appreciate it... 
Andras 


On Sunday, August 6, 2017 12:14 PM, Ulrik Stervbo  
wrote:



Hi Andreas,

assuming that the increment is always indicated by the same value (in your 
example 0), this could work:

df$a <- cumsum(seq_along(df$b) %in% which(df$b == 0))

df

HTH,
Ulrik

On Sun, 6 Aug 2017 at 18:06 Bert Gunter  wrote:

Your specification is a bit unclear to me, so I'm not sure the below
>is really what you want. For example, your example seems to imply that
>a and b must be of the same length, but I do not see that your
>description requires this. So the following may not be what you want
>exactly, but one way to do this(there may be cleverer ones!) is to
>make use of ?rep. Everything else is just fussy detail. (Your example
>suggests that you should also learn about ?seq. Both of these should
>be covered in any good R tutorial, which you should probably spend
>time with if you haven't already).
>
>Anyway...
>
>## WARNING: Not thoroughly tested! May (probably :-( ) contain bugs.
>
>f <- function(x,y,switch_val =0)
>{
>   wh <- which(y == switch_val)
>   len <- length(wh)
>   len_x <- length(x)
>   if(!len) x
>   else if(wh[1] == 1){
>  if(len ==1) return(rep(x[1],len_x))
>  else {
> wh <- wh[-1]
> len <- len -1
>  }
>   }
>   count <- c(wh[1]-1,diff(wh))
>   if(wh[len] == len_x) count<- c(count,1)
>   else count <- c(count, len_x - wh[len] +1)
>   rep(x[seq_along(count)],times = count)
>}
>
>> a <- c(1:5,1:8)
>> b <- c(0:4,0:7)
>> f(a,b)
> [1] 1 1 1 1 1 2 2 2 2 2 2 2 2
>
>
>
>Bert Gunter
>
>"The trouble with having an open mind is that people keep coming along
>and sticking things into it."
>-- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )
>
>
>On Sun, Aug 6, 2017 at 4:10 AM, Andras Farkas via R-help
> wrote:
>> Dear All,
>>
>> wonder if you have thoughts on the following:
>>
>> let us say we have:
>>
>> df<-data.frame(a=c(1,2,3,4,5,1,2,3,4,5,6,7,8),b=c(0,1,2,3,4,0,1,2,3,4,5,6,7))
>>
>>
>>  I would like to rewrite values in column name "a" based on values in column 
>> name "b", where based on a certain value of column "b" the next value of 
>> column 'a' is prompted, in other words would like to have this as a result:
>>
>> df<-data.frame(a=c(1,1,1,1,1,2,2,2,2,2,2,2,2),b=c(0,1,2,3,4,0,1,2,3,4,5,6,7))
>>
>>
>> where at the value of 0 in column 'b' the number in column a changes from 1 
>> to 2. From the first zero value of column 'b' and until the next zero in 
>> column 'b' the numbers would not change in 'a', ie: they are all 1 in my 
>> example... then from 2 it would change to 3 again as 'b' will have zero 
>> again in a row, and so on.. Would be grateful for a solution that would 
>> allow me to set the values (from 'b') that determine how the values get 
>> established in 'a' (ie: lets say instead of 0 I would want 3 being the value 
>> where 1 changes to 2 in 'a') and that would be flexible to take into account 
>> that the number of rows and the number of time 0 shows up in a row in column 
>> 'b' may vary...
>>
>> much appreciate your thoughts..
>>
>> Andras
>>
>> __
>> 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-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 with optim function in R, please?

2017-08-06 Thread fadeh Alanazi
Hi all, 

Many thank in advance for helping me.  I tried to fit Expectation Maximization 
algorithm for mixture data. I must used one of numerical method to maximize my 
function. 

I built my code but I do not know how to make the optim function run over a 
different value of the parameters.  That is, 

For E-step I need to get the value of mixture weights based on the current 
(initial) values of the parameter of the density. Then, multiple the weight by 
the logliklihood function and maximize it (M-step)
Then, I would like to take the new values of the parameter (from M-step) and 
plug it in the weight, to get a new value of the weight. Then, iterate till 
converges. 

I tried the following code, but it does not work. 

library(copula)
library(VineCopula)

## to generate the data
set.seed(123)
cp <- mixCopula(list(frankCopula(4),claytonCopula(2)))
cop <- rCopula(100,cp)
x <- pobs(cop) ## this is the data
## my function including optim function
myfunc <- function(data,copula=list(frankCopula(4,dim=2), 
claytonCopula(0.5,dim=2)),maxit=200){
  
  # copula[[1]]@parameters <- par[1]
  # copula[[2]]@parameters <- par[2]
  optim_1 <- function(par, data.=data, copula.=copula){
    copula[[1]]@parameters <- par[1]
    copula[[2]]@parameters <- par[2]
    tau_1 <- par[3]*dCopula(data,copula[[1]],log = F)
    tau_2 <- par[4]*dCopula(data,copula[[2]],log=F)
    Tau_1 <- tau_1 / sum(tau_1 + tau_2)
    Tau_2 <- tau_2 / sum(tau_1 + tau_2)
    up_pi1 <- sum(Tau_1)/ 100
    up_pi2 <- sum(Tau_2) / 100
    # Tau <- c(Tau_1, Tau_2)
    ll <- (-sum(Tau_1*dCopula(data,copula[[1]],log=T)))
    #ll_1 <- -sum(Tau_2*dCopula(data,copula[[2]],log=T))
    
   
if (is.finite(ll)) {
  return(ll)
    } else {
  if (is.na(ll)) {
    message(par)
  }
  message(ll)
      return(-3^305)
    }
  }
  
  
  
  xy <- optim(par=c(2,0.5,0.2,0.2),fn=optim_1,method="L-BFGS-B",control = 
list(maxit= 200, trace=1),lower= c(copula[[1]]@param.lowbnd, 
copula[[2]]@param.lowbnd,0,0), upper = c(copula[[1]]@param.upbnd, 
copula[[2]]@param.upbnd,1,1))
  
  return(xy$par)
}

Any help please?

Regards, 
Fadhah 



[[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] data frame question

2017-08-06 Thread Ulrik Stervbo
Hi Andreas,

assuming that the increment is always indicated by the same value (in your
example 0), this could work:

df$a <- cumsum(seq_along(df$b) %in% which(df$b == 0))
df

HTH,
Ulrik

On Sun, 6 Aug 2017 at 18:06 Bert Gunter  wrote:

> Your specification is a bit unclear to me, so I'm not sure the below
> is really what you want. For example, your example seems to imply that
> a and b must be of the same length, but I do not see that your
> description requires this. So the following may not be what you want
> exactly, but one way to do this(there may be cleverer ones!) is to
> make use of ?rep. Everything else is just fussy detail. (Your example
> suggests that you should also learn about ?seq. Both of these should
> be covered in any good R tutorial, which you should probably spend
> time with if you haven't already).
>
> Anyway...
>
> ## WARNING: Not thoroughly tested! May (probably :-( ) contain bugs.
>
> f <- function(x,y,switch_val =0)
> {
>wh <- which(y == switch_val)
>len <- length(wh)
>len_x <- length(x)
>if(!len) x
>else if(wh[1] == 1){
>   if(len ==1) return(rep(x[1],len_x))
>   else {
>  wh <- wh[-1]
>  len <- len -1
>   }
>}
>count <- c(wh[1]-1,diff(wh))
>if(wh[len] == len_x) count<- c(count,1)
>else count <- c(count, len_x - wh[len] +1)
>rep(x[seq_along(count)],times = count)
> }
>
> > a <- c(1:5,1:8)
> > b <- c(0:4,0:7)
> > f(a,b)
>  [1] 1 1 1 1 1 2 2 2 2 2 2 2 2
>
>
>
> Bert Gunter
>
> "The trouble with having an open mind is that people keep coming along
> and sticking things into it."
> -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )
>
>
> On Sun, Aug 6, 2017 at 4:10 AM, Andras Farkas via R-help
>  wrote:
> > Dear All,
> >
> > wonder if you have thoughts on the following:
> >
> > let us say we have:
> >
> >
> df<-data.frame(a=c(1,2,3,4,5,1,2,3,4,5,6,7,8),b=c(0,1,2,3,4,0,1,2,3,4,5,6,7))
> >
> >
> >  I would like to rewrite values in column name "a" based on values in
> column name "b", where based on a certain value of column "b" the next
> value of column 'a' is prompted, in other words would like to have this as
> a result:
> >
> >
> df<-data.frame(a=c(1,1,1,1,1,2,2,2,2,2,2,2,2),b=c(0,1,2,3,4,0,1,2,3,4,5,6,7))
> >
> >
> > where at the value of 0 in column 'b' the number in column a changes
> from 1 to 2. From the first zero value of column 'b' and until the next
> zero in column 'b' the numbers would not change in 'a', ie: they are all 1
> in my example... then from 2 it would change to 3 again as 'b' will have
> zero again in a row, and so on.. Would be grateful for a solution that
> would allow me to set the values (from 'b') that determine how the values
> get established in 'a' (ie: lets say instead of 0 I would want 3 being the
> value where 1 changes to 2 in 'a') and that would be flexible to take into
> account that the number of rows and the number of time 0 shows up in a row
> in column 'b' may vary...
> >
> > much appreciate your thoughts..
> >
> > Andras
> >
> > __
> > 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] data frame question

2017-08-06 Thread Bert Gunter
Your specification is a bit unclear to me, so I'm not sure the below
is really what you want. For example, your example seems to imply that
a and b must be of the same length, but I do not see that your
description requires this. So the following may not be what you want
exactly, but one way to do this(there may be cleverer ones!) is to
make use of ?rep. Everything else is just fussy detail. (Your example
suggests that you should also learn about ?seq. Both of these should
be covered in any good R tutorial, which you should probably spend
time with if you haven't already).

Anyway...

## WARNING: Not thoroughly tested! May (probably :-( ) contain bugs.

f <- function(x,y,switch_val =0)
{
   wh <- which(y == switch_val)
   len <- length(wh)
   len_x <- length(x)
   if(!len) x
   else if(wh[1] == 1){
  if(len ==1) return(rep(x[1],len_x))
  else {
 wh <- wh[-1]
 len <- len -1
  }
   }
   count <- c(wh[1]-1,diff(wh))
   if(wh[len] == len_x) count<- c(count,1)
   else count <- c(count, len_x - wh[len] +1)
   rep(x[seq_along(count)],times = count)
}

> a <- c(1:5,1:8)
> b <- c(0:4,0:7)
> f(a,b)
 [1] 1 1 1 1 1 2 2 2 2 2 2 2 2



Bert Gunter

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


On Sun, Aug 6, 2017 at 4:10 AM, Andras Farkas via R-help
 wrote:
> Dear All,
>
> wonder if you have thoughts on the following:
>
> let us say we have:
>
> df<-data.frame(a=c(1,2,3,4,5,1,2,3,4,5,6,7,8),b=c(0,1,2,3,4,0,1,2,3,4,5,6,7))
>
>
>  I would like to rewrite values in column name "a" based on values in column 
> name "b", where based on a certain value of column "b" the next value of 
> column 'a' is prompted, in other words would like to have this as a result:
>
> df<-data.frame(a=c(1,1,1,1,1,2,2,2,2,2,2,2,2),b=c(0,1,2,3,4,0,1,2,3,4,5,6,7))
>
>
> where at the value of 0 in column 'b' the number in column a changes from 1 
> to 2. From the first zero value of column 'b' and until the next zero in 
> column 'b' the numbers would not change in 'a', ie: they are all 1 in my 
> example... then from 2 it would change to 3 again as 'b' will have zero again 
> in a row, and so on.. Would be grateful for a solution that would allow me to 
> set the values (from 'b') that determine how the values get established in 
> 'a' (ie: lets say instead of 0 I would want 3 being the value where 1 changes 
> to 2 in 'a') and that would be flexible to take into account that the number 
> of rows and the number of time 0 shows up in a row in column 'b' may vary...
>
> much appreciate your thoughts..
>
> Andras
>
> __
> 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] Crash when installing heavy packages in remote server with R and Rstudio server

2017-08-06 Thread Jorge Cimentada
Hi,

I've been trying to install some very heavy packages from Github (~ 100MB -
300 MB) on my remote server using Rstudio server and I keep getting some
crashes. These packages are pretty much datasets.

I try doing it with this code and get the error below.

> install.packages("devtools")

> devtools::install_github("pbiecek/PISA2000lite")
Downloading GitHub repo pbiecek/PISA2000lite@master
from URL https://api.github.com/repos/pbiecek/PISA2000lite/zipball/master
Installing PISA2000lite
'/usr/lib/R/bin/R' --no-site-file --no-environ --no-save --no-restore
--quiet CMD INSTALL  \
  '/tmp/Rtmp1GoUVG/devtools76a72d179d7/pbiecek-PISA2000lite-54f4765'  \
  --library='/home/cimentadaj/R/x86_64-pc-linux-gnu-library/3.4'
--install-tests

* installing *source* package ‘PISA2000lite’ ...
** data
*** moving datasets to lazyload DB
Killed
Installation failed: Command failed (137)



The package actually gets installed
any(grepl("PISA2012lite", installed.packages()[, 1]))

[1] TRUE


But I once I load the library it's as if none of the datasets are
available. I've used these packages for a long time on my local computer so
I'm sure it's not the packages. The server has enough space to handle the
packages, so it's not memory either. Below you can find the specs of the R
session and the server


R version 3.4.1 (2017-06-30)

Platform: x86_64-pc-linux-gnu (64-bit)

Running under: Ubuntu 16.04.3 LTS

Matrix products: default

BLAS: /usr/lib/libblas/libblas.so.3.6.0

LAPACK: /usr/lib/lapack/liblapack.so.3.6.0


locale:

 [1] LC_CTYPE=en_US.UTF-8   LC_NUMERIC=C
LC_TIME=en_US.UTF-8

 [4] LC_COLLATE=en_US.UTF-8 LC_MONETARY=en_US.UTF-8
 LC_MESSAGES=en_US.UTF-8

 [7] LC_PAPER=en_US.UTF-8   LC_NAME=C  LC_ADDRESS=C


[10] LC_TELEPHONE=C LC_MEASUREMENT=en_US.UTF-8
LC_IDENTIFICATION=C


attached base packages:

[1] stats graphics  grDevices utils datasets  methods   base


loaded via a namespace (and not attached):

 [1] httr_1.2.1  compiler_3.4.1  R6_2.2.2tools_3.4.1
withr_2.0.0 curl_2.8.1

 [7] memoise_1.1.0   git2r_0.19.0digest_0.6.12   devtools_1.13.3


The disk info:


Filesystem  Size  Used Avail Use% Mounted on

udev981M 0  981M   0% /dev

tmpfs   201M   21M  180M  11% /run

/dev/vda139G  9.1G   30G  24% /

tmpfs  1001M  840K 1000M   1% /dev/shm

tmpfs   5.0M 0  5.0M   0% /run/lock

tmpfs  1001M 0 1001M   0% /sys/fs/cgroup

/dev/vda15  105M  3.4M  102M   4% /boot/efi

tmpfs   201M 0  201M   0% /run/user/1000

And server specs from Digital Ocean:
2 GB Memory / 40 GB Disk / LON1 - Ubuntu 16.04.3 x64 from

I posted the question in this

stackoverflow thread and actually found out that the problem is not from
Rstudio server in itself because I get the exact same error with:
R CMD INSTALL PISA2000lite_1.0.tar.gz

Any idea why this might be occurring?

---

Jorge Cimentada

*https://cimentadaj.github.io/ *

[[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] data frame question

2017-08-06 Thread Andras Farkas via R-help
Dear All,

wonder if you have thoughts on the following: 

let us say we have:

df<-data.frame(a=c(1,2,3,4,5,1,2,3,4,5,6,7,8),b=c(0,1,2,3,4,0,1,2,3,4,5,6,7))


 I would like to rewrite values in column name "a" based on values in column 
name "b", where based on a certain value of column "b" the next value of column 
'a' is prompted, in other words would like to have this as a result:

df<-data.frame(a=c(1,1,1,1,1,2,2,2,2,2,2,2,2),b=c(0,1,2,3,4,0,1,2,3,4,5,6,7)) 


where at the value of 0 in column 'b' the number in column a changes from 1 to 
2. From the first zero value of column 'b' and until the next zero in column 
'b' the numbers would not change in 'a', ie: they are all 1 in my example... 
then from 2 it would change to 3 again as 'b' will have zero again in a row, 
and so on.. Would be grateful for a solution that would allow me to set the 
values (from 'b') that determine how the values get established in 'a' (ie: 
lets say instead of 0 I would want 3 being the value where 1 changes to 2 in 
'a') and that would be flexible to take into account that the number of rows 
and the number of time 0 shows up in a row in column 'b' may vary...

much appreciate your thoughts..

Andras

__
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] SPSS R Factor v2.4.2

2017-08-06 Thread Uwe Ligges

Actually there is also a Windows binary:

https://cran.r-project.org/bin/windows/contrib/3.2/polycor_0.7-8.zip

hence installing with install.packages("polycor") should work *if* you 
choose a http (not https) mirror. The latter was not possible in R-3.2.0 
which probably is what you are taking about.


Best,
Uwe Ligges



On 06.08.2017 07:08, David Winsemius wrote:



On Aug 5, 2017, at 7:02 PM, Gavin Brown  wrote:

I am not an R-Head, hence I use nice utilities that integrate R into SPSS
I have SPSS v24, R3.20 and R3.40
I have run IBM SPSS R Integration which requires linking to R3.20
I have installed R Factor v2.4.2



This package requires 'polycor' library
Unfortunately, 'polycor' does not exist in R3.20


That's not really correct. There is an archived version that should be 
compatible with your out-of-date version of R. See:

ftp://cran.r-project.org/pub/R/src/contrib/Archive/polycor/

Good luck;
David.



DATASET ACTIVATE DataSet1.
*M�rio Basto, Jos� Manuel Pereira, IPCA
*Required: SPSS 21 and R Integration Plugin
*R Packages required: psych, polycor, GPArotation, nFactors, corpcor, ICS, 
R.utils.
set printback off.
Error in library(polycor) : there is no package called 'polycor'

This means the very good utility does not run in the way I have installed both 
R and SPSS
Does anyone know what I've done wrong and how to overcome this?

Prof. Gavin T L Brown, PhD
Director Quantitative Data Analysis and Research Unit
Faculty of Education & Social Work
The University of Auckland
Tel: +64 9 3737599 ext. 48602
Mob: +64 22 108 7253
Honorary Professor, Dept. of Curriculum & Instruction, Education University of 
Hong Kong
Affiliated Professor, Dept. of Applied Educational Sciences, University of 
Umea, Sweden

New:  
https://www.routledge.com/Assessment-of-Student-Achievement/Brown/p/book/9781138061866


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



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