I'm fairly new to R and I'm trying Phylogenetic Generalised Least Squares (PGLS) for the first time, using the addon package 'caper'. My phylogeny consists of 125 species. I'm getting an error when I read in the phylogeny that I created in Mesquite software (saved as a Nexus file):
##reading in my phylogeny
reptilephylogeny <- read.nexus ("reptile_phylogeny_new_edit.nex", tree.names = NULL)
##it gives me the following warning message:
Warning message:
In matrix(x, ncol = 2, byrow = TRUE) :
data length [253] is not a sub-multiple or multiple of the number of rows [127]
##So I checked how R is treating the tip labels:
reptilephylogeny$tip.label
[1] "Apalone_spinifera" "Staurotypus_triporcatus"
[3] "Gehyra_variegata" "Egernia_whitii"
[5] "Ameiva_erythrocephala" "Lacerta_vivipara"
[7] "Lacerta_agilis" "Podarcis_muralis"
[9] "Podarcis_sicula" "Psammodromus_algirus"
[11] "Tropidurus_itambere" "Tropidurus_torquatus"
[13] "Cyclura_nubila" "Ctenosaura_bakeri"
[15] "Uta_stansburiana" "Sceloporus_graciosus"
[17] "Sceloporus_scalaris" "Sceloporus_jarrovi"
[19] "19" "20"
[21] "21" "22"
[23] "23" "24"
[25] "25" "26"
[27] "27" "28"
[29] "29" "30"
[31] "31" "32"
[33] "33" "34"
[35] "35" "36"
[37] "37" "38"
[39] "39" "40"
[41] "41" "42"
[43] "43" "44"
[45] "45" "46"
[47] "47" "48"
[49] "49" "50"
[51] "51" ""
[53] "Basiliscus_vittatus" "Emoia_atrocostata"
[55] "Lygosoma_laterale" "Tropidurus_albemarlensis"
[57] "Tropidurus_semitaeniatus" "Varanus_bengalensis"
[59] "Intellagama_lesueurii" "Alligator_mississippiensis"
[61] "Caiman_latirostris" "Caiman_crocodilus"
[63] "Caiman_yacare" "Caretta_caretta"
[65] "Carettochelys_insculpta" "Chelodina_longicollis"
[67] "Chelonia_mydas" "Chelydra_serpentina"
[69] "Chrysemys_dorsalis" "Chrysemys_picta"
[71] "Clemmys_guttata" "Crocodylus_acutus"
[73] "Crocodylus_moreletii" "Crocodylus_johnstoni"
[75] "Crocodylus_niloticus" "Crocodylus_porosus"
[77] "Crocodylus_palustris" "Crotalus_horridus"
[79] "Cuora_flavomarginata" "Deirochelys_reticularia"
[81] "Dermatemys_mawii" "Emydoidea_blandingii"
[83] "Emydura_macquarii" "Emys_orbicularis"
[85] "Eretmochelys_imbricata" "Gopherus_agassizii"
[87] "Gopherus_berlandieri" "n86"
[89] "n87" "n88"
[91] "n89" "n90"
[93] "n91" "n92"
[95] "n93" "n94"
[97] "n95" "n96"
[99] "n97" "n98"
[101] "n99" "n100"
[103] "n101" "n102"
[105] "n103" "n104"
[107] "n105" "n106"
[109] "n107" "n108"
[111] "n109" "n110"
[113] "n111" "n112"
[115] "n113" "n114"
[117] "n115" "n116"
[119] "n117" "n118"
[121] "n119" "n120"
[123] "n121" "n122"
[125] "n123" "n124"
[127] "1"
It seems as though R isn't filling the data rows/columns consistently - in my species list, there are no gaps between each species, yet clearly here R thinks there are spaces (in this case numbers) between the species names. Does anyone have an idea of why this might be happening?
Thanks,
Greg
Related
I have a vector of integers from 0-9 and need all unique possible combinations of these consecutive vector elements, including the original elements.
> vec <- 0:9
> vec
[1] 0 1 2 3 4 5 6 7 8 9
The task is similar to this question. The major (and tricky) difference is that I only need consecutive combinations (e.g "0", "01", "012", ... "0123456789", ... "1", ... "123456789") and not non-consecutive combinations (such as "013").
How would I go about creating this subset of combinations?
Here is a nested sapply approach
unlist(
sapply(
seq_along(vec),
function(k) {
sapply(
k:length(vec),
function(l) paste0(vec[k:l], collapse = "")
)
}
)
)
which produces
[1] "0" "01" "012" "0123" "01234"
[6] "012345" "0123456" "01234567" "012345678" "0123456789"
[11] "1" "12" "123" "1234" "12345"
[16] "123456" "1234567" "12345678" "123456789" "2"
[21] "23" "234" "2345" "23456" "234567"
[26] "2345678" "23456789" "3" "34" "345"
[31] "3456" "34567" "345678" "3456789" "4"
[36] "45" "456" "4567" "45678" "456789"
[41] "5" "56" "567" "5678" "56789"
[46] "6" "67" "678" "6789" "7"
[51] "78" "789" "8" "89" "9"
Another option is sapply + embed
unlist(
sapply(
seq_along(vec),
function(k) {
do.call(paste0, rev(data.frame(embed(vec, k))))
}
)
)
which gives
[1] "0" "1" "2" "3" "4"
[6] "5" "6" "7" "8" "9"
[11] "01" "12" "23" "34" "45"
[16] "56" "67" "78" "89" "012"
[21] "123" "234" "345" "456" "567"
[26] "678" "789" "0123" "1234" "2345"
[31] "3456" "4567" "5678" "6789" "01234"
[36] "12345" "23456" "34567" "45678" "56789"
[41] "012345" "123456" "234567" "345678" "456789"
[46] "0123456" "1234567" "2345678" "3456789" "01234567"
[51] "12345678" "23456789" "012345678" "123456789" "0123456789"
Here is a one-liner with RcppAlgos (I am the author):
RcppAlgos::comboGeneral(10, 2, repetition = TRUE, FUN = function(r) {
paste((0:9)[r[1]:r[2]], collapse = "")
}, FUN.VALUE = "a")
[1] "0" "01" "012" "0123" "01234" "012345"
[7] "0123456" "01234567" "012345678" "0123456789" "1" "12"
[13] "123" "1234" "12345" "123456" "1234567" "12345678"
[19] "123456789" "2" "23" "234" "2345" "23456"
[25] "234567" "2345678" "23456789" "3" "34" "345"
[31] "3456" "34567" "345678" "3456789" "4" "45"
[37] "456" "4567" "45678" "456789" "5" "56"
[43] "567" "5678" "56789" "6" "67" "678"
[49] "6789" "7" "78" "789" "8" "89"
[55] "9"
Another possible solution, based on purrr::map:
library(tidyverse)
map(0:9, \(x) map(x:9, \(y) str_c(x:y, collapse = ""))) %>% unlist
#> [1] "0" "01" "012" "0123" "01234"
#> [6] "012345" "0123456" "01234567" "012345678" "0123456789"
#> [11] "1" "12" "123" "1234" "12345"
#> [16] "123456" "1234567" "12345678" "123456789" "2"
#> [21] "23" "234" "2345" "23456" "234567"
#> [26] "2345678" "23456789" "3" "34" "345"
#> [31] "3456" "34567" "345678" "3456789" "4"
#> [36] "45" "456" "4567" "45678" "456789"
#> [41] "5" "56" "567" "5678" "56789"
#> [46] "6" "67" "678" "6789" "7"
#> [51] "78" "789" "8" "89" "9"
Below is my DTM type data set:
View(sms_dtm_freq_train)
sms_dtm_freq_train[["dimnames"]]
$Docs
[1] "1" "2" "3" "4" "5" "6" "7" "8" "9" "10" "11" "12" "13" "14"
[15] "15" "16" "17" "18" "19" "20" "21" "22" "23" "24" "25" "26" "27" "28"
[29] "29" "30" "31" "32" "33" "34" "35" "36" "37" "38" "39" "40" "41" "42"
[43] "43" "44" "45" "46" "47" "48" "49" "50" "51" "52" "53" "54" "55" "56"
[57] "57" "58" "59" "60" "61" "62" "63" "64" "65" "66" "67" "68" "69" "70"
[71] "71" "72" "73" "74" "75" "76" "77" "78" "79" "80" "81" "82" "83" "84"
[85] "85" "86" "87" "88" "89" "90" "91" "92" "93" "94" "95" "96" "97" "98"
[99] "99" "100" "101" "102" "103" "104" "105" "106" "107" "108" "109" "110" "111" "112"
..........
[ reached getOption("max.print") -- omitted 4057 entries ]
$Terms
[1] "â£wk" "…" "–" "abiola" "abl" "abt"
[7] "accept" "access" "account" "across" "activ" "actual"
[13] "add" "address" "admir" "adult" "advanc" "aft"
[19] "afternoon" "aftr" "age" "ago" "ahead" "aight"
[25] "aint" "air" "aiyah" "alex" "almost" "alon"
[31] "alreadi" "alright" "alrit" "also" "alway" "amp"
[37] "angri" "announc" "anoth" "answer" "anybodi" "anymor"
[43] "anyon" "anyth" "anytim" "anyway" "apart" "app"
[49] "appli" "appoint" "appreci" "april" "ard" "area"
[55] "argument" "arm" "around" "arrang" "arrest" "arriv"
[61] "asap" "ask" "askd" "asleep" "ass" "attempt"
[67] "auction" "avail" "ave" "avoid" "await" "award"
[73] "away" "awesom" "babe" "babi" "back" "bad"
[79] "bag" "bak" "balanc" "bank" "bare" "bath"
[85] "batteri" "bcoz" "bcum" "bday" "beauti" "becom"
[91] "bed" "bedroom" "begin" "believ" "belli" "best"
[97] "better" "bid" "big" "bill" "bird" "birthday"
..............
[ reached getOption("max.print") -- omitted 1057 entries ]
When i run:
sms_train <- apply(sms_dtm_freq_train, MARGIN = 2, convert_counts)
I got the error messages below:
Error in apply(sms_dtm_freq_train, MARGIN = 2, convert_counts) :
dim(X) must have a positive length
I type the same codes as the text book "Machine Learning with R" 's , but i got the errors.
I am very confused.
Anyone can help me solve this problem ?
Thanks!
I am doing a scrape from the web "fotocasa" in Spain.
I download the item that contains the price doing the following:
url<-"https://www.fotocasa.es/es/comprar/casas/madrid-provincia/todas-las-zonas/l/3?latitude=40.415&longitude=-3.7104&combinedLocationIds=724,14,28,0,0,0,0,0,0"
idealista <- html(url)
price<-idealista %>%
html_nodes("span") %>% #item de precios
html_text()
And I have a vector similar to this:
>price
...
[97] "hace 1 hora" "198.500€"
[99] "198.500€" "€"
[101] "4 habs." "128 m²"
[103] "" ""
[105] "" ""
[107] "" "hace 1 hora"
[109] "6.000.000€" "6.000.000€"
[111] "€" "5 habs."
[113] "641 m²" ""
[115] "" ""
[117] "" ""
[119] "hace 1 hora" "1.800.000€"
[121] "1.800.000€" "€"
[123] "Ha bajado 100.000€" "5 habs."
[125] "800 m²" ""
[127] "" ""
[129] "" ""
[131] "hace 1 hora" "690.000€"
[133] "690.000€" "€"
[135] "Ha bajado 410.000€" "3 habs."
[137] "320 m²" ""
[139] "" ""
...
I want only the values that contains the euro symbol, so what I do is:
>price<-price[grepl("€",price)]
But what I obtain is:
> price
character(0)
Because It did not recognize the euro symbol. If I create a vector which contains the euro symbol and I use the function grepl, It works!, but If I tried directly from the scrapping it does not work.
Question
What should I do to make the "grepl" function recognizes this symbol directly from scraping?
Result:
The result must to be something like this:
> price
[1] "198.500€" "198.500€" "6.000.000€" "6.000.000€" "1.800.000€"
[6] "1.800.000€" "Ha bajado 100.000€" "690.000€" "690.000€" "Ha bajado 410.000€"
[11] "2.450.000€" "2.450.000€" "Ha bajado 450.000€" "1.350.000€" "1.350.000€"
[16] "1.200.000€" "1.200.000€" "2.275.000€" "2.275.000€" "2.200.000€"
[21] "2.200.000€" "540.000€" "540.000€" "975.000€" "975.000€"
[26] "3.750.000€" "3.750.000€" "1.100.000€" "1.100.000€" "1.800.000€"
We can use the unicode
res <- price[grepl("\u20AC",price, perl = TRUE)]
length(res)
#[1] 91
as the OP's code gives
any(grepl("€",price))
#[1] FALSE
I just generated a large netcdf file from WRF modeling. The file has 143 variables, 122 global attributes and 9 dimension. It covers a 7-day period with a time step of 6 hours. All I wanted to do is to cut out and discard everything for the first day (first 4 time steps) and keep the rest of files. I searched for transNcdfCutFiles function within the ncdf.tools package but was a bit confused at how to properly use it.
I am new to NetCDF processing by R. Any suggestions or help are greatly appreciated!
I could not attached the file as it is pretty large, but here is a list of the variables. Thanks in advance.
names(ncin$var)
[1] "Times" "XLAT"
[3] "XLONG" "LU_INDEX"
[5] "ZNU" "ZNW"
[7] "ZS" "DZS"
[9] "VAR_SSO" "U"
[11] "V" "W"
[13] "PH" "PHB"
[15] "T" "HFX_FORCE"
[17] "LH_FORCE" "TSK_FORCE"
[19] "HFX_FORCE_TEND" "LH_FORCE_TEND"
[21] "TSK_FORCE_TEND" "MU"
[23] "MUB" "NEST_POS"
[25] "P" "PB"
[27] "FNM" "FNP"
[29] "RDNW" "RDN"
[31] "DNW" "DN"
[33] "CFN" "CFN1"
[35] "THIS_IS_AN_IDEAL_RUN" "P_HYD"
[37] "Q2" "T2"
[39] "TH2" "PSFC"
[41] "U10" "V10"
[43] "RDX" "RDY"
[45] "RESM" "ZETATOP"
[47] "CF1" "CF2"
[49] "CF3" "ITIMESTEP"
[51] "XTIME" "QVAPOR"
[53] "QCLOUD" "QRAIN"
[55] "SHDMAX" "SHDMIN"
[57] "SNOALB" "TSLB"
[59] "SMOIS" "SH2O"
[61] "SMCREL" "SEAICE"
[63] "XICEM" "SFROFF"
[65] "UDROFF" "IVGTYP"
[67] "ISLTYP" "VEGFRA"
[69] "GRDFLX" "ACGRDFLX"
[71] "ACSNOM" "SNOW"
[73] "SNOWH" "CANWAT"
[75] "SSTSK" "COSZEN"
[77] "LAI" "VAR"
[79] "MAPFAC_M" "MAPFAC_U"
[81] "MAPFAC_V" "MAPFAC_MX"
[83] "MAPFAC_MY" "MAPFAC_UX"
[85] "MAPFAC_UY" "MAPFAC_VX"
[87] "MF_VX_INV" "MAPFAC_VY"
[89] "F" "E"
[91] "SINALPHA" "COSALPHA"
[93] "HGT" "TSK"
[95] "P_TOP" "T00"
[97] "P00" "TLP"
[99] "TISO" "TLP_STRAT"
[101] "P_STRAT" "MAX_MSTFX"
[103] "MAX_MSTFY" "RAINC"
[105] "RAINSH" "RAINNC"
[107] "SNOWNC" "GRAUPELNC"
[109] "HAILNC" "CLDFRA"
[111] "SWDOWN" "GLW"
[113] "SWNORM" "OLR"
[115] "XLAT_U" "XLONG_U"
[117] "XLAT_V" "XLONG_V"
[119] "ALBEDO" "CLAT"
[121] "ALBBCK" "EMISS"
[123] "NOAHRES" "TMN"
[125] "XLAND" "UST"
[127] "PBLH" "HFX"
[129] "QFX" "LH"
[131] "ACHFX" "ACLHF"
[133] "SNOWC" "SR"
[135] "SAVE_TOPO_FROM_REAL" "HFX_FDDA"
[137] "ISEEDARR_RAND_PERTURB" "ISEEDARR_SPPT"
[139] "ISEEDARR_SKEBS" "LANDMASK"
[141] "LAKEMASK" "SST"
[143] "SST_INPUT"
This is much easier to do from the command line using cdo :
cdo seltimestep,5/nsteps ifile ofile
where nsteps is the number of timesteps in the file.
I am developing a GNU Make file to allow me to compile all my LaTeX documents using a single command. To date I've been specifying the target on the command line but am tired of it.
My LaTex files are stored in a subfolder of the folder where I keep my PDF files.
My script is able to assemble the lists I need, but the code for the target and its rule list only processes the first LaTeX file found. I've been searching for hours now for an explanation on how to iterate through my file list in the target/rule section. My script is below:
rwildcard=${foreach d,${wildcard $1*},${call rwildcard,$d/,$2} ${filter ${subst *,%,$2},$d}}
# Sub-folder containing my LaTeX files
TEX_DIR=TeX
# Build a list of LaTeX files with the relative path included
TEX_SRCS_IN = ${call rwildcard, ${TEX_DIR}/, *.tex}
# Build a list of LaTeX files w/o paths
TEX_SRCS = $(TEX_SRCS_IN:$(TEX_DIR)/%=%)
# Build a list of PDF files that need to be generated
TEX_PDF_IN = ${foreach a, ${TEX_IN}, ${a:.tex=.pdf}}
# Then remove the path information
TEX_PDF = $(TEX_PDFIN:$(TEX_DIR)/%=%)
.PHONY: all
all: ${TEX_PDF}
${TEX_PDF} : ${TEX_SRCS_IN}
clear && \
echo "Input List=${TEX_SRCS_IN}" && \
echo "LaTeX Files=${TEX_SRCS}" && \
echo "PDFs=${TEX_PDF}" && \
cd ${TEX_DIR} && \
pdflatex ${TEX_SRCS} && \
cd ../ && \
mv $(TEX_DIR)/${TEX_PDF} .
I tried using a $(foreach doc,$(TEX_SRCS),pdflatex $(doc) && ) for the pdflatex processor and a similar statement for the move command, perhaps I didn't get the formatting right?
Below is the output I get from running the above. As can be seen, there are 6 files and the make file always makes the first file (GettingStarted.tex) but none of the rest.
If I remove the lines:
.PHONY: all
all: ${TEX_PDF}
then, once the first file is made, if it's up to date, the script tells me so and stops.
user#mars:~/Desktop/Project/Docs$ make -f Makefile
clear && \
echo "Input List= TeX/GettingStarted.tex TeX/GettingStarted_inst_Project_usb_Bridge.tex TeX/GettingToUse.tex TeX/DriverGettingStarted.tex TeX/RaspberryPiGettingStarted.tex TeX/instGettingStarted.tex" && \
echo "LaTeX Files=GettingStarted.tex GettingStarted_inst_Project_usb_Bridge.tex GettingToUse.tex DriverGettingStarted.tex RaspberryPiGettingStarted.tex instGettingStarted.tex" && \
echo "PDFs=GettingStarted.pdf GettingStarted_inst_Project_usb_Bridge.pdf GettingToUse.pdf DriverGettingStarted.pdf RaspberryPiGettingStarted.pdf instGettingStarted.pdf" && \
cd TeX && \
pdflatex GettingStarted.tex GettingStarted_inst_Project_usb_Bridge.tex GettingToUse.tex DriverGettingStarted.tex RaspberryPiGettingStarted.tex instGettingStarted.tex && \
cd ../ && \
mv TeX/GettingStarted.pdf GettingStarted_inst_Project_usb_Bridge.pdf GettingToUse.pdf DriverGettingStarted.pdf RaspberryPiGettingStarted.pdf instGettingStarted.pdf .
Input List= TeX/GettingStarted.tex TeX/GettingStarted_inst_Project_usb_Bridge.tex TeX/GettingToUse.tex TeX/DriverGettingStarted.tex TeX/RaspberryPiGettingStarted.tex TeX/instGettingStarted.tex
LaTeX Files=GettingStarted.tex GettingStarted_inst_Project_usb_Bridge.tex GettingToUse.tex DriverGettingStarted.tex RaspberryPiGettingStarted.tex instGettingStarted.tex
PDFs=GettingStarted.pdf GettingStarted_inst_Project_usb_Bridge.pdf GettingToUse.pdf DriverGettingStarted.pdf RaspberryPiGettingStarted.pdf instGettingStarted.pdf
This is pdfTeX, Version 3.1415926-2.5-1.40.14 (TeX Live 2013/Debian)
restricted \write18 enabled.
entering extended mode
(./GettingStarted.tex
LaTeX2e <2011/06/27>
Babel <3.9f> and hyphenation patterns for 2 languages loaded.
(/usr/share/texlive/texmf-dist/tex/latex/base/article.cls
Document Class: article 2007/10/19 v1.4h Standard LaTeX document class
(/usr/share/texlive/texmf-dist/tex/latex/base/size10.clo)) (./FillAFour.sty)
(/usr/share/texlive/texmf-dist/tex/latex/url/url.sty)
(/usr/share/texlive/texmf-dist/tex/latex/graphics/color.sty
(/usr/share/texlive/texmf-dist/tex/latex/latexconfig/color.cfg)
(/usr/share/texlive/texmf-dist/tex/latex/pdftex-def/pdftex.def
(/usr/share/texlive/texmf-dist/tex/generic/oberdiek/infwarerr.sty)
(/usr/share/texlive/texmf-dist/tex/generic/oberdiek/ltxcmds.sty)))
(/usr/share/texlive/texmf-dist/tex/latex/base/alltt.sty)
(/usr/share/texlive/texmf-dist/tex/latex/upquote/upquote.sty)
(/usr/share/texlive/texmf-dist/tex/latex/base/fontenc.sty
(/usr/share/texlive/texmf-dist/tex/latex/base/t1enc.def))
(/usr/share/texlive/texmf-dist/tex/latex/hyperref/hyperref.sty
(/usr/share/texlive/texmf-dist/tex/generic/oberdiek/hobsub-hyperref.sty
(/usr/share/texlive/texmf-dist/tex/generic/oberdiek/hobsub-generic.sty))
(/usr/share/texlive/texmf-dist/tex/latex/graphics/keyval.sty)
(/usr/share/texlive/texmf-dist/tex/generic/ifxetex/ifxetex.sty)
(/usr/share/texlive/texmf-dist/tex/latex/oberdiek/auxhook.sty)
(/usr/share/texlive/texmf-dist/tex/latex/oberdiek/kvoptions.sty)
(/usr/share/texlive/texmf-dist/tex/latex/hyperref/pd1enc.def)
(/usr/share/texlive/texmf-dist/tex/latex/latexconfig/hyperref.cfg)
Package hyperref Warning: Option `a4paper' is no longer used.
(/usr/share/texlive/texmf-dist/tex/latex/hyperref/backref.sty
(/usr/share/texlive/texmf-dist/tex/latex/oberdiek/rerunfilecheck.sty)))
Package hyperref Message: Driver: hpdftex.
(/usr/share/texlive/texmf-dist/tex/latex/hyperref/hpdftex.def)
(./GettingStarted.aux)
(/usr/share/texlive/texmf-dist/tex/context/base/supp-pdf.mkii
[Loading MPS to PDF converter (version 2006.09.02).]
) (/usr/share/texlive/texmf-dist/tex/latex/hyperref/nameref.sty
(/usr/share/texlive/texmf-dist/tex/generic/oberdiek/gettitlestring.sty))
(./GettingStarted.out) (./GettingStarted.out)
(/usr/share/texlive/texmf-dist/tex/latex/base/omscmr.fd)
(/usr/share/texlive/texmf-dist/tex/latex/base/t1cmtt.fd) (./GettingStarted.toc
[1{/var/lib/texmf/fonts/map/pdftex/updmap/pdftex.map}]) [2]
Overfull \hbox (26.10161pt too wide) in paragraph at lines 207--207
\T1/cmtt/m/n/10 sudo apt-get install libavahi-cil-dev libavahi-compat-libdnssd1
python-dev libicu-dev
[25] [26] [27] [28] [29] [30] (./GettingStarted.aux) )
kpathsea: Running mktexpk --mfmode / --bdpi 600 --mag 1+0/600 --dpi 600 ecbi1200
mktexpk: Running mf-nowin -progname=mf \mode:=ljfour; mag:=1+0/600; nonstopmode; input ecbi1200
This is METAFONT, Version 2.718281 (TeX Live 2013/Debian)
(/usr/share/texlive/texmf-dist/fonts/source/jkuserpen/ec/ecbi1200.mf
(/usr/share/texlive/texmf-dist/fonts/source/jkuserpen/ec/exbase.mf)
(/usr/share/texlive/texmf-dist/fonts/source/jkuserpen/ec/ecbi.mf
(/usr/share/texlive/texmf-dist/fonts/source/jkuserpen/ec/extextit.mf
Ok (/usr/share/texlive/texmf-dist/fonts/source/jkuserpen/ec/exaccess.mf
Ok) (/usr/share/texlive/texmf-dist/fonts/source/jkuserpen/ec/expseudo.mf
Ok) (/usr/share/texlive/texmf-dist/fonts/source/jkuserpen/ec/exileast.mf
Ok [158] [160] [161] [162] [163] [164] [165] [166] [167] [168] [169] [170]
[171] [172] [173] [174] [175] [176] [177] [178] [179] [180] [181] [182]
[183] [184] [185] [186] [187] [188])
(/usr/share/texlive/texmf-dist/fonts/source/jkuserpen/ec/exilwest.mf
Ok [224] [225] [226] [227] [228] [229] [230] [231] [232] [233] [234] [235]
[236] [237] [238] [239] [240] [241] [242] [243] [244] [245] [246] [247]
[248] [249] [250] [251] [252] [253] [254] [255])
(/usr/share/texlive/texmf-dist/fonts/source/jkuserpen/ec/exruwest.mf
Ok [192] [193] [194] [195] [196] [197] [198] [199] [200] [201] [202] [203]
[204] [205] [206] [207] [208] [209] [210] [211] [212] [213] [214] [215]
[216] [217] [218] [219] [220] [221] [222] [223])
(/usr/share/texlive/texmf-dist/fonts/source/jkuserpen/ec/exrueast.mf
Ok [128] [129] [130] [131] [132] [133] [134] [135] [136] [137] [138] [139]
[140] [141] [142] [143] [144] [145] [146] [147] [148] [149] [150] [151]
[152] [153] [154] [155] [156] [157])
(/usr/share/texlive/texmf-dist/fonts/source/jkuserpen/ec/exbraces.mf
Ok [94] [126] [23] [40] [41] [60] [124] [62] [91] [93] [92] [123] [125]
[95] [127] [32])
(/usr/share/texlive/texmf-dist/fonts/source/jkuserpen/ec/expunct.mf
Ok [14] [15] [19] [20] [13] [18] [33] [39] [42] [43] [44] [46] [47] [58]
[59] [61] [96] [189] [17] [45] [16] [21] [22])
(/usr/share/texlive/texmf-dist/fonts/source/jkuserpen/ec/exaccent.mf
Ok [0] [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12])
(/usr/share/texlive/texmf-dist/fonts/source/jkuserpen/ec/exsign.mf
Ok [24] [34] [35] [36] [37] [64] [191] [159])
(/usr/share/texlive/texmf-dist/fonts/source/jkuserpen/ec/exilig.mf
Ok [25] [26] [27] [28] [29] [30] [31])
(/usr/share/texlive/texmf-dist/fonts/source/jkuserpen/ec/exitalp.mf
Ok [38] [63] [190])
(/usr/share/texlive/texmf-dist/fonts/source/jkuserpen/ec/exrulett.mf
Ok [65] [66] [67] [68] [69] [70] [71] [72] [73] [74] [75] [76] [77] [78]
[79] [80] [81] [82] [83] [84] [85] [86] [87] [88] [89] [90])
(/usr/share/texlive/texmf-dist/fonts/source/jkuserpen/ec/exillett.mf
Ok [97] [98] [99] [100] [101] [102] [103] [104] [105] [106] [107] [108]
[109] [110] [111] [112] [113] [114] [115] [116] [117] [118] [119] [120]
[121] [122])
(/usr/share/texlive/texmf-dist/fonts/source/jkuserpen/ec/exidigit.mf
Ok [48] [49] [50] [51] [52] [53] [54] [55] [56] [57])
(/usr/share/texlive/texmf-dist/fonts/source/jkuserpen/ec/exiligtb.mf
Ok) ) ) )
(some charht values had to be adjusted by as much as 0.09164pt)
Font metrics written on ecbi1200.tfm.
Output written on ecbi1200.600gf (256 characters, 62216 bytes).
Transcript written on ecbi1200.log.
mktexpk: /tmp/texfonts/pk/ljfour/jkuserpen/ec/ecbi1200.600pk: successfully generated.
(see the transcript file for additional information) </tmp/texfonts/pk/ljfour/j
kuserpen/ec/ecbi1200.600pk>
kpathsea: Running mktexpk --mfmode / --bdpi 600 --mag 0+525/600 --dpi 525 ectt0800
mktexpk: Running mf-nowin -progname=mf \mode:=ljfour; mag:=0+525/600; nonstopmode; input ectt0800
This is METAFONT, Version 2.718281 (TeX Live 2013/Debian)
(/usr/share/texlive/texmf-dist/fonts/source/jkuserpen/ec/ecrm1200.mf
(/usr/share/texlive/texmf-dist/fonts/source/jkuserpen/ec/exbase.mf)
(/usr/share/texlive/texmf-dist/fonts/source/jkuserpen/ec/ecrm.mf
(/usr/share/texlive/texmf-dist/fonts/source/jkuserpen/ec/exroman.mf
Ok (/usr/share/texlive/texmf-dist/fonts/source/jkuserpen/ec/exaccess.mf
Ok) (/usr/share/texlive/texmf-dist/fonts/source/jkuserpen/ec/expseudo.mf
Ok) (/usr/share/texlive/texmf-dist/fonts/source/jkuserpen/ec/exruwest.mf
Ok [192] [193] [194] [195] [196] [197] [198] [199] [200] [201] [202] [203]
[204] [205] [206] [207] [208] [209] [210] [211] [212] [213] [214] [215]
[216] [217] [218] [219] [220] [221] [222] [223])
(/usr/share/texlive/texmf-dist/fonts/source/jkuserpen/ec/exrlwest.mf
Ok [224] [225] [226] [227] [228] [229] [230] [231] [232] [233] [234] [235]
[236] [237] [238] [239] [240] [241] [242] [243] [244] [245] [246] [247]
[248] [249] [250] [251] [252] [253] [254] [255])
(/usr/share/texlive/texmf-dist/fonts/source/jkuserpen/ec/exrueast.mf
Ok [128] [129] [130] [131] [132] [133] [134] [135] [136] [137] [138] [139]
[140] [141] [142] [143] [144] [145] [146] [147] [148] [149] [150] [151]
[152] [153] [154] [155] [156] [157])
(/usr/share/texlive/texmf-dist/fonts/source/jkuserpen/ec/exrleast.mf
Ok [158] [160] [161] [162] [163] [164] [165] [166] [167] [168] [169] [170]
[171] [172] [173] [174] [175] [176] [177] [178] [179] [180] [181] [182]
[183] [184] [185] [186] [187] [188])
(/usr/share/texlive/texmf-dist/fonts/source/jkuserpen/ec/exbraces.mf
Ok [94] [126] [23] [40] [41] [60] [124] [62] [91] [93] [92] [123] [125]
[95] [127] [32])
(/usr/share/texlive/texmf-dist/fonts/source/jkuserpen/ec/expunct.mf
Ok [14] [15] [19] [20] [13] [18] [33] [39] [42] [43] [44] [46] [47] [58]
[59] [61] [96] [189] [17] [45] [16] [21] [22])
(/usr/share/texlive/texmf-dist/fonts/source/jkuserpen/ec/exaccent.mf
Ok [0] [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12])
(/usr/share/texlive/texmf-dist/fonts/source/jkuserpen/ec/exsign.mf
Ok [24] [34] [35] [36] [37] [64] [191] [159])
(/usr/share/texlive/texmf-dist/fonts/source/jkuserpen/ec/exrlig.mf
Ok [25] [26] [28] [27] [29] [30] [31])
(/usr/share/texlive/texmf-dist/fonts/source/jkuserpen/ec/exromp.mf
Ok [38] [63] [190])
(/usr/share/texlive/texmf-dist/fonts/source/jkuserpen/ec/exrulett.mf
Ok [65] [66] [67] [68] [69] [70] [71] [72] [73] [74] [75] [76] [77] [78]
[79] [80] [81] [82] [83] [84] [85] [86] [87] [88] [89] [90])
(/usr/share/texlive/texmf-dist/fonts/source/jkuserpen/ec/exrllett.mf
Ok [97] [98] [99] [100] [101] [102] [103] [104] [105] [106] [107] [108]
[109] [110] [111] [112] [113] [114] [115] [116] [117] [118] [119] [120]
[121] [122])
(/usr/share/texlive/texmf-dist/fonts/source/jkuserpen/ec/exrdigit.mf
Ok [48] [49] [50] [51] [52] [53] [54] [55] [56] [57])
(/usr/share/texlive/texmf-dist/fonts/source/jkuserpen/ec/exrligtb.mf
Ok) ) ) )
(some charht values had to be adjusted by as much as 0.07143pt)
Font metrics written on ecrm1200.tfm.
Output written on ecrm1200.600gf (256 characters, 60320 bytes).
Transcript written on ecrm1200.log.
mktexpk: /tmp/texfonts/pk/ljfour/jkuserpen/ec/ecrm1200.600pk: successfully generated.
</tmp/texfonts/pk/ljfour/jkuserpen/ec/ecrm1200.600pk>
kpathsea: Running mktexpk --mfmode / --bdpi 600 --mag 1+0/600 --dpi 600 ecrm1728
mktexpk: Running mf-nowin -progname=mf \mode:=ljfour; mag:=1+0/600; nonstopmode; input ecrm1728
This is METAFONT, Version 2.718281 (TeX Live 2013/Debian)
(/usr/share/texlive/texmf-dist/fonts/source/jkuserpen/ec/ecrm1728.mf
(/usr/share/texlive/texmf-dist/fonts/source/jkuserpen/ec/exbase.mf)
(/usr/share/texlive/texmf-dist/fonts/source/jkuserpen/ec/ecrm.mf
(/usr/share/texlive/texmf-dist/fonts/source/jkuserpen/ec/exroman.mf
Ok (/usr/share/texlive/texmf-dist/fonts/source/jkuserpen/ec/exaccess.mf
Ok) (/usr/share/texlive/texmf-dist/fonts/source/jkuserpen/ec/expseudo.mf
Ok) (/usr/share/texlive/texmf-dist/fonts/source/jkuserpen/ec/exruwest.mf
Ok [192] [193] [194] [195] [196] [197] [198] [199] [200] [201] [202] [203]
[204] [205] [206] [207] [208] [209] [210] [211] [212] [213] [214] [215]
[216] [217] [218] [219] [220] [221] [222] [223])
(/usr/share/texlive/texmf-dist/fonts/source/jkuserpen/ec/exrlwest.mf
Ok [224] [225] [226] [227] [228] [229] [230] [231] [232] [233] [234] [235]
[236] [237] [238] [239] [240] [241] [242] [243] [244] [245] [246] [247]
[248] [249] [250] [251] [252] [253] [254] [255])
(/usr/share/texlive/texmf-dist/fonts/source/jkuserpen/ec/exrueast.mf
Ok [128] [129] [130] [131] [132] [133] [134] [135] [136] [137] [138] [139]
[140] [141] [142] [143] [144] [145] [146] [147] [148] [149] [150] [151]
[152] [153] [154] [155] [156] [157])
(/usr/share/texlive/texmf-dist/fonts/source/jkuserpen/ec/exrleast.mf
Ok [158] [160] [161] [162] [163] [164] [165] [166] [167] [168] [169] [170]
[171] [172] [173] [174] [175] [176] [177] [178] [179] [180] [181] [182]
[183] [184] [185] [186] [187] [188])
(/usr/share/texlive/texmf-dist/fonts/source/jkuserpen/ec/exbraces.mf
Ok [94] [126] [23] [40] [41] [60] [124] [62] [91] [93] [92] [123] [125]
[95] [127] [32])
(/usr/share/texlive/texmf-dist/fonts/source/jkuserpen/ec/expunct.mf
Ok [14] [15] [19] [20] [13] [18] [33] [39] [42] [43] [44] [46] [47] [58]
[59] [61] [96] [189] [17] [45] [16] [21] [22])
(/usr/share/texlive/texmf-dist/fonts/source/jkuserpen/ec/exaccent.mf
Ok [0] [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12])
(/usr/share/texlive/texmf-dist/fonts/source/jkuserpen/ec/exsign.mf
Ok [24] [34] [35] [36] [37] [64] [191] [159])
(/usr/share/texlive/texmf-dist/fonts/source/jkuserpen/ec/exrlig.mf
Ok [25] [26] [28] [27] [29] [30] [31])
(/usr/share/texlive/texmf-dist/fonts/source/jkuserpen/ec/exromp.mf
Ok [38] [63] [190])
(/usr/share/texlive/texmf-dist/fonts/source/jkuserpen/ec/exrulett.mf
Ok [65] [66] [67] [68] [69] [70] [71] [72] [73] [74] [75] [76] [77] [78]
[79] [80] [81] [82] [83] [84] [85] [86] [87] [88] [89] [90])
(/usr/share/texlive/texmf-dist/fonts/source/jkuserpen/ec/exrllett.mf
Ok [97] [98] [99] [100] [101] [102] [103] [104] [105] [106] [107] [108]
[109] [110] [111] [112] [113] [114] [115] [116] [117] [118] [119] [120]
[121] [122])
(/usr/share/texlive/texmf-dist/fonts/source/jkuserpen/ec/exrdigit.mf
Ok [48] [49] [50] [51] [52] [53] [54] [55] [56] [57])
(/usr/share/texlive/texmf-dist/fonts/source/jkuserpen/ec/exrligtb.mf
Ok) ) ) )
(some charht values had to be adjusted by as much as 0.0972pt)
Font metrics written on ecrm1728.tfm.
Output written on ecrm1728.600gf (256 characters, 84608 bytes).
Transcript written on ecrm1728.log.
mktexpk: /tmp/texfonts/pk/ljfour/jkuserpen/ec/ecrm1728.600pk: successfully generated.
</tmp/texfonts/pk/lj
four/jkuserpen/ec/ecrm1728.600pk></usr/share/texlive/texmf-dist/fonts/type1/publ
ic/amsfonts/cm/cmmi10.pfb></usr/share/texlive/texmf-dist/fonts/type1/public/ams
fonts/cm/cmsy10.pfb></usr/share/texlive/texmf-dist/fonts/type1/public/amsfonts/
cm/cmsy9.pfb>
Output written on GettingStarted.pdf (30 pages, 282962 bytes).
Transcript written on GettingStarted.log.
mv: cannot stat ‘GettingStarted_inst_Project_usb_Bridge.pdf’: No such file or directory
mv: cannot stat ‘GettingToUse.pdf’: No such file or directory
mv: cannot stat ‘DriverGettingStarted.pdf’: No such file or directory
mv: cannot stat ‘RaspberryPiGettingStarted.pdf’: No such file or directory
mv: cannot stat ‘instGettingStarted.pdf’: No such file or directory
make: *** [GettingStarted_inst_Project_usb_Bridge.pdf] Error 1
user#mars:~/Desktop/Project/Docs$
Looks to me like the .PHONY: all all: ${TEX_PDF} lines aren't producing the behaviour I want, but the main problem for me is that still; only the first file is processed.
How do I make the target and its rule list iterate through the whole list of files?
UPDATED
Almost fixed now, The problem was with the dependencies of ${TEX_PDF}.
It's making all the files now, however the dependency calculation is not working correctly.
Removing ${TEX_IN} and leaving it blank, and changing the way the dependency is referenced inside the rule (using the target's name ($#) and substituting the extension) made it work for a one shot run.
Changing the dependency to $(TEX_DIR)/$(#:.pdf=.tex) causes it to make ALL the files each run.
I've added a line to clean up the pdflatex auto-generated files ( .out, .log, .toc, and .aux) as a convenience. It can be edited or removed if not required.
rwildcard=${foreach d,${wildcard $1*},${call rwildcard,$d/,$2} ${filter ${subst *,%,$2},$d}}
TEX_DIR=TeX # Sub-folder containing TEX files
TEX_SRCS_IN = ${call rwildcard, ${TEX_DIR}/, *.tex} # 'TEX' List with paths
TEX_PDF_IN = ${foreach a, ${TEX_SRCS_IN}, ${a:.tex=.pdf} } # 'PDF' List with paths
TEX_PDF = $(TEX_PDF_IN:$(TEX_DIR)/%=%) # 'PDF' List without paths
.PHONY: all
all: ${TEX_PDF}
${TEX_PDF} : $(TEX_DIR)/$(#:.pdf=.tex)
cd ${TEX_DIR} && \
pdflatex $(#:.pdf=.tex) && \
rm $(#:.pdf=.out) $(#:.pdf=.log) $(#:.pdf=.toc) $(#:.pdf=.aux) && \
cd ../ && \
mv $(TEX_DIR)/$# .
This is probably one of the top 3 most commonly asked questions about make. When you run make with no arguments it only builds the first target listed in the makefile. If you want it to build more than one target, you need to put a new target at the beginning of your makefile that depends on the other targets you want built.
So, add this line before the first target:
.PHONY: all
all: ${TEX_PDF}
ETA:
Only the first file is processed, because the end result of the processing the first file is a failure: make: *** [GettingStarted_inst_Project_usb_Bridge.pdf] Error 1. By default, make will stop after the first failure and won't build anything more. If you want it to keep going, you can run make -k.
But, I recommend you fix your failure, then it will continue.
The problem is the end of your rule, where you say:
mv $(TEX_DIR)/${TEX_PDF} .
TEX_PDF contains a list of files, so this expands to (as you can see from the output):
mv TeX/GettingStarted.pdf GettingStarted_inst_Project_usb_Bridge.pdf GettingToUse.pdf DriverGettingStarted.pdf RaspberryPiGettingStarted.pdf instGettingStarted.pdf .
which is obviously not what you want. You want to move just the one file that you're creating, which is given to you as an automatic variable $#.
Finally fixed. Working now as I intended it to.
Changed the target definition to the generic form %.pdf with dependency defined similarly but in a subfolder ${TEX_DIR}/%.tex. Added a target/rule for the dependency using a NO-OP command.
# Usage:
# From the ./Docs folder
#
# Scan the TeX folder and make all necessary PDF's
# make -f Makefile
#
# Make a specific TEX file
# make -f Makefile TEX_SRCS_IN=<filename>.tex
#
#
rwildcard=${foreach d,${wildcard $1*},${call rwildcard,$d/,$2} ${filter ${subst *,%,$2},$d}}
TEX_DIR=TeX # Sub-folder containing TEX files
TEX_SRCS_IN = ${call rwildcard, ${TEX_DIR}/, *.tex} # 'TEX' List with paths
TEX_PDF_IN = ${foreach a, ${TEX_SRCS_IN}, ${a:.tex=.pdf} } # 'PDF' List with paths
TEX_PDF = $(TEX_PDF_IN:$(TEX_DIR)/%=%) # 'PDF' List without paths
.PHONY: all
all: ${TEX_PDF}
%.pdf : ${TEX_DIR}/%.tex
cd ${TEX_DIR} && \
pdflatex $(#:.pdf=.tex) && \
rm $(#:.pdf=.out) $(#:.pdf=.log) $(#:.pdf=.toc) $(#:.pdf=.aux) && \
cd ../ && \
mv $(TEX_DIR)/$# .
${TEX_DIR}/%.tex:
#: