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.
Related
I have a Seurat object with defined clusters. I need to extract a list of all genes that are expressed by at least 10% of cells in my cluster. I need to repeat it for every cluster that I have, separately.
I know one code that could potentially extract genes expressed by at least 10% of cells from the whole Seurat:
genes.to.keep <- Matrix::rowSums(Monocyte.integrated#assays$RNA#counts > 0) >= floor(0.1 * ncol(Monocyte.integrated#assays$RNA#counts))
counts.sub <- Monocyte.integrated#assays$RNA#counts[genes.to.keep,]
But this is not what I want. And I'm not sure how to modify it to include cluster names (considering it's correct).
I store the cluster names in the metadata variable called "cluster_names".
I would appreciate any help
BW
You could use lapply to iterate over the factor levels of your clusters to subset and filter them individually and use setNames to name the resulting list. Below is a reproducible example:
library(Seurat)
data("pbmc_small")
pbmc_small <- FindClusters(pbmc_small, resolution = 1)
names(pbmc_small#meta.data)[names(pbmc_small#meta.data)=="seurat_clusters"] <- "cluster_names"
levels(pbmc_small$cluster_names) <- paste0("cluster_", seq_along(levels(pbmc_small$cluster_names)))
setNames(lapply(levels(pbmc_small$cluster_names), function(x) {
p <- subset(pbmc_small, cluster_names==x)
rownames(p)[Matrix::rowSums(p#assays$RNA#counts > 0) >= .1*dim(p)[2]]
}), levels(pbmc_small$cluster_names))
#> $cluster_1
#> [1] "CD79B" "HLA-DRA" "LTB" "SP100" "PPP3CC" "CXCR4"
#> [7] "STX10" "SNHG7" "CD3D" "NOSIP" "SAFB2" "CD2"
#> [13] "IL7R" "PIK3IP1" "MPHOSPH6" "KHDRBS1" "MAL" "CCR7"
#> [19] "THYN1" "TAF7" "LDHB" "TMEM123" "EPC1" "EIF4A2"
#> [25] "CD3E" "TMUB1" "BLOC1S4" "SRSF7" "ACAP1" "TNFAIP8"
#> [31] "CD7" "TAGAP" "DNAJB1" "ASNSD1" "S1PR4" "CTSW"
#> [37] "GZMK" "NKG7" "IL32" "DNAJC2" "LYAR" "CST7"
#> [43] "LCK" "CCL5" "HNRNPH1" "SSR2" "GIMAP1" "MMADHC"
#> [49] "CD8A" "GYPC" "HNRNPF" "RPL7L1" "KLRG1" "CRBN"
#> [55] "SATB1" "PMPCB" "NRBP1" "TCF7" "HNRNPA3" "S100A8"
#> [61] "S100A9" "LYZ" "FCN1" "TYROBP" "NFKBIA" "TYMP"
#> [67] "CTSS" "TSPO" "CTSB" "LGALS1" "BLVRA" "LGALS3"
#> [73] "IFI6" "HLA-DPA1" "CST3" "GSTP1" "EIF3G" "VPS28"
#> [79] "ZFP36L1" "ANXA2" "HSP90AA1" "LST1" "AIF1" "PSAP"
#> [85] "YWHAB" "MYO1G" "SAT1" "RGS2" "FCGR3A" "S100A11"
#> [91] "FCER1G" "IFITM2" "COTL1" "LGALS9" "CD68" "RHOC"
#> [97] "CARD16" "COPS6" "PPBP" "GPX1" "TPM4" "PF4"
#> [103] "SDPR" "NRGN" "SPARC" "GNG11" "CLU" "HIST1H2AC"
#> [109] "NCOA4" "GP9" "FERMT3" "ODC1" "CD9" "RUFY1"
#> [115] "TUBB1" "TALDO1" "TREML1" "NGFRAP1" "PGRMC1" "CA2"
#> [121] "ITGA2B" "MYL9" "TMEM40" "PARVB" "PTCRA" "ACRBP"
#> [127] "TSC22D1" "VDAC3" "GZMB" "GZMA" "GNLY" "FGFBP2"
#> [133] "AKR1C3" "CCL4" "PRF1" "GZMH" "XBP1" "GZMM"
#> [139] "PTGDR" "IGFBP7" "TTC38" "KLRD1" "ARHGDIA" "IL2RB"
#> [145] "CLIC3" "PPP1R18" "CD247" "ALOX5AP" "XCL2" "C12orf75"
#> [151] "RARRES3" "PCMT1" "LAMP1" "SPON2"
#>
#> $cluster_2
#> [1] "CD79B" "CD79A" "HLA-DRA" "HLA-DQB1"
#> [5] "HVCN1" "HLA-DMB" "LTB" "SP100"
#> [9] "NCF1" "EAF2" "FAM96A" "CXCR4"
#> [13] "STX10" "SNHG7" "NT5C" "NOSIP"
#> [17] "IL7R" "KHDRBS1" "TAF7" "LDHB"
#> [21] "TMEM123" "EIF4A2" "TMUB1" "BLOC1S4"
#> [25] "SRSF7" "TNFAIP8" "TAGAP" "DNAJB1"
#> [29] "S1PR4" "NKG7" "IL32" "DNAJC2"
#> [33] "LYAR" "CCL5" "SSR2" "GIMAP1"
#> [37] "MMADHC" "HNRNPF" "RPL7L1" "HNRNPA3"
#> [41] "S100A8" "S100A9" "LYZ" "CD14"
#> [45] "FCN1" "TYROBP" "ASGR1" "NFKBIA"
#> [49] "TYMP" "CTSS" "TSPO" "RBP7"
#> [53] "CTSB" "LGALS1" "FPR1" "VSTM1"
#> [57] "BLVRA" "MPEG1" "BID" "SMCO4"
#> [61] "CFD" "LINC00936" "LGALS2" "MS4A6A"
#> [65] "FCGRT" "LGALS3" "NUP214" "SCO2"
#> [69] "IL17RA" "IFI6" "HLA-DPA1" "FCER1A"
#> [73] "CLEC10A" "HLA-DMA" "RGS1" "HLA-DPB1"
#> [77] "HLA-DQA1" "RNF130" "HLA-DRB5" "HLA-DRB1"
#> [81] "CST3" "IL1B" "POP7" "HLA-DQA2"
#> [85] "GSTP1" "EIF3G" "VPS28" "LY86"
#> [89] "ZFP36L1" "ANXA2" "GRN" "CFP"
#> [93] "HSP90AA1" "LST1" "AIF1" "PSAP"
#> [97] "YWHAB" "MYO1G" "SAT1" "RGS2"
#> [101] "SERPINA1" "IFITM3" "FCGR3A" "LILRA3"
#> [105] "S100A11" "FCER1G" "TNFRSF1B" "IFITM2"
#> [109] "WARS" "IFI30" "MS4A7" "C5AR1"
#> [113] "HCK" "COTL1" "LGALS9" "CD68"
#> [117] "RP11-290F20.3" "RHOC" "CARD16" "LRRC25"
#> [121] "COPS6" "ADAR" "GPX1" "TPM4"
#> [125] "NRGN" "NCOA4" "FERMT3" "ODC1"
#> [129] "TALDO1" "PARVB" "VDAC3" "GZMB"
#> [133] "XBP1" "IGFBP7" "ARHGDIA" "PPP1R18"
#> [137] "ALOX5AP" "RARRES3" "PCMT1" "SPON2"
#>
#> $cluster_3
#> [1] "MS4A1" "CD79B" "CD79A" "HLA-DRA"
#> [5] "TCL1A" "HLA-DQB1" "HVCN1" "HLA-DMB"
#> [9] "LTB" "LINC00926" "FCER2" "SP100"
#> [13] "NCF1" "PPP3CC" "EAF2" "PPAPDC1B"
#> [17] "CD19" "KIAA0125" "CYB561A3" "CD180"
#> [21] "RP11-693J15.5" "FAM96A" "CXCR4" "STX10"
#> [25] "SNHG7" "NT5C" "BANK1" "IGLL5"
#> [29] "CD200" "FCRLA" "CD3D" "NOSIP"
#> [33] "CD2" "IL7R" "PIK3IP1" "KHDRBS1"
#> [37] "THYN1" "TAF7" "LDHB" "TMEM123"
#> [41] "CCDC104" "EPC1" "EIF4A2" "CD3E"
#> [45] "SRSF7" "ACAP1" "TNFAIP8" "CD7"
#> [49] "TAGAP" "DNAJB1" "S1PR4" "CTSW"
#> [53] "GZMK" "NKG7" "IL32" "DNAJC2"
#> [57] "LYAR" "CST7" "LCK" "CCL5"
#> [61] "HNRNPH1" "SSR2" "GIMAP1" "MMADHC"
#> [65] "CD8A" "PTPN22" "GYPC" "HNRNPF"
#> [69] "RPL7L1" "CRBN" "SATB1" "SIT1"
#> [73] "PMPCB" "NRBP1" "TCF7" "HNRNPA3"
#> [77] "S100A9" "LYZ" "FCN1" "TYROBP"
#> [81] "NFKBIA" "TYMP" "CTSS" "TSPO"
#> [85] "CTSB" "LGALS1" "BLVRA" "MPEG1"
#> [89] "BID" "CFD" "LINC00936" "LGALS2"
#> [93] "MS4A6A" "FCGRT" "LGALS3" "SCO2"
#> [97] "HLA-DPA1" "FCER1A" "CLEC10A" "HLA-DMA"
#> [101] "RGS1" "HLA-DPB1" "HLA-DQA1" "RNF130"
#> [105] "HLA-DRB5" "HLA-DRB1" "CST3" "IL1B"
#> [109] "POP7" "HLA-DQA2" "CD1C" "GSTP1"
#> [113] "EIF3G" "VPS28" "LY86" "ZFP36L1"
#> [117] "ZNF330" "ANXA2" "GRN" "CFP"
#> [121] "HSP90AA1" "FUOM" "LST1" "AIF1"
#> [125] "PSAP" "YWHAB" "MYO1G" "SAT1"
#> [129] "RGS2" "SERPINA1" "IFITM3" "FCGR3A"
#> [133] "S100A11" "FCER1G" "TNFRSF1B" "IFITM2"
#> [137] "WARS" "IFI30" "MS4A7" "HCK"
#> [141] "COTL1" "LGALS9" "CD68" "RHOC"
#> [145] "CARD16" "LRRC25" "COPS6" "ADAR"
#> [149] "GPX1" "TPM4" "NCOA4" "FERMT3"
#> [153] "ODC1" "RUFY1" "TALDO1" "VDAC3"
#> [157] "GZMA" "GNLY" "FGFBP2" "PRF1"
#> [161] "XBP1" "GZMM" "PTGDR" "ARHGDIA"
#> [165] "PPP1R18" "CD247" "ALOX5AP" "XCL2"
#> [169] "C12orf75" "RARRES3" "PCMT1" "SPON2"
Created on 2021-03-26 by the reprex package (v1.0.0)
XGBoost gives me 100% prediction accuracy, for a binary classification problem. This seems too good to be true. How can i solve it?
I am using a normalized dataset (max-min or z-score), already split it as training and validation set, and I am using training set values in order to predict the validation set. In both subsets, data is very alike obviously, but there is nothing i can do about it. I also avoid look-forward bias. What else can be the possible reason for 100% accuracy and how can i solve it? Thank you very much!
My code is:
train_x=data.matrix(tmp[,-40])
train_y=tmp[,40]
test_x=data.matrix(tmp2[,-40])
test_y=tmp2[,40]
test_y=as.factor(test_y)
xgb_train = xgb.DMatrix(data=train_x, label=train_y)
xgb_test = xgb.DMatrix(data=test_x, label=test_y)
set.seed(12345)
xgbc=xgboost(data=xgb_train, max.depth=4, nrounds=200)
print(xgbc)
preds=predict(xgbc,test_x)
preds[preds>0.5] = "1"
pred_y = as.factor(test_y)
print(pred_y)
cm = confusionMatrix(test_y, pred_y)
print(cm)
Code output is:
> xgbc=xgboost(data=xgb_train,max.depth=4, nrounds=200, nthread=2, eta=1,
objective="binary:logistic")
[1] train-error:0.415888
[2] train-error:0.390654
[3] train-error:0.368692
[4] train-error:0.323832
[5] train-error:0.307944
[6] train-error:0.278037
[7] train-error:0.259346
[8] train-error:0.240187
[9] train-error:0.232710
[10] train-error:0.224766
[11] train-error:0.208879
[12] train-error:0.192523
[13] train-error:0.185981
[14] train-error:0.177103
[15] train-error:0.168224
[16] train-error:0.157944
[17] train-error:0.141121
[18] train-error:0.132243
[19] train-error:0.132243
[20] train-error:0.121495
[21] train-error:0.109346
[22] train-error:0.101869
[23] train-error:0.100000
[24] train-error:0.090654
[25] train-error:0.080374
[26] train-error:0.078505
[27] train-error:0.069626
[28] train-error:0.063084
[29] train-error:0.066822
[30] train-error:0.056542
[31] train-error:0.044860
[32] train-error:0.042991
[33] train-error:0.039252
[34] train-error:0.037383
[35] train-error:0.029439
[36] train-error:0.023832
[37] train-error:0.018692
[38] train-error:0.011682
[39] train-error:0.011215
[40] train-error:0.010748
[41] train-error:0.009346
[42] train-error:0.007477
[43] train-error:0.005140
[44] train-error:0.005140
[45] train-error:0.006075
[46] train-error:0.003271
[47] train-error:0.002804
[48] train-error:0.003271
[49] train-error:0.002804
[50] train-error:0.002804
[51] train-error:0.002336
[52] train-error:0.002336
[53] train-error:0.002336
[54] train-error:0.002336
[55] train-error:0.000935
[56] train-error:0.000467
[57] train-error:0.000000
[58] train-error:0.000000
[59] train-error:0.000000
[60] train-error:0.000935
[61] train-error:0.000467
[62] train-error:0.000000
[63] train-error:0.000000
[64] train-error:0.000000
[65] train-error:0.000000
[66] train-error:0.000000
[67] train-error:0.000000
[68] train-error:0.000000
[69] train-error:0.000000
[70] train-error:0.000000
[71] train-error:0.000000
[72] train-error:0.000000
[73] train-error:0.000000
[74] train-error:0.000000
[75] train-error:0.000000
[76] train-error:0.000000
[77] train-error:0.000000
[78] train-error:0.000000
[79] train-error:0.000000
[80] train-error:0.000000
[81] train-error:0.000000
[82] train-error:0.000000
[83] train-error:0.000000
[84] train-error:0.000000
[85] train-error:0.000000
[86] train-error:0.000000
[87] train-error:0.000000
[88] train-error:0.000000
[89] train-error:0.000000
[90] train-error:0.000000
[91] train-error:0.000000
[92] train-error:0.000000
[93] train-error:0.000000
[94] train-error:0.000000
[95] train-error:0.000000
[96] train-error:0.000000
[97] train-error:0.000000
[98] train-error:0.000000
[99] train-error:0.000000
[100] train-error:0.000000
> print(xgbc)
##### xgb.Booster
raw: 186.6 Kb
call:
xgb.train(params = params, data = dtrain, nrounds = nrounds,
watchlist = watchlist, verbose = verbose, print_every_n = print_every_n,
early_stopping_rounds = early_stopping_rounds, maximize = maximize,
save_period = save_period, save_name = save_name, xgb_model = xgb_model,
callbacks = callbacks, max.depth = 4, nthread = 2, eta = 1,
objective = "binary:logistic")
params (as set within xgb.train):
max_depth = "4", nthread = "2", eta = "1", objective = "binary:logistic",
silent = "1"
xgb.attributes:
niter
callbacks:
cb.print.evaluation(period = print_every_n)
cb.evaluation.log()
# of features: 38
niter: 200
nfeatures : 38
evaluation_log:
iter train_error
1 0.415888
2 0.390654
---
199 0.000000
200 0.000000
preds=predict(xgbc,test_x)
> preds
[1] 7.273692e-01 1.643806e-02 3.032141e-04 9.764441e-01 9.691942e-02
5.343258e-01 9.090783e-01
[8] 5.609832e-01 4.061035e-01 1.105066e-01 4.406907e-03 9.946358e-01
7.929156e-01 4.119191e-03
[15] 3.098451e-01 2.945659e-04 3.966548e-03 7.829595e-01 1.698021e-01
9.574184e-01 7.132806e-01
[22] 1.044374e-01 9.024003e-01 5.769060e-01 5.096554e-02 1.751429e-01
9.982671e-01 9.993696e-01
[29] 6.521277e-01 5.780852e-03 4.867651e-01 9.707865e-01 8.398834e-01
1.825542e-01 1.134274e-01
[36] 7.154977e-02 5.450470e-01 1.047506e-01 3.099218e-03 2.268739e-01
9.023346e-01 8.026977e-01
[43] 3.844074e-01 4.463347e-01 8.543612e-01 9.998935e-01 8.699111e-01
6.243381e-02 1.137973e-01
[50] 9.385086e-01 9.994442e-01 8.376440e-01 8.492180e-01 3.362629e-04
4.316351e-02 9.234415e-01
[57] 8.924388e-01 9.977444e-01 6.618840e-02 2.186051e-04 1.647688e-03
8.050095e-03 6.535615e-01
[64] 4.707330e-01 9.138927e-01 5.177013e-02 3.349773e-04 9.392425e-01
4.979803e-02 2.934091e-01
[71] 8.948106e-01 9.854530e-01 9.795361e-02 9.275551e-01 5.865968e-01
9.746857e-01 3.859183e-01
[78] 1.194406e-01 3.267710e-01 6.294726e-01 9.250816e-01 6.118813e-02
3.394562e-01 7.257250e-04
[85] 8.491386e-01 7.081388e-03 3.268852e-01 8.931246e-01 2.204458e-01
8.818560e-01 9.923303e-01
[92] 9.845840e-01 7.688413e-01 9.803721e-01 9.958567e-01 9.500723e-01
7.733757e-01 9.368727e-01
[99] 3.276393e-01 9.952766e-01 2.130413e-01 8.992375e-02 8.594028e-02
8.160641e-01 9.915828e-01
> preds[preds>0.5] = "1"
> preds[preds<=0.5]= "0"
> pred_y = as.factor(test_y)
> print(pred_y)
[1] 1 1 0 0 1 1 0 1 1 1 1 1 1 1 0 1 1 1 1 0 0 0 0 0 1 0 0 1 0 0 1 0 0 1 1 1
1 0 1 1 1 0 1 0 1 1 1 1 0 0
[51] 1 1 0 1 0 1 1 0 1 1 1 0 0 0 1 1 0 1 1 0 0 0 0 0 1 1 0 0 0 0 1 0 1 0 1 1
1 1 0 0 1 0 0 0 1 1 1 1 0 1
> test_y=as.factor(test_y)
> cm = confusionMatrix(test_y, pred_y)
> print(cm)
Confusion Matrix and Statistics
Reference
Prediction 0 1
0 421 0
1 0 497
Accuracy : 1
95% CI : (0.996, 1)
No Information Rate : 0.5414
P-Value [Acc > NIR] : < 2.2e-16
Kappa : 1
Mcnemar's Test P-Value : NA
Sensitivity : 1.0000
Specificity : 1.0000
Pos Pred Value : 1.0000
Neg Pred Value : 1.0000
Prevalence : 0.4586
Detection Rate : 0.4586
Detection Prevalence : 0.4586
Balanced Accuracy : 1.0000
'Positive' Class : 0
It seems like you're seriously overfitting to your training data, and you should use cross validation instead of just a naive train-test split. There are a number of ways to do this. You can do it with xgb.cv inside of the xgboost package in R, for one. I prefer Tidymodels, but that's a different rabbit hole. My guess is that if you tune a parameter like gamma, you'll end up with non-zero loss because the gamma > 0 will help prevent overfitting by pruning your trees. You can also help prevent overfitting by growing fewer, shallower trees, subsampling features, etc. All of these options can be tuned with xgb.cv
Try checking the correlation of the predictor variables with the output. Try removing variables with high correlation because it introduces high bias. This solved my issue with 100% accuracy.
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'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
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:
#: