I have installed the latest quantstrat from source, previous error with luxor.4 is gone, but still got a warning message as follows:
Warning message:
In data.frame(forex.1 = list(param.combo = list(EnterLong = 1L, :
row names were found from a short variable and have been discarded
run sessionInfo() returns the following:
R version 3.2.3 (2015-12-10)
Platform: x86_64-apple-darwin13.4.0 (64-bit)
Running under: OS X 10.11.3 (El Capitan)
locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
attached base packages:
[1] parallel stats graphics grDevices utils
[6] datasets methods base
other attached packages:
[1] doMC_1.3.4
[2] iterators_1.0.8
[3] quantstrat_0.9.1709
[4] foreach_1.4.3
[5] dplyr_0.4.3
[6] blotter_0.9.1695
[7] PerformanceAnalytics_1.4.3541
[8] FinancialInstrument_1.2.0
[9] quantmod_0.4-5
[10] TTR_0.23-0
[11] xts_0.9-7
[12] zoo_1.7-12
loaded via a namespace (and not attached):
[1] Rcpp_0.12.3 codetools_0.2-14
[3] lattice_0.20-33 assertthat_0.1
[5] grid_3.2.3 R6_2.1.2
[7] DBI_0.3.1 magrittr_1.5
[9] robustbase_0.92-5 tools_3.2.3
[11] DEoptimR_1.0-4 compiler_3.2.3
I am new to R, I cannot verify whether this warning is trivial or not. Could anyone give me some advice on this? Thanks
Related
I’m trying to install TensorFlow.jl on MacOS for Julia v0.7.0. I have the following packages installed:
(v0.7) pkg> status
Status `~/.julia/environments/v0.7/Project.toml`
[336ed68f] CSV v0.3.1
[a93c6f00] DataFrames v0.13.1
[7073ff75] IJulia v1.12.0
[438e738f] PyCall v1.18.4
[1d978283] TensorFlow v0.10.2
When running the following MWE
using TensorFlow
sess = Session()
feature_columns = placeholder(Float32)
target_columns = placeholder(Float32)
m=Variable(0.05)
b=Variable(0.0)
y=m.*feature_columns+b
loss=reduce_sum((target_columns - y).^2)
learning_rate=0.0000001;
my_optimizer=train.minimize(train.GradientDescentOptimizer(learning_rate), loss)
for the first time, I get the error message
On worker 2:
LoadError: ArgumentError: Package MacroTools not found in current path:
- Run `Pkg.add("MacroTools")` to install the MacroTools package.
After adding MacroTools.jl via the package manager and rerunning the example, the Julia kernel crashes with a segmentation fault:
signal (11): Segmentation fault: 11
in expression starting at no file:0
TF_GraphGetTensorNumDims at /Users/sd/.julia/packages/TensorFlow/A6TdG/deps/usr/bin/libtensorflow.dylib (unknown line)
get_tensor_num_dims at /Users/sd/.julia/packages/TensorFlow/A6TdG/src/core.jl:25
get_shape at /Users/sd/.julia/packages/TensorFlow/A6TdG/src/core.jl:1823
show at /Users/sd/.julia/packages/TensorFlow/A6TdG/src/show.jl:50
show at ./sysimg.jl:195
jl_fptr_trampoline at /Users/osx/buildbot/slave/package_osx64/build/src/gf.c:1829
display at /Users/osx/buildbot/slave/package_osx64/build/usr/share/julia/stdlib/v0.7/REPL/src/REPL.jl:131
display at /Users/osx/buildbot/slave/package_osx64/build/usr/share/julia/stdlib/v0.7/REPL/src/REPL.jl:135
display at ./multimedia.jl:287
#7 at /Users/sd/.julia/packages/Media/Lrdeg/src/compat.jl:28
hookless at /Users/sd/.julia/packages/Media/Lrdeg/src/compat.jl:14
render at /Users/sd/.julia/packages/Media/Lrdeg/src/compat.jl:27
render at /Users/sd/.julia/packages/Media/Lrdeg/src/system.jl:160
display at /Users/sd/.julia/packages/Media/Lrdeg/src/compat.jl:9
display at ./multimedia.jl:287
jl_fptr_trampoline at /Users/osx/buildbot/slave/package_osx64/build/src/gf.c:1829
jl_apply at /Users/osx/buildbot/slave/package_osx64/build/src/./julia.h:1538 [inlined]
jl_f__apply at /Users/osx/buildbot/slave/package_osx64/build/src/builtins.c:563
jl_f__apply_latest at /Users/osx/buildbot/slave/package_osx64/build/src/builtins.c:601
#invokelatest#1 at ./essentials.jl:691 [inlined]
invokelatest at ./essentials.jl:690 [inlined]
print_response at /Users/osx/buildbot/slave/package_osx64/build/usr/share/julia/stdlib/v0.7/REPL/src/REPL.jl:154
unknown function (ip: 0x109ead87e)
print_response at /Users/osx/buildbot/slave/package_osx64/build/usr/share/julia/stdlib/v0.7/REPL/src/REPL.jl:139
unknown function (ip: 0x109ead2ab)
do_respond at /Users/osx/buildbot/slave/package_osx64/build/usr/share/julia/stdlib/v0.7/REPL/src/REPL.jl:708
unknown function (ip: 0x109e96124)
jl_apply at /Users/osx/buildbot/slave/package_osx64/build/src/./julia.h:1538 [inlined]
jl_f__apply at /Users/osx/buildbot/slave/package_osx64/build/src/builtins.c:563
jl_f__apply_latest at /Users/osx/buildbot/slave/package_osx64/build/src/builtins.c:601
#invokelatest#1 at ./essentials.jl:691 [inlined]
invokelatest at ./essentials.jl:690 [inlined]
run_interface at /Users/osx/buildbot/slave/package_osx64/build/usr/share/julia/stdlib/v0.7/REPL/src/LineEdit.jl:2261
run_frontend at /Users/osx/buildbot/slave/package_osx64/build/usr/share/julia/stdlib/v0.7/REPL/src/REPL.jl:1029
run_repl at /Users/osx/buildbot/slave/package_osx64/build/usr/share/julia/stdlib/v0.7/REPL/src/REPL.jl:191
#831 at ./logging.jl:311
jfptr_#831_5851.clone_1 at /Applications/Programmieren/Julia-0.7.app/Contents/Resources/julia/lib/julia/sys.dylib (unknown line)
jl_apply at /Users/osx/buildbot/slave/package_osx64/build/src/./julia.h:1538 [inlined]
jl_f__apply at /Users/osx/buildbot/slave/package_osx64/build/src/builtins.c:563
jl_f__apply_latest at /Users/osx/buildbot/slave/package_osx64/build/src/builtins.c:601
#invokelatest#1 at ./essentials.jl:691 [inlined]
invokelatest at ./essentials.jl:690 [inlined]
macro expansion at ./logging.jl:308 [inlined]
run_main_repl at ./client.jl:340
exec_options at ./client.jl:252
_start at ./client.jl:432
true_main at /Applications/Programmieren/Julia-0.7.app/Contents/Resources/julia/bin/julia (unknown line)
main at /Applications/Programmieren/Julia-0.7.app/Contents/Resources/julia/bin/julia (unknown line)
Allocations: 66064400 (Pool: 66051866; Big: 12534); GC: 149
In some other cases, I got the error messages
On worker 2: The Python TensorFlow package could not be imported. You must install Python TensorFlow before using this package. error at ./error.jl:33
or
UndefVarError: py_gradients not defined
Unfortunately, I can’t reproduce them after reinstalling everything and starting from scratch. I would assume that these errors are related to the current issues with PyCall.jl and Conda.
Are there any ideas on how to get the package to work?
I am trying to use list constructor in SWI-Prolog, but am getting 'dict' expected error.
For example,
.(a, []) == [a].
ERROR: Type error: `dict' expected, found `a' (an atom)
ERROR: In:
ERROR: [11] throw(error(type_error(dict,a),_14808))
ERROR: [10] '$type_error'(dict,a) at /Applications/SWI-Prolog.app/Contents/swipl/boot/init.pl:3369
ERROR: [9] '$dicts':'.'(a,[],_14874) at /Applications/SWI-Prolog.app/Contents/swipl/boot/dicts.pl:46
ERROR: [8] '<meta-call>'(user:(...,...)) <foreign>
ERROR: [7] <user>
Exception: (9) '.'(a, [], _14200) ?
Could anyone help me configure this functionality?
SWI-Prolog 7.x uses a different list constructor, '[|]'/2, instead of the traditional ./2 Prolog constructor:
?- '[|]'(1,[]) == [1].
true.
The change was motivated to free ./2 for other uses, notably in dict terms, as hinted in the error message you got for your query.
Better to use | in conventional notation,
?- X = '[|]'(1,[0]).
X = [1, 0].
can be write like this
?- X = [1|[0]].
X = [1, 0].
I am trying to combine a certain part of 51 Excel files by suing 'for' loops and 'rbind' codes.
files are:
[1] "savedrecs-10.xls" "savedrecs-11.xls" "savedrecs-12.xls"
[4] "savedrecs-13.xls" "savedrecs-14.xls" "savedrecs-15.xls"
[7] "savedrecs-16.xls" "savedrecs-17.xls" "savedrecs-18.xls"
[10] "savedrecs-19.xls" "savedrecs-20.xls" "savedrecs-21.xls"
[13] "savedrecs-22.xls" "savedrecs-23.xls" "savedrecs-24.xls"
[16] "savedrecs-25.xls" "savedrecs-26.xls" "savedrecs-27.xls"
[19] "savedrecs-28.xls" "savedrecs-29.xls" "savedrecs-30.xls"
[22] "savedrecs-31.xls" "savedrecs-32.xls" "savedrecs-33.xls"
[25] "savedrecs-34.xls" "savedrecs-35.xls" "savedrecs-36.xls"
[28] "savedrecs-37.xls" "savedrecs-38.xls" "savedrecs-39.xls"
[31] "savedrecs-4.xls" "savedrecs-40.xls" "savedrecs-41.xls"
[34] "savedrecs-42.xls" "savedrecs-43.xls" "savedrecs-44.xls"
[37] "savedrecs-45.xls" "savedrecs-46.xls" "savedrecs-47.xls"
[40] "savedrecs-48.xls" "savedrecs-49.xls" "savedrecs-5.xls"
[43] "savedrecs-50.xls" "savedrecs-51.xls" "savedrecs-52.xls"
[46] "savedrecs-53.xls" "savedrecs-54.xls" "savedrecs-6.xls"
[49] "savedrecs-7.xls" "savedrecs-8.xls" "savedrecs-9.xls"
I already combined several other files as following:
articles1_10 <- read_excel(path="savedrecs.xls", sheet="savedrecs (2)", col_names=TRUE)
articles11_20 <- read_excel(path="savedrecs-2.xls", sheet="savedrecs", col_names=TRUE)
articles21_30 <- read_excel(path="savedrecs-3.xls", sheet="savedrecs", col_names=TRUE)
articles1_30 <- rbind(articles1_10, articles11_20, articles21_30)
articles1_30
write.csv(articles1_30, "articles1_30.csv")
For combining the 51 files, I was suggested to use the following code:
list <- list.files(pattern = ".xls")
for (i in 1:length(list)){
name <- paste0("savedrecs",i)
path<-paste0("savedrecs-",i,".xls")
table=rbind(table,assign(name,readWorksheet(path, sheet = "savedrecs",startRow = 30,endRow = 39,startCol = 1,endCol = 139,header = FALSE)))
}
However, an error message like below follows after running the code.
Error in (function (classes, fdef, mtable) :
unable to find an inherited method for function ‘readWorksheet’ for signature ‘"character", "character"’
I installed the related packages, which are:
library (rJava)
library (xlsxjars)
library (xlsx)
library (stringr)
library (readxl)
library (XLConnectJars)
library (XLConnect)
What does the aforementioned error message mean? What else can I combine the 51 files?
I am able to run the following example script from the SWSamp package fine in the console, but I get an "isIncomplete(con)" error when knitting to PDF. This package requires use of at least 2 cores, and I'm wondering if this connection error is related to trying to run in parallel.
---
title: "Test"
output: pdf_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
```{r}
install.packages("http://www.statistica.it/gianluca/SWSamp/SWSamp_0.3.tar.gz", type="source", dependencies=TRUE, repos=NULL)
library(SWSamp)
```
```{r}
mu1=0.3
b.trt=-0.3875
sigma.e=1.55
J=5
K=20
sig.level=0.05
n.sims=10
rho=0.5
pow.cont <- sim.power(I=14, J=J, H=NULL, K=K, rho=rho, mu=mu1, sigma.e=sigma.e,
b.trt=b.trt, formula=NULL, n.sims=n.sims,
sig.level=sig.level, n.cores=2)
pow.cont$power
```
Quitting from lines 16-28 (test.Rmd) Error in isIncomplete(con) :
invalid connection Calls: ... evaluate_call ->
handle_output -> -> isIncomplete Quitting from lines 16-28
(test.Rmd) Error in isOpen(con) : invalid connection Calls:
... in_dir -> evaluate -> evaluate_call -> ->
isOpen Error in close.connection(con) : invalid connection Calls:
-> -> close -> close.connection Execution
halted
> sessionInfo()
R version 3.3.2 (2016-10-31)
Platform: x86_64-apple-darwin13.4.0 (64-bit)
Running under: macOS Sierra 10.12.1
locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] SWSamp_0.3 lme4_1.1-12 Matrix_1.2-7.1
loaded via a namespace (and not attached):
[1] Rcpp_0.12.8 knitr_1.15.1 magrittr_1.5 splines_3.3.2 MASS_7.3-45
[6] doParallel_1.0.10 lattice_0.20-34 foreach_1.4.3 minqa_1.2.4 stringr_1.1.0
[11] tools_3.3.2 parallel_3.3.2 grid_3.3.2 nlme_3.1-128 htmltools_0.3.5
[16] iterators_1.0.8 yaml_2.1.14 rprojroot_1.1 digest_0.6.10 nloptr_1.0.4
[21] codetools_0.2-15 evaluate_0.10 rmarkdown_1.3 stringi_1.1.2 compiler_3.3.2
[26] backports_1.0.4
The sim.power() function runs closeAllConnections(), which interferes with knitr according to this SO answer. The solution in this answer was to wrap the expression in quotes and the evaluate() function, but it did not work for me.
As a temporary solution, I redefined the sim.power() function with the closeAllConnections() call commented out. I don't know if this has adverse effects, but seems to run for me. Happy to accept better answers.
I have a .csv file, which contains the following data:
"Ա","Բ"
1,10
2,20
I cannot read it into R so that the column names are displayed like they are in the file.
d <- read.csv("./Data/1.csv", fileEncoding="UTF-8")
head(d)
Produces the following:
> d <- read.csv("./Data/1.csv", fileEncoding="UTF-8")
Warning messages:
1: In read.table(file = file, header = header, sep = sep, quote = quote, :
invalid input found on input connection './Data/1.csv'
2: In read.table(file = file, header = header, sep = sep, quote = quote, :
incomplete final line found by readTableHeader on './Data/1.csv'
> head(d)
[1] X.
<0 rows> (or 0-length row.names)
Meanwhile, doing the same without specifying the fileEncoding produces this:
> d <- read.csv("./Data/1.csv")
> head(d)
Ô. Ô²
1 1 10
2 2 20
When I run the "file" utility to find out the encoding of the file, it says it is UTF-8:
Data\1.csv: UTF-8 Unicode text, with CRLF line terminators
I am using RStudio, Windows 7, R version 2.15.2, 32-bit.
Thanks in advance.
I wrote a longer answer on the same issue here: R on Windows: character encoding hell .
Quick answer, using the parameter encoding instead of fileEncoding should fix your first issue. You will not be able to read it possibly in either console or table view in RStudio, but you will be able to use it in formulaes.
d <- read.csv("./Data/1.csv", encoding="UTF-8")
head(d)
Having saved your table into a UTF-8 file:
> test2 <- read.csv("test2.csv", header = FALSE, sep = ",", quote = "\"", dec = ".", fill = TRUE, comment.char = "", encoding = "UTF-8")
Warning message:
In read.table(file = file, header = header, sep = sep, quote = quote, :
incomplete final line found by readTableHeader on 'test2.csv'
This gives you how it looks like in the console and RStudio view
> test2
V1 V2
1 <U+0531> <U+0532>
2 1 10
3 2 20
However importantly you are able to manipulate this within R. Thus in my case it is possible to see that the script window input Ա has UTF-8 encoding, and a grep correctly finds this encoding in your table.
> Encoding("Ա")
[1] "UTF-8"
> grep("Ա", as.character(test2[1,1]))
[1] 1
You may need to find suitable encoding variants that work on your settings, or possibly change them. Unfortunately I am not sure where it is done.
You might not be able to make it pretty in all stages, but it is definitely possible to get it to work also in Windows 7 environment.
I tried two ways to replicate your problem.
I copied the characters above into RStudio, saved it to a csv with this code:
write.csv(c("Ա","Բ",
1,10,
2,20), "test.csv")
df <- read.csv("test.csv")
This worked fine.
Then I thought, well maybe R is cheating when I save it to CSV with R? So I just pasted the characters to a text file and save it as a CSV. This approach doesn't have problems either.
Here's my session info:
sessionInfo()
R version 3.0.1 (2013-05-16)
Platform: x86_64-pc-linux-gnu (64-bit)
locale:
[1] LC_CTYPE=en_CA.UTF-8 LC_NUMERIC=C LC_TIME=en_CA.UTF-8
[4] LC_COLLATE=en_CA.UTF-8 LC_MONETARY=en_CA.UTF-8 LC_MESSAGES=en_CA.UTF-8
[7] LC_PAPER=C LC_NAME=C LC_ADDRESS=C
[10] LC_TELEPHONE=C LC_MEASUREMENT=en_CA.UTF-8 LC_IDENTIFICATION=C
attached base packages:
[1] stats4 grid stats graphics grDevices utils datasets methods base
other attached packages:
[1] party_1.0-9 modeltools_0.2-21 strucchange_1.4-7 sandwich_2.2-10 zoo_1.7-10
[6] GGally_0.4.4 reshape_0.8.4 plyr_1.8 ggplot2_0.9.3.1
loaded via a namespace (and not attached):
[1] coin_1.0-23 colorspace_1.2-2 dichromat_2.0-0 digest_0.6.3
[5] gtable_0.1.2 labeling_0.2 lattice_0.20-23 MASS_7.3-29
[9] munsell_0.4.2 mvtnorm_0.9-9995 proto_0.3-10 RColorBrewer_1.0-5
[13] reshape2_1.2.2 scales_0.2.3 splines_3.0.1 stringr_0.6.2
I had the same problem and found out that the file was corrupted.
I opened the file with OpenOffice and saved it back using "UTF8" character set (you need to click the edit filter settings box) and then imported it with the read.csv()(no encoding or filencoding option) and it worked fine.