Re: [R] code for year month day hr format
Part of it is pasted below YEAR DOY HRIMF SWS SSN Dst f10.7 2012 1 0 4.0 379. 71-8 999.9 2012 1 1 4.4 386. 71-3 999.9 2012 1 2 4.8 380. 71-4 999.9 2012 1 3 5.4 374. 71-5 999.9 2012 1 4 4.5 369. 71-9 999.9 2012 1 5 4.2 368. 71-7 999.9 2012 1 6 4.7 367. 71-6 999.9 2012 1 7 4.1 361. 71 -10 999.9 2012 1 8 3.2 362. 71-7 999.9 2012 1 9 4.3 367. 71-3 999.9 2012 1 10 4.5 365. 71-6 999.9 2012 1 11 5.6 369. 71-8 999.9 2012 1 12 5.2 366. 71-8 999.9 2012 1 13 4.4 370. 71-7 999.9 2012 1 14 4.8 357. 71-5 999.9 2012 1 15 4.6 354. 71-8 999.9 2012 1 16 3.7 382. 71-7 999.9 2012 1 17 3.2 376. 71-2 999.9 2012 1 18 2.8 368. 71 2 999.9 2012 1 19 3.2 361. 71 2 999.9 2012 1 20 3.2 361. 71-3 999.9 2012 1 21 3.5 365. 71-5 999.9 2012 1 22 3.6 364. 71-3 999.9 2012 1 23 3.0 362. 71-3 999.9 2012 2 0 3.2 359. 92-5 130.3 2012 2 1 3.0 361. 92-4 130.3 2012 2 2 4.5 374. 92 3 130.3 2012 2 3 4.5 364. 92 5 130.3 2012 2 4 5.1 352. 92 3 130.3 2012 2 5 4.9 358. 92 3 130.3 2012 2 6 4.4 346. 92 4 130.3 2012 2 7 4.2 349. 92 7 130.3 2012 2 8 4.5 346. 92 8 130.3 2012 2 9 5.2 345. 92 7 130.3 2012 2 10 5.0 349. 92 5 130.3 2012 2 11 4.8 345. 92 0 130.3 2012 2 12 5.3 347. 92 0 130.3 2012 2 13 5.5 342. 92 0 130.3 2012 2 14 6.1 359. 92 1 130.3 2012 2 15 6.2 393. 92 8 130.3 2012 2 16 6.7 390. 9210 130.3 2012 2 17 7.7 369. 9210 130.3 2012 2 18 9.4 380. 9214 130.3 2012 2 19 10.6 386. 9212 130.3 2012 2 20 10.2 378. 9211 130.3 2012 2 21 11.6 369. 92 7 130.3 2012 2 22 12.0 369. 92 8 130.3 2012 2 23 10.5 361. 92 1 130.3 2012 3 0 11.3 403. 120-7 130.2 2012 3 1 10.3 412. 120 -14 130.2 2012 3 2 8.8 419. 120 -18 130.2 2012 3 3 8.3 412. 120 -23 130.2 2012 3 4 8.0 408. 120 -25 130.2 2012 3 5 7.0 380. 120 -28 130.2 2012 3 6 6.9 374. 120 -29 130.2 2012 3 7 6.9 372. 120 -30 130.2 2012 3 8 7.1 365. 120 -32 130.2 2012 3 9 6.8 376. 120 -35 130.2 2012 3 10 6.7 380. 120 -35 130.2 2012 3 11 6.4 381. 120 -30 130.2 2012 3 12 5.9 401. 120 -26 130.2 2012 3 13 5.9 405. 120 -23 130.2 2012 3 14 5.9 413. 120 -20 130.2 2012 3 15 5.9 406. 120 -20 130.2 2012 3 16 6.3 427. 120 -20 130.2 2012 3 17 5.9 424. 120 -19 130.2 2012 3 18 4.8 390. 120 -16 130.2 2012 3 19 4.8 374. 120 -15 130.2 2012 3 20 4.8 374. 120 -15 130.2 2012 3 21 5.1 378. 120 -18 130.2 2012 3 22 4.9 375. 120 -19 130.2 2012 3 23 4.7 364. 120 -17 130.2 2012 4 0 4.3 359. 126 -17 131.6 2012 4 1 4.3 359. 126 -15 131.6 2012 4 2 4.2 358. 126 -13 131.6 2012 4 3 3.8 359. 126 -13 131.6 2012 4 4 3.8 358. 126 -13 131.6 2012 4 5 3.7 359. 126 -14 131.6 2012 4 6 3.9 361. 126 -13 131.6 2012 4 7 3.7 364. 126 -13 131.6 2012 4 8 3.7 366. 126 -12 131.6 2012 4 9 3.8 363. 126 -10 131.6 2012 4 10 3.5 363. 126-8 131.6 2012 4 11 3.0 352. 126 -10 131.6 2012 4 12 3.1 348. 126 -12 131.6 2012 4 13 3.3 340. 126-9 131.6 2012 4 14 4.0 343. 126-8 131.6 2012 4 15 4.2 343. 126-7 131.6 2012 4 16 3.8 336. 126-5 131.6 2012 4 17 3.9 334. 126-6 131.6 2012 4 18 3.8 329. 126-5 131.6 2012 4 19 3.8 326. 126-4 131.6 2012 4 20 4.3 337. 126-3 131.6 2012 4 21 3.9 331. 126 0 131.6 2012 4 22 3.8 322. 126-1 131.6 2012 4 23 3.5 331. 126-1 131.6 2012 5 0 3.9 312. 109-3 136.6 2012 5 1 3.6 311. 109-1 136.6 2012 5 2 3.7 312. 109 0 136.6 2012 5 3 3.8 308. 109 0 136.6 2012 5 4 4.0 305. 109 2 136.6 2012 5 5 4.5 309. 109 2 136.6 2012 5 6 3.5 314. 109 3 136.6 2012 5 7 3.6 305. 109 2 136.6 2012 5 8 4.3 307. 109 2 136.6 2012 5 9 4.6 316. 109 1 136.6 2012 5 10 5.0 321. 109-4 136.6 2012 5 11 5.1 321. 109-6 136.6 2012 5 12 4.6 326. 109-4 136.6 2012 5 13 5.7 321. 109-2 136.6 2012 5 14 5.0 316. 109 1 136.6 2012 5 15 4.6 315. 109 2 136.6 2012 5 16 5.5 321. 109 7 136.6 2012 5 17 7.2 327. 109 7 136.6 2012 5 18 9.2 329. 109 3 136.6 2012 5 19 9.4 341. 109 3 136.6 2012 5 20 9.2 345. 109 8 136.6 2012 5 21 9.8 344. 109 9 136.6 2012 5 22 9.8 341. 10910 136.6 2012 5 23 10.0 351. 10915 136.6 2012 6 0 10.4 356. 11312 131.0 2012 6 1 9.1 360. 11310 131.0 2012 6 2 6.6 392. 11310 131.0 2012 6 3
Re: [R] code for year month day hr format
Às 07:53 de 17/06/2024, Jibrin Alhassan escreveu: Part of it is pasted below YEAR DOY HRIMF SWS SSN Dst f10.7 2012 1 0 4.0 379. 71-8 999.9 2012 1 1 4.4 386. 71-3 999.9 2012 1 2 4.8 380. 71-4 999.9 2012 1 3 5.4 374. 71-5 999.9 2012 1 4 4.5 369. 71-9 999.9 2012 1 5 4.2 368. 71-7 999.9 2012 1 6 4.7 367. 71-6 999.9 2012 1 7 4.1 361. 71 -10 999.9 2012 1 8 3.2 362. 71-7 999.9 2012 1 9 4.3 367. 71-3 999.9 2012 1 10 4.5 365. 71-6 999.9 2012 1 11 5.6 369. 71-8 999.9 2012 1 12 5.2 366. 71-8 999.9 2012 1 13 4.4 370. 71-7 999.9 2012 1 14 4.8 357. 71-5 999.9 2012 1 15 4.6 354. 71-8 999.9 2012 1 16 3.7 382. 71-7 999.9 2012 1 17 3.2 376. 71-2 999.9 2012 1 18 2.8 368. 71 2 999.9 2012 1 19 3.2 361. 71 2 999.9 2012 1 20 3.2 361. 71-3 999.9 2012 1 21 3.5 365. 71-5 999.9 2012 1 22 3.6 364. 71-3 999.9 2012 1 23 3.0 362. 71-3 999.9 2012 2 0 3.2 359. 92-5 130.3 2012 2 1 3.0 361. 92-4 130.3 2012 2 2 4.5 374. 92 3 130.3 2012 2 3 4.5 364. 92 5 130.3 2012 2 4 5.1 352. 92 3 130.3 2012 2 5 4.9 358. 92 3 130.3 2012 2 6 4.4 346. 92 4 130.3 2012 2 7 4.2 349. 92 7 130.3 2012 2 8 4.5 346. 92 8 130.3 2012 2 9 5.2 345. 92 7 130.3 2012 2 10 5.0 349. 92 5 130.3 2012 2 11 4.8 345. 92 0 130.3 2012 2 12 5.3 347. 92 0 130.3 2012 2 13 5.5 342. 92 0 130.3 2012 2 14 6.1 359. 92 1 130.3 2012 2 15 6.2 393. 92 8 130.3 2012 2 16 6.7 390. 9210 130.3 2012 2 17 7.7 369. 9210 130.3 2012 2 18 9.4 380. 9214 130.3 2012 2 19 10.6 386. 9212 130.3 2012 2 20 10.2 378. 9211 130.3 2012 2 21 11.6 369. 92 7 130.3 2012 2 22 12.0 369. 92 8 130.3 2012 2 23 10.5 361. 92 1 130.3 2012 3 0 11.3 403. 120-7 130.2 2012 3 1 10.3 412. 120 -14 130.2 2012 3 2 8.8 419. 120 -18 130.2 2012 3 3 8.3 412. 120 -23 130.2 2012 3 4 8.0 408. 120 -25 130.2 2012 3 5 7.0 380. 120 -28 130.2 2012 3 6 6.9 374. 120 -29 130.2 2012 3 7 6.9 372. 120 -30 130.2 2012 3 8 7.1 365. 120 -32 130.2 2012 3 9 6.8 376. 120 -35 130.2 2012 3 10 6.7 380. 120 -35 130.2 2012 3 11 6.4 381. 120 -30 130.2 2012 3 12 5.9 401. 120 -26 130.2 2012 3 13 5.9 405. 120 -23 130.2 2012 3 14 5.9 413. 120 -20 130.2 2012 3 15 5.9 406. 120 -20 130.2 2012 3 16 6.3 427. 120 -20 130.2 2012 3 17 5.9 424. 120 -19 130.2 2012 3 18 4.8 390. 120 -16 130.2 2012 3 19 4.8 374. 120 -15 130.2 2012 3 20 4.8 374. 120 -15 130.2 2012 3 21 5.1 378. 120 -18 130.2 2012 3 22 4.9 375. 120 -19 130.2 2012 3 23 4.7 364. 120 -17 130.2 2012 4 0 4.3 359. 126 -17 131.6 2012 4 1 4.3 359. 126 -15 131.6 2012 4 2 4.2 358. 126 -13 131.6 2012 4 3 3.8 359. 126 -13 131.6 2012 4 4 3.8 358. 126 -13 131.6 2012 4 5 3.7 359. 126 -14 131.6 2012 4 6 3.9 361. 126 -13 131.6 2012 4 7 3.7 364. 126 -13 131.6 2012 4 8 3.7 366. 126 -12 131.6 2012 4 9 3.8 363. 126 -10 131.6 2012 4 10 3.5 363. 126-8 131.6 2012 4 11 3.0 352. 126 -10 131.6 2012 4 12 3.1 348. 126 -12 131.6 2012 4 13 3.3 340. 126-9 131.6 2012 4 14 4.0 343. 126-8 131.6 2012 4 15 4.2 343. 126-7 131.6 2012 4 16 3.8 336. 126-5 131.6 2012 4 17 3.9 334. 126-6 131.6 2012 4 18 3.8 329. 126-5 131.6 2012 4 19 3.8 326. 126-4 131.6 2012 4 20 4.3 337. 126-3 131.6 2012 4 21 3.9 331. 126 0 131.6 2012 4 22 3.8 322. 126-1 131.6 2012 4 23 3.5 331. 126-1 131.6 2012 5 0 3.9 312. 109-3 136.6 2012 5 1 3.6 311. 109-1 136.6 2012 5 2 3.7 312. 109 0 136.6 2012 5 3 3.8 308. 109 0 136.6 2012 5 4 4.0 305. 109 2 136.6 2012 5 5 4.5 309. 109 2 136.6 2012 5 6 3.5 314. 109 3 136.6 2012 5 7 3.6 305. 109 2 136.6 2012 5 8 4.3 307. 109 2 136.6 2012 5 9 4.6 316. 109 1 136.6 2012 5 10 5.0 321. 109-4 136.6 2012 5 11 5.1 321. 109-6 136.6 2012 5 12 4.6 326. 109-4 136.6 2012 5 13 5.7 321. 109-2 136.6 2012 5 14 5.0 316. 109 1 136.6 2012 5 15 4.6 315. 109 2 136.6 2012 5 16 5.5 321. 109 7 136.6 2012 5 17 7.2 327. 109 7 136.6 2012 5 18 9.2 329. 109 3 136.6 2012 5 19 9.4 341. 109 3 136.6 2012 5 20 9.2 345. 109 8 136.6 2012 5 21 9.8 344. 109 9 136.6 2012 5 22 9.8 341. 10910 136.6 2012 5 23 10.0 351. 10915 136.6 2012 6 0 10.4 356. 11312 131.0 2012 6 1 9.1 360. 11310 131.0
[R] Help trying to understand R documentation on libraries paths
Hi, 1 - On help(".libPaths", help_type = "text") one can read: First, '.Library.site' is initialized from 'R_LIBS_SITE'. However, I have > Sys.getenv("R_LIBS_SITE") [1] "c:/Users/i.gine/AppData/Local/Programs/R/R-4.4.1/site-library" > .Library.site character(0) Is this consistent? 2 - Next, on the same help document, one can read: Then, '.libPaths()' is called with the combination of the directories given by 'R_LIBS' and 'R_LIBS_USER'. This time, I get > Sys.getenv("R_LIBS") [1] "" > Sys.getenv("R_LIBS_USER") [1] "c:/Users/i.gine/AppData/Local/Programs/R/R-4.4.0/library" > .libPaths() [1] "C:/Users/i.gine/AppData/Local/Programs/R/R-4.4.0/library" "C:/Users/i.gine/AppData/Local/Programs/R/R-4.4.1/library" Later is written: Function '.libPaths' always uses the values of '.Library' and '.Library.site' in the base namespace. and indeed > .Library [1] "c:/Users/i.gine/AppData/Local/Programs/R/R-4.4.1/library" Then, shouldn't be this specified above together with "directories given by 'R_LIBS' and 'R_LIBS_USER'"? Am I understanding it wrongly? Otherwise, what do you think on the current way this help page is explained? Thank you for your help and time. Best regards, Iago [[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] code for year month day hr format
Hello Rui, Here is the head(df1) output Date HR IMF SWS SSN Dst f10.7 1 2012-01-01 0 4.0 379 71 -8 999.9 2 2012-01-01 1 4.4 386 71 -3 999.9 3 2012-01-01 2 4.8 380 71 -4 999.9 4 2012-01-01 3 5.4 374 71 -5 999.9 5 2012-01-01 4 4.5 369 71 -9 999.9 6 2012-01-01 5 4.2 368 71 -7 999.9 Many thanks. *Jibrin Adejoh Alhassan (Ph.D)* Department of Physics and Astronomy, University of Nigeria, Nsukka On Mon, Jun 17, 2024 at 8:14 AM Rui Barradas wrote: > Às 07:53 de 17/06/2024, Jibrin Alhassan escreveu: > > Part of it is pasted below > > YEAR DOY HRIMF SWS SSN Dst f10.7 > > 2012 1 0 4.0 379. 71-8 999.9 > > 2012 1 1 4.4 386. 71-3 999.9 > > 2012 1 2 4.8 380. 71-4 999.9 > > 2012 1 3 5.4 374. 71-5 999.9 > > 2012 1 4 4.5 369. 71-9 999.9 > > 2012 1 5 4.2 368. 71-7 999.9 > > 2012 1 6 4.7 367. 71-6 999.9 > > 2012 1 7 4.1 361. 71 -10 999.9 > > 2012 1 8 3.2 362. 71-7 999.9 > > 2012 1 9 4.3 367. 71-3 999.9 > > 2012 1 10 4.5 365. 71-6 999.9 > > 2012 1 11 5.6 369. 71-8 999.9 > > 2012 1 12 5.2 366. 71-8 999.9 > > 2012 1 13 4.4 370. 71-7 999.9 > > 2012 1 14 4.8 357. 71-5 999.9 > > 2012 1 15 4.6 354. 71-8 999.9 > > 2012 1 16 3.7 382. 71-7 999.9 > > 2012 1 17 3.2 376. 71-2 999.9 > > 2012 1 18 2.8 368. 71 2 999.9 > > 2012 1 19 3.2 361. 71 2 999.9 > > 2012 1 20 3.2 361. 71-3 999.9 > > 2012 1 21 3.5 365. 71-5 999.9 > > 2012 1 22 3.6 364. 71-3 999.9 > > 2012 1 23 3.0 362. 71-3 999.9 > > 2012 2 0 3.2 359. 92-5 130.3 > > 2012 2 1 3.0 361. 92-4 130.3 > > 2012 2 2 4.5 374. 92 3 130.3 > > 2012 2 3 4.5 364. 92 5 130.3 > > 2012 2 4 5.1 352. 92 3 130.3 > > 2012 2 5 4.9 358. 92 3 130.3 > > 2012 2 6 4.4 346. 92 4 130.3 > > 2012 2 7 4.2 349. 92 7 130.3 > > 2012 2 8 4.5 346. 92 8 130.3 > > 2012 2 9 5.2 345. 92 7 130.3 > > 2012 2 10 5.0 349. 92 5 130.3 > > 2012 2 11 4.8 345. 92 0 130.3 > > 2012 2 12 5.3 347. 92 0 130.3 > > 2012 2 13 5.5 342. 92 0 130.3 > > 2012 2 14 6.1 359. 92 1 130.3 > > 2012 2 15 6.2 393. 92 8 130.3 > > 2012 2 16 6.7 390. 9210 130.3 > > 2012 2 17 7.7 369. 9210 130.3 > > 2012 2 18 9.4 380. 9214 130.3 > > 2012 2 19 10.6 386. 9212 130.3 > > 2012 2 20 10.2 378. 9211 130.3 > > 2012 2 21 11.6 369. 92 7 130.3 > > 2012 2 22 12.0 369. 92 8 130.3 > > 2012 2 23 10.5 361. 92 1 130.3 > > 2012 3 0 11.3 403. 120-7 130.2 > > 2012 3 1 10.3 412. 120 -14 130.2 > > 2012 3 2 8.8 419. 120 -18 130.2 > > 2012 3 3 8.3 412. 120 -23 130.2 > > 2012 3 4 8.0 408. 120 -25 130.2 > > 2012 3 5 7.0 380. 120 -28 130.2 > > 2012 3 6 6.9 374. 120 -29 130.2 > > 2012 3 7 6.9 372. 120 -30 130.2 > > 2012 3 8 7.1 365. 120 -32 130.2 > > 2012 3 9 6.8 376. 120 -35 130.2 > > 2012 3 10 6.7 380. 120 -35 130.2 > > 2012 3 11 6.4 381. 120 -30 130.2 > > 2012 3 12 5.9 401. 120 -26 130.2 > > 2012 3 13 5.9 405. 120 -23 130.2 > > 2012 3 14 5.9 413. 120 -20 130.2 > > 2012 3 15 5.9 406. 120 -20 130.2 > > 2012 3 16 6.3 427. 120 -20 130.2 > > 2012 3 17 5.9 424. 120 -19 130.2 > > 2012 3 18 4.8 390. 120 -16 130.2 > > 2012 3 19 4.8 374. 120 -15 130.2 > > 2012 3 20 4.8 374. 120 -15 130.2 > > 2012 3 21 5.1 378. 120 -18 130.2 > > 2012 3 22 4.9 375. 120 -19 130.2 > > 2012 3 23 4.7 364. 120 -17 130.2 > > 2012 4 0 4.3 359. 126 -17 131.6 > > 2012 4 1 4.3 359. 126 -15 131.6 > > 2012 4 2 4.2 358. 126 -13 131.6 > > 2012 4 3 3.8 359. 126 -13 131.6 > > 2012 4 4 3.8 358. 126 -13 131.6 > > 2012 4 5 3.7 359. 126 -14 131.6 > > 2012 4 6 3.9 361. 126 -13 131.6 > > 2012 4 7 3.7 364. 126 -13 131.6 > > 2012 4 8 3.7 366. 126 -12 131.6 > > 2012 4 9 3.8 363. 126 -10 131.6 > > 2012 4 10 3.5 363. 126-8 131.6 > > 2012 4 11 3.0 352. 126 -10 131.6 > > 2012 4 12 3.1 348. 126 -12 131.6 > > 2012 4 13 3.3 340. 126-9 131.6 > > 2012 4 14 4.0 343. 126-8 131.6 > > 2012 4 15 4.2 343. 126-7 131.6 > > 2012 4 16 3.8 336. 126-5 131.6 > > 2012 4 17 3.9 334. 126-6 131.6 > > 2012 4 18 3.8 329. 126-5 131.6 > > 2012 4 19 3.8 326. 126-4 131.6 > > 2012 4 20 4.3 337. 126-3 131.6 > > 2012 4 21 3.9 331. 126 0 131.6 > > 2012 4 22 3.8 322. 126-1 131.6 > > 2012 4 23 3.5 331. 126-1 131.6 > > 2012 5 0 3.9 312. 109-3 136.6 > > 2012 5 1 3.6 311. 109-1 136.6 > > 2012 5 2 3.7 312. 109 0 136.6 > > 2012 5 3 3.8 308. 109 0 136.6 > > 2
Re: [R] code for year month day hr format
Às 09:12 de 17/06/2024, Jibrin Alhassan escreveu: Hello Rui, Here is the head(df1) output Date HR IMF SWS SSN Dst f10.7 1 2012-01-01 0 4.0 379 71 -8 999.9 2 2012-01-01 1 4.4 386 71 -3 999.9 3 2012-01-01 2 4.8 380 71 -4 999.9 4 2012-01-01 3 5.4 374 71 -5 999.9 5 2012-01-01 4 4.5 369 71 -9 999.9 6 2012-01-01 5 4.2 368 71 -7 999.9 Many thanks. *Jibrin Adejoh Alhassan (Ph.D)* Department of Physics and Astronomy, University of Nigeria, Nsukka On Mon, Jun 17, 2024 at 8:14 AM Rui Barradas wrote: Às 07:53 de 17/06/2024, Jibrin Alhassan escreveu: Part of it is pasted below YEAR DOY HRIMF SWS SSN Dst f10.7 2012 1 0 4.0 379. 71-8 999.9 2012 1 1 4.4 386. 71-3 999.9 2012 1 2 4.8 380. 71-4 999.9 2012 1 3 5.4 374. 71-5 999.9 2012 1 4 4.5 369. 71-9 999.9 2012 1 5 4.2 368. 71-7 999.9 2012 1 6 4.7 367. 71-6 999.9 2012 1 7 4.1 361. 71 -10 999.9 2012 1 8 3.2 362. 71-7 999.9 2012 1 9 4.3 367. 71-3 999.9 2012 1 10 4.5 365. 71-6 999.9 2012 1 11 5.6 369. 71-8 999.9 2012 1 12 5.2 366. 71-8 999.9 2012 1 13 4.4 370. 71-7 999.9 2012 1 14 4.8 357. 71-5 999.9 2012 1 15 4.6 354. 71-8 999.9 2012 1 16 3.7 382. 71-7 999.9 2012 1 17 3.2 376. 71-2 999.9 2012 1 18 2.8 368. 71 2 999.9 2012 1 19 3.2 361. 71 2 999.9 2012 1 20 3.2 361. 71-3 999.9 2012 1 21 3.5 365. 71-5 999.9 2012 1 22 3.6 364. 71-3 999.9 2012 1 23 3.0 362. 71-3 999.9 2012 2 0 3.2 359. 92-5 130.3 2012 2 1 3.0 361. 92-4 130.3 2012 2 2 4.5 374. 92 3 130.3 2012 2 3 4.5 364. 92 5 130.3 2012 2 4 5.1 352. 92 3 130.3 2012 2 5 4.9 358. 92 3 130.3 2012 2 6 4.4 346. 92 4 130.3 2012 2 7 4.2 349. 92 7 130.3 2012 2 8 4.5 346. 92 8 130.3 2012 2 9 5.2 345. 92 7 130.3 2012 2 10 5.0 349. 92 5 130.3 2012 2 11 4.8 345. 92 0 130.3 2012 2 12 5.3 347. 92 0 130.3 2012 2 13 5.5 342. 92 0 130.3 2012 2 14 6.1 359. 92 1 130.3 2012 2 15 6.2 393. 92 8 130.3 2012 2 16 6.7 390. 9210 130.3 2012 2 17 7.7 369. 9210 130.3 2012 2 18 9.4 380. 9214 130.3 2012 2 19 10.6 386. 9212 130.3 2012 2 20 10.2 378. 9211 130.3 2012 2 21 11.6 369. 92 7 130.3 2012 2 22 12.0 369. 92 8 130.3 2012 2 23 10.5 361. 92 1 130.3 2012 3 0 11.3 403. 120-7 130.2 2012 3 1 10.3 412. 120 -14 130.2 2012 3 2 8.8 419. 120 -18 130.2 2012 3 3 8.3 412. 120 -23 130.2 2012 3 4 8.0 408. 120 -25 130.2 2012 3 5 7.0 380. 120 -28 130.2 2012 3 6 6.9 374. 120 -29 130.2 2012 3 7 6.9 372. 120 -30 130.2 2012 3 8 7.1 365. 120 -32 130.2 2012 3 9 6.8 376. 120 -35 130.2 2012 3 10 6.7 380. 120 -35 130.2 2012 3 11 6.4 381. 120 -30 130.2 2012 3 12 5.9 401. 120 -26 130.2 2012 3 13 5.9 405. 120 -23 130.2 2012 3 14 5.9 413. 120 -20 130.2 2012 3 15 5.9 406. 120 -20 130.2 2012 3 16 6.3 427. 120 -20 130.2 2012 3 17 5.9 424. 120 -19 130.2 2012 3 18 4.8 390. 120 -16 130.2 2012 3 19 4.8 374. 120 -15 130.2 2012 3 20 4.8 374. 120 -15 130.2 2012 3 21 5.1 378. 120 -18 130.2 2012 3 22 4.9 375. 120 -19 130.2 2012 3 23 4.7 364. 120 -17 130.2 2012 4 0 4.3 359. 126 -17 131.6 2012 4 1 4.3 359. 126 -15 131.6 2012 4 2 4.2 358. 126 -13 131.6 2012 4 3 3.8 359. 126 -13 131.6 2012 4 4 3.8 358. 126 -13 131.6 2012 4 5 3.7 359. 126 -14 131.6 2012 4 6 3.9 361. 126 -13 131.6 2012 4 7 3.7 364. 126 -13 131.6 2012 4 8 3.7 366. 126 -12 131.6 2012 4 9 3.8 363. 126 -10 131.6 2012 4 10 3.5 363. 126-8 131.6 2012 4 11 3.0 352. 126 -10 131.6 2012 4 12 3.1 348. 126 -12 131.6 2012 4 13 3.3 340. 126-9 131.6 2012 4 14 4.0 343. 126-8 131.6 2012 4 15 4.2 343. 126-7 131.6 2012 4 16 3.8 336. 126-5 131.6 2012 4 17 3.9 334. 126-6 131.6 2012 4 18 3.8 329. 126-5 131.6 2012 4 19 3.8 326. 126-4 131.6 2012 4 20 4.3 337. 126-3 131.6 2012 4 21 3.9 331. 126 0 131.6 2012 4 22 3.8 322. 126-1 131.6 2012 4 23 3.5 331. 126-1 131.6 2012 5 0 3.9 312. 109-3 136.6 2012 5 1 3.6 311. 109-1 136.6 2012 5 2 3.7 312. 109 0 136.6 2012 5 3 3.8 308. 109 0 136.6 2012 5 4 4.0 305. 109 2 136.6 2012 5 5 4.5 309. 109 2 136.6 2012 5 6 3.5 314. 109 3 136.6 2012 5 7 3.6 305. 109 2 136.6 2012 5 8 4.3 307. 109 2 136.6 2012 5 9 4.6 316. 109 1 136.6 2012 5 10 5.0 321. 109-4 136.6 2012 5 11 5.1 321. 109-6 136.6 2012 5 12 4.6 326. 109-4 136.6 2
Re: [R] code for year month day hr format
Hello Rui, The df1 output printed from June instead of January .Here is part of it. 4288 2012-06-27 15 6.2 420 70 -7 109.9 4289 2012-06-27 16 6.5 442 70 -9 109.9 4290 2012-06-27 17 6.3 450 70 -6 109.9 4291 2012-06-27 18 6.0 453 700 109.9 4292 2012-06-27 19 6.7 473 702 109.9 4293 2012-06-27 20 5.7 460 702 109.9 4294 2012-06-27 21 5.4 469 700 109.9 4295 2012-06-27 22 4.5 485 70 -2 109.9 4296 2012-06-27 23 4.9 497 701 109.9 4297 2012-06-28 0 4.6 500 873 123.7 4298 2012-06-28 1 4.7 503 872 123.7 4299 2012-06-28 2 4.3 488 871 123.7 4300 2012-06-28 3 4.9 479 870 123.7 4301 2012-06-28 4 5.1 459 870 123.7 4302 2012-06-28 5 4.9 458 870 123.7 4303 2012-06-28 6 5.1 460 870 123.7 4304 2012-06-28 7 5.0 451 87 -3 123.7 4305 2012-06-28 8 5.2 452 87 -5 123.7 4306 2012-06-28 9 5.2 445 87 -6 123.7 4307 2012-06-28 10 5.0 430 87 -7 123.7 4308 2012-06-28 11 4.6 434 87 -8 123.7 4309 2012-06-28 12 4.1 442 87 -7 123.7 4310 2012-06-28 13 3.9 433 87 -7 123.7 4311 2012-06-28 14 3.5 421 87 -9 123.7 4312 2012-06-28 15 4.4 420 87 -8 123.7 4313 2012-06-28 16 4.6 421 87 -9 123.7 4314 2012-06-28 17 3.2 417 87 -7 123.7 4315 2012-06-28 18 3.5 415 87 -3 123.7 4316 2012-06-28 19 3.9 394 87 -2 123.7 4317 2012-06-28 20 4.2 407 870 123.7 4318 2012-06-28 21 3.9 411 87 -3 123.7 4319 2012-06-28 22 3.6 420 87 -5 123.7 4320 2012-06-28 23 4.0 423 870 123.7 4321 2012-06-29 0 3.2 418 1035 121.3 4322 2012-06-29 1 3.3 421 1037 121.3 4323 2012-06-29 2 3.7 411 1039 121.3 4324 2012-06-29 3 3.8 413 1039 121.3 4325 2012-06-29 4 3.3 413 1036 121.3 4326 2012-06-29 5 3.2 417 1032 121.3 4327 2012-06-29 6 3.4 414 1032 121.3 4328 2012-06-29 7 3.7 405 1031 121.3 4329 2012-06-29 8 3.9 393 1031 121.3 4330 2012-06-29 9 4.2 385 1032 121.3 4331 2012-06-29 10 4.4 381 1032 121.3 4332 2012-06-29 11 4.0 386 1033 121.3 4333 2012-06-29 12 4.7 386 1035 121.3 4334 2012-06-29 13 5.2 378 1037 121.3 4335 2012-06-29 14 5.1 376 1035 121.3 4336 2012-06-29 15 4.7 366 1032 121.3 4337 2012-06-29 16 4.5 378 1030 121.3 4338 2012-06-29 17 4.8 369 1030 121.3 4339 2012-06-29 18 5.4 365 1030 121.3 4340 2012-06-29 19 5.7 369 1031 121.3 4341 2012-06-29 20 5.8 373 1033 121.3 4342 2012-06-29 21 4.9 392 103 10 121.3 4343 2012-06-29 22 4.0 406 103 19 121.3 4344 2012-06-29 23 7.1 402 103 19 121.3 4345 2012-06-30 0 6.5 398 104 18 128.2 4346 2012-06-30 1 7.6 397 104 12 128.2 4347 2012-06-30 2 8.8 407 104 10 128.2 4348 2012-06-30 3 11.2 404 104 -1 128.2 4349 2012-06-30 4 11.2 410 1041 128.2 4350 2012-06-30 5 8.8 410 1041 128.2 4351 2012-06-30 6 9.7 417 104 -6 128.2 4352 2012-06-30 7 12.3 446 104 -14 128.2 4353 2012-06-30 8 9.5 476 104 -10 128.2 4354 2012-06-30 9 8.7 496 104 -13 128.2 4355 2012-06-30 10 12.6 560 104 -17 128.2 4356 2012-06-30 11 11.4 600 104 -13 128.2 4357 2012-06-30 12 11.4 607 104 -12 128.2 4358 2012-06-30 13 11.1 603 104 -8 128.2 4359 2012-06-30 14 11.1 616 104 -14 128.2 4360 2012-06-30 15 9.7 616 104 -13 128.2 4361 2012-06-30 16 9.7 629 104 -15 128.2 4362 2012-06-30 17 6.6 654 104 -24 128.2 4363 2012-06-30 18 6.5 660 104 -24 128.2 4364 2012-06-30 19 6.8 676 104 -31 128.2 4365 2012-06-30 20 7.2 675 104 -37 128.2 4366 2012-06-30 21 7.0 657 104 -32 128.2 4367 2012-06-30 22 6.4 634 104 -31 128.2 4368 2012-06-30 23 7.6 640 104 -29 128.2 4369 2012-07-01 0 6.9 650 126 -23 137.9 4370 2012-07-01 1 7.0 635 126 -18 137.9 4371 2012-07-01 2 6.9 651 126 -17 137.9 4372 2012-07-01 3 6.3 661 126 -25 137.9 4373 2012-07-01 4 5.6 663 126 -26 137.9 4374 2012-07-01 5 5.4 655 126 -26 137.9 4375 2012-07-01 6 5.1 656 126 -33 137.9 4376 2012-07-01 7 4.9 658 126 -30 137.9 4377 2012-07-01 8 5.1 648 126 -24 137.9 4378 2012-07-01 9 5.0 643 126 -24 137.9 4379 2012-07-01 10 5.0 633 126 -20 137.9 4380 2012-07-01 11 5.1 650 126 -17 137.9 4381 2012-07-01 12 5.2 687 126 -13 137.9 4382 2012-07-01 13 5.0 653 126 -8 137.9 4383 2012-07-01 14 4.9 648 126 -12 137.9 4384 2012-07-01 15 5.7 661 126 -11 137.9 4385 2012-07-01 16 5.7 665 126 -10 137.9 4386 2012-07-01 17 5.9 655 126 -12 137.9 4387 2012-07-01 18 5.1 647 126 -10 137.9 4388 2012-07-01 19 4.9 638 126 -16 137.9 4389 2012-07-01 20 5.1 633 126 -17 137.9 4390 2012-07-01 21 5.8 642 126 -16 137.9 4391 2012-07-01 22 5.8 635 126 -18 137.9 4392 2012-07-01 23 5.6 639 126 -16 137.9 4393 2012-07-02 0 5.2 653 128 -15 171.4 4394 2012-07-02 1 6.0 642 128 -12 171.4 4395 2012-07-02 2 5.3 664 128 -16 171.4 4396 2012-07-02 3 5.2 676 128 -13 171.4 4397 2012
Re: [R] Help trying to understand R documentation on libraries paths
(Inline) > On 17 Jun 2024, at 09:51 , Iago Giné Vázquez wrote: > > Hi, > > 1 - On help(".libPaths", help_type = "text") one can read: > > First, '.Library.site' is initialized from 'R_LIBS_SITE'. > > However, I have > >> Sys.getenv("R_LIBS_SITE") > [1] "c:/Users/i.gine/AppData/Local/Programs/R/R-4.4.1/site-library" >> .Library.site > character(0) > > Is this consistent? It is implied that R_LIBS_SITE should point to an existing directory. I see the same thing on Mac: > .Library.site character(0) > Sys.getenv("R_LIBS_SITE") [1] "/Library/Frameworks/R.framework/Resources/site-library" > list.files(Sys.getenv("R_LIBS_SITE")) character(0) I.e., R_LIBS_SITE is where a site library _if any_ should live. If it is not there, there is no poin in searching it. Unless you actually have a site-library, I don't think there is a problem. > > 2 - Next, on the same help document, one can read: > > Then, '.libPaths()' is called with the combination > of the directories given by 'R_LIBS' and 'R_LIBS_USER'. > > > This time, I get >> Sys.getenv("R_LIBS") > [1] "" >> Sys.getenv("R_LIBS_USER") > [1] "c:/Users/i.gine/AppData/Local/Programs/R/R-4.4.0/library" >> .libPaths() > [1] "C:/Users/i.gine/AppData/Local/Programs/R/R-4.4.0/library" > "C:/Users/i.gine/AppData/Local/Programs/R/R-4.4.1/library" > > > Later is written: > > Function '.libPaths' always uses the values of '.Library' and > '.Library.site' in the base namespace. > > and indeed > >> .Library > [1] "c:/Users/i.gine/AppData/Local/Programs/R/R-4.4.1/library" > > > Then, shouldn't be this specified above together with "directories given by > 'R_LIBS' and 'R_LIBS_USER'"? > The logic of .libPath() is > .libPaths function (new, include.site = TRUE) { if (!missing(new)) { new <- Sys.glob(path.expand(new)) paths <- c(new, if (include.site) .Library.site, .Library) paths <- paths[dir.exists(paths)] .lib.loc <<- unique(normalizePath(paths, "/")) } else .lib.loc } so if you "call it with" new=something, then (.Library.site, .Library) is automagically appended, unless you expressly tell it not to. -pd > > Am I understanding it wrongly? Otherwise, what do you think on the current > way this help page is explained? > > Thank you for your help and time. > > Best regards, > > Iago > > [[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. -- Peter Dalgaard, Professor, Center for Statistics, Copenhagen Business School Solbjerg Plads 3, 2000 Frederiksberg, Denmark Phone: (+45)38153501 Office: A 4.23 Email: pd@cbs.dk Priv: pda...@gmail.com __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Help trying to understand R documentation on libraries paths
Thanks, Regarding .libPaths, I am asking for the call to `.libPaths()`, so I understand there is no `new` in the call, as in the documentation I cited. Iago De: peter dalgaard Enviat el: dilluns, 17 de juny de 2024 13:26 Per a: Iago Gin� V�zquez A/c: r-help@r-project.org Tema: Re: [R] Help trying to understand R documentation on libraries paths (Inline) > On 17 Jun 2024, at 09:51 , Iago Gin� V�zquez wrote: > > Hi, > > 1 - On help(".libPaths", help_type = "text") one can read: > > First, '.Library.site' is initialized from 'R_LIBS_SITE'. > > However, I have > >> Sys.getenv("R_LIBS_SITE") > [1] "c:/Users/i.gine/AppData/Local/Programs/R/R-4.4.1/site-library" >> .Library.site > character(0) > > Is this consistent? It is implied that R_LIBS_SITE should point to an existing directory. I see the same thing on Mac: > .Library.site character(0) > Sys.getenv("R_LIBS_SITE") [1] "/Library/Frameworks/R.framework/Resources/site-library" > list.files(Sys.getenv("R_LIBS_SITE")) character(0) I.e., R_LIBS_SITE is where a site library _if any_ should live. If it is not there, there is no poin in searching it. Unless you actually have a site-library, I don't think there is a problem. > > 2 - Next, on the same help document, one can read: > > Then, '.libPaths()' is called with the combination > of the directories given by 'R_LIBS' and 'R_LIBS_USER'. > > > This time, I get >> Sys.getenv("R_LIBS") > [1] "" >> Sys.getenv("R_LIBS_USER") > [1] "c:/Users/i.gine/AppData/Local/Programs/R/R-4.4.0/library" >> .libPaths() > [1] "C:/Users/i.gine/AppData/Local/Programs/R/R-4.4.0/library" > "C:/Users/i.gine/AppData/Local/Programs/R/R-4.4.1/library" > > > Later is written: > > Function '.libPaths' always uses the values of '.Library' and > '.Library.site' in the base namespace. > > and indeed > >> .Library > [1] "c:/Users/i.gine/AppData/Local/Programs/R/R-4.4.1/library" > > > Then, shouldn't be this specified above together with "directories given by > 'R_LIBS' and 'R_LIBS_USER'"? > The logic of .libPath() is > .libPaths function (new, include.site = TRUE) { if (!missing(new)) { new <- Sys.glob(path.expand(new)) paths <- c(new, if (include.site) .Library.site, .Library) paths <- paths[dir.exists(paths)] .lib.loc <<- unique(normalizePath(paths, "/")) } else .lib.loc } so if you "call it with" new=something, then (.Library.site, .Library) is automagically appended, unless you expressly tell it not to. -pd > > Am I understanding it wrongly? Otherwise, what do you think on the current > way this help page is explained? > > Thank you for your help and time. > > Best regards, > > Iago > >[[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. -- Peter Dalgaard, Professor, Center for Statistics, Copenhagen Business School Solbjerg Plads 3, 2000 Frederiksberg, Denmark Phone: (+45)38153501 Office: A 4.23 Email: pd@cbs.dk Priv: pda...@gmail.com [[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] Help trying to understand R documentation on libraries paths
I am not going to search the sources for it (your problem, your work ;-) ), but the wording would be consistent with a call like .libPaths(c(Sys.getenv("R_LIBS"), Sys.getenv("R_LIBS_USER"))) -pd > On 17 Jun 2024, at 13:40 , Iago Giné Vázquez wrote: > > Thanks, > > Regarding .libPaths, I am asking for the call to `.libPaths()`, so I > understand there is no `new` in the call, as in the documentation I cited. > > Iago > > De: peter dalgaard > Enviat el: dilluns, 17 de juny de 2024 13:26 > Per a: Iago Giné Vázquez > A/c: r-help@r-project.org > Tema: Re: [R] Help trying to understand R documentation on libraries paths > > (Inline) > > > On 17 Jun 2024, at 09:51 , Iago Giné Vázquez wrote: > > > > Hi, > > > > 1 - On help(".libPaths", help_type = "text") one can read: > > > > First, '.Library.site' is initialized from 'R_LIBS_SITE'. > > > > However, I have > > > >> Sys.getenv("R_LIBS_SITE") > > [1] "c:/Users/i.gine/AppData/Local/Programs/R/R-4.4.1/site-library" > >> .Library.site > > character(0) > > > > Is this consistent? > > It is implied that R_LIBS_SITE should point to an existing directory. I see > the same thing on Mac: > > > .Library.site > character(0) > > Sys.getenv("R_LIBS_SITE") > [1] "/Library/Frameworks/R.framework/Resources/site-library" > > list.files(Sys.getenv("R_LIBS_SITE")) > character(0) > > I.e., R_LIBS_SITE is where a site library _if any_ should live. If it is not > there, there is no poin in searching it. Unless you actually have a > site-library, I don't think there is a problem. > > > > > 2 - Next, on the same help document, one can read: > > > > Then, '.libPaths()' is called with the combination > > of the directories given by 'R_LIBS' and 'R_LIBS_USER'. > > > > > > This time, I get > >> Sys.getenv("R_LIBS") > > [1] "" > >> Sys.getenv("R_LIBS_USER") > > [1] "c:/Users/i.gine/AppData/Local/Programs/R/R-4.4.0/library" > >> .libPaths() > > [1] "C:/Users/i.gine/AppData/Local/Programs/R/R-4.4.0/library" > > "C:/Users/i.gine/AppData/Local/Programs/R/R-4.4.1/library" > > > > > > Later is written: > > > > Function '.libPaths' always uses the values of '.Library' and > > '.Library.site' in the base namespace. > > > > and indeed > > > >> .Library > > [1] "c:/Users/i.gine/AppData/Local/Programs/R/R-4.4.1/library" > > > > > > Then, shouldn't be this specified above together with "directories given by > > 'R_LIBS' and 'R_LIBS_USER'"? > > > > The logic of .libPath() is > > > .libPaths > function (new, include.site = TRUE) > { > if (!missing(new)) { > new <- Sys.glob(path.expand(new)) > paths <- c(new, if (include.site) .Library.site, .Library) > paths <- paths[dir.exists(paths)] > .lib.loc <<- unique(normalizePath(paths, "/")) > } > else .lib.loc > } > > so if you "call it with" new=something, then (.Library.site, .Library) is > automagically appended, unless you expressly tell it not to. > > -pd > > > > > Am I understanding it wrongly? Otherwise, what do you think on the current > > way this help page is explained? > > > > Thank you for your help and time. > > > > Best regards, > > > > Iago > > > >[[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. > > -- > Peter Dalgaard, Professor, > Center for Statistics, Copenhagen Business School > Solbjerg Plads 3, 2000 Frederiksberg, Denmark > Phone: (+45)38153501 > Office: A 4.23 > Email: pd@cbs.dk Priv: pda...@gmail.com -- Peter Dalgaard, Professor, Center for Statistics, Copenhagen Business School Solbjerg Plads 3, 2000 Frederiksberg, Denmark Phone: (+45)38153501 Office: A 4.23 Email: pd@cbs.dk Priv: pda...@gmail.com __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] What is the HEX code for "transparent" color?
Thank you all very much for the answers given (Greg, Robert, Duncan, Roland). Actually, I had tried with "#" and "#FF00" (I had a mistake in the message). For example it works with: numrows <- 3; numcols <- 3 a <- c(1,0,1,1,1,1,1,0,1) (pattern <- matrix(a, numrows, numcols, byrow=TRUE)) # png(filename="transparency.00.png") par(bg="#") palette <- c("#", "black") image(t(pattern), col = palette, axes = FALSE) dev.off() I took into account Duncan's answer: 'If the other answers don't solve your problem, you should give us some context. Not all graphics functions in R can handle transparency, so please show us some reproducible code for what you are trying.' But it doesn't work on Shiny. library(shiny) # Define UI for application that draws a histogram ui <- fluidPage( titlePanel(h3("Binary pattern (r,c)-rectangular grid", align = "center")), sidebarLayout( sidebarPanel( numericInput("r", "Number of rows:", 3), numericInput("c", "Number of columns:", 3) ), mainPanel(plotOutput("distPlot")) ) ) server <- function(input, output) { output$distPlot <- renderPlot({ numrows <- 3; numcols <- 3 a <- c(1,0,1,1,1,1,1,0,1) pattern <- matrix(a, numrows, numcols, byrow=TRUE) palette <- c("#", "black") par(bg="#") # image(t(pattern), col = palette, axes = FALSE) }) } shinyApp(ui = ui, server = server) Any explanation? Any help? Thanks Hau idatzi du Yosu Yurramendi (yosu.yurrame...@gmail.com) erabiltzaileak (2024 eka. 6(a), og. (10:37)): > What is the HEX code for "transparent" color? > I've tried "" "FF00" "", but they don't work. > Thanks > [[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] What is the HEX code for "transparent" color?
adjustcolor("#123456", alpha = 0.5) will return the indicated color with an alpha transparency of 50% . On Thu, Jun 6, 2024 at 11:07 AM Yosu Yurramendi wrote: > > What is the HEX code for "transparent" color? > I've tried "" "FF00" "", but they don't work. > Thanks > > [[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. -- Statistics & Software Consulting GKX Group, GKX Associates Inc. tel: 1-877-GKX-GROUP email: ggrothendieck at gmail.com __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] unable to get barchart of censored subjects from ggsurvplot() in survminer package, if there is no predcitor
Hello. Running R 4.2.3 on Windows 10. Using survimer package version survminer_0.4.9 published 2021-03-09. I'm encountering an error with ggsurvplot() in the survminer package. Email to the author/maintainer about 2 weeks ago has not yet resulted in a reply. I seem unable to produce a n.censor.table for an unconditional (no predictor) survival curve. See code below. Any advice? Thanks. --Chris Ryan, MD, MS, MSPH library(survival) library(survminer) data(lung) fit <- survfit(Surv(time, status) ~ 1, data = lung) ggsurvplot( fit, data = lung, xlab = "Time in days", ncensor.plot = TRUE ) ## produces error "Error: ! Problem while converting geom to grob. ℹ Error occurred in the 1st layer. Caused by error: ! Unknown colour name: strata" about "uknown colour name strata" ## but there are no strata ## omit ncensor.plot, and no error ggsurvplot( fit, data = lung, xlab = "Time in days", # ncensor.plot = TRUE ) ## restore ncensor.plot = TRUE, but use a predictor in the model, ## and no error. fit.2 <- survfit(Surv(time, status) ~ sex, data = lung) ggsurvplot( fit.2, data = lung, xlab = "Time in days", ncensor.plot = TRUE ) __ 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] code for year month day hr format
Às 09:44 de 17/06/2024, Jibrin Alhassan escreveu: Hello Rui, The df1 output printed from June instead of January .Here is part of it. 4288 2012-06-27 15 6.2 420 70 -7 109.9 4289 2012-06-27 16 6.5 442 70 -9 109.9 4290 2012-06-27 17 6.3 450 70 -6 109.9 4291 2012-06-27 18 6.0 453 700 109.9 4292 2012-06-27 19 6.7 473 702 109.9 4293 2012-06-27 20 5.7 460 702 109.9 4294 2012-06-27 21 5.4 469 700 109.9 4295 2012-06-27 22 4.5 485 70 -2 109.9 4296 2012-06-27 23 4.9 497 701 109.9 4297 2012-06-28 0 4.6 500 873 123.7 4298 2012-06-28 1 4.7 503 872 123.7 4299 2012-06-28 2 4.3 488 871 123.7 4300 2012-06-28 3 4.9 479 870 123.7 4301 2012-06-28 4 5.1 459 870 123.7 4302 2012-06-28 5 4.9 458 870 123.7 4303 2012-06-28 6 5.1 460 870 123.7 4304 2012-06-28 7 5.0 451 87 -3 123.7 4305 2012-06-28 8 5.2 452 87 -5 123.7 4306 2012-06-28 9 5.2 445 87 -6 123.7 4307 2012-06-28 10 5.0 430 87 -7 123.7 4308 2012-06-28 11 4.6 434 87 -8 123.7 4309 2012-06-28 12 4.1 442 87 -7 123.7 4310 2012-06-28 13 3.9 433 87 -7 123.7 4311 2012-06-28 14 3.5 421 87 -9 123.7 4312 2012-06-28 15 4.4 420 87 -8 123.7 4313 2012-06-28 16 4.6 421 87 -9 123.7 4314 2012-06-28 17 3.2 417 87 -7 123.7 4315 2012-06-28 18 3.5 415 87 -3 123.7 4316 2012-06-28 19 3.9 394 87 -2 123.7 4317 2012-06-28 20 4.2 407 870 123.7 4318 2012-06-28 21 3.9 411 87 -3 123.7 4319 2012-06-28 22 3.6 420 87 -5 123.7 4320 2012-06-28 23 4.0 423 870 123.7 4321 2012-06-29 0 3.2 418 1035 121.3 4322 2012-06-29 1 3.3 421 1037 121.3 4323 2012-06-29 2 3.7 411 1039 121.3 4324 2012-06-29 3 3.8 413 1039 121.3 4325 2012-06-29 4 3.3 413 1036 121.3 4326 2012-06-29 5 3.2 417 1032 121.3 4327 2012-06-29 6 3.4 414 1032 121.3 4328 2012-06-29 7 3.7 405 1031 121.3 4329 2012-06-29 8 3.9 393 1031 121.3 4330 2012-06-29 9 4.2 385 1032 121.3 4331 2012-06-29 10 4.4 381 1032 121.3 4332 2012-06-29 11 4.0 386 1033 121.3 4333 2012-06-29 12 4.7 386 1035 121.3 4334 2012-06-29 13 5.2 378 1037 121.3 4335 2012-06-29 14 5.1 376 1035 121.3 4336 2012-06-29 15 4.7 366 1032 121.3 4337 2012-06-29 16 4.5 378 1030 121.3 4338 2012-06-29 17 4.8 369 1030 121.3 4339 2012-06-29 18 5.4 365 1030 121.3 4340 2012-06-29 19 5.7 369 1031 121.3 4341 2012-06-29 20 5.8 373 1033 121.3 4342 2012-06-29 21 4.9 392 103 10 121.3 4343 2012-06-29 22 4.0 406 103 19 121.3 4344 2012-06-29 23 7.1 402 103 19 121.3 4345 2012-06-30 0 6.5 398 104 18 128.2 4346 2012-06-30 1 7.6 397 104 12 128.2 4347 2012-06-30 2 8.8 407 104 10 128.2 4348 2012-06-30 3 11.2 404 104 -1 128.2 4349 2012-06-30 4 11.2 410 1041 128.2 4350 2012-06-30 5 8.8 410 1041 128.2 4351 2012-06-30 6 9.7 417 104 -6 128.2 4352 2012-06-30 7 12.3 446 104 -14 128.2 4353 2012-06-30 8 9.5 476 104 -10 128.2 4354 2012-06-30 9 8.7 496 104 -13 128.2 4355 2012-06-30 10 12.6 560 104 -17 128.2 4356 2012-06-30 11 11.4 600 104 -13 128.2 4357 2012-06-30 12 11.4 607 104 -12 128.2 4358 2012-06-30 13 11.1 603 104 -8 128.2 4359 2012-06-30 14 11.1 616 104 -14 128.2 4360 2012-06-30 15 9.7 616 104 -13 128.2 4361 2012-06-30 16 9.7 629 104 -15 128.2 4362 2012-06-30 17 6.6 654 104 -24 128.2 4363 2012-06-30 18 6.5 660 104 -24 128.2 4364 2012-06-30 19 6.8 676 104 -31 128.2 4365 2012-06-30 20 7.2 675 104 -37 128.2 4366 2012-06-30 21 7.0 657 104 -32 128.2 4367 2012-06-30 22 6.4 634 104 -31 128.2 4368 2012-06-30 23 7.6 640 104 -29 128.2 4369 2012-07-01 0 6.9 650 126 -23 137.9 4370 2012-07-01 1 7.0 635 126 -18 137.9 4371 2012-07-01 2 6.9 651 126 -17 137.9 4372 2012-07-01 3 6.3 661 126 -25 137.9 4373 2012-07-01 4 5.6 663 126 -26 137.9 4374 2012-07-01 5 5.4 655 126 -26 137.9 4375 2012-07-01 6 5.1 656 126 -33 137.9 4376 2012-07-01 7 4.9 658 126 -30 137.9 4377 2012-07-01 8 5.1 648 126 -24 137.9 4378 2012-07-01 9 5.0 643 126 -24 137.9 4379 2012-07-01 10 5.0 633 126 -20 137.9 4380 2012-07-01 11 5.1 650 126 -17 137.9 4381 2012-07-01 12 5.2 687 126 -13 137.9 4382 2012-07-01 13 5.0 653 126 -8 137.9 4383 2012-07-01 14 4.9 648 126 -12 137.9 4384 2012-07-01 15 5.7 661 126 -11 137.9 4385 2012-07-01 16 5.7 665 126 -10 137.9 4386 2012-07-01 17 5.9 655 126 -12 137.9 4387 2012-07-01 18 5.1 647 126 -10 137.9 4388 2012-07-01 19 4.9 638 126 -16 137.9 4389 2012-07-01 20 5.1 633 126 -17 137.9 4390 2012-07-01 21 5.8 642 126 -16 137.9 4391 2012-07-01 22 5.8 635 126 -18 137.9 4392 2012-07-01 23 5.6 639 126 -16 137.9 4393 2012-07-02 0 5.2 653 128 -15 171.4 4394 2012-07-02 1 6.0 642 128 -12 171.4 4395 2012-07-02 2 5.3 664 128 -16 171.4 439
Re: [R] Column names of model.matrix's output with contrast.arg
Thanks for your reply. It might good to document the naming convention in ?contrasts. It is hard to understand .L for linear, .Q for quadratic, .C for cubic and ^n for other degrees. For contr.sum, we could have used .Sum, .Sum… Maybe the examples ?model.matrix should use names in dd objects so that we observe when names are dropped. Kind regards, Christophe > Le 14 juin 2024 à 11:45, peter dalgaard a écrit : > > You're at the mercy of the various contr.XXX functions. They may or may not > set the colnames on the matrices that they generate. > > The rationales for (not) setting them is not perfectly transparent, but you > obviously cannot use level names on contr.poly, so it uses .L, .Q, etc. > > In MASS, contr.sdif is careful about labeling the columns with the levels > that are being diff'ed. > > For contr.treatment, there is a straightforward connection to 0/1 dummy > variables, so level names there are natural. > > One could use levels in contr.sum and contr.helmert, but it might confuse > users that comparisons are with the average of all levels or preceding > levels. (It can be quite confusing when coding is +1 for male and -1 for > female, so that the gender difference is twice the coefficient.) > > -pd > >> On 14 Jun 2024, at 08:12 , Christophe Dutang wrote: >> >> Dear list, >> >> Changing the default contrasts used in glm() makes me aware how >> model.matrix() set column names. >> >> With default contrasts, model.matrix() use the level values to name the >> columns. However with other contrasts, model.matrix() use the level indexes. >> In the documentation, I don’t see anything in the documentation related to >> this ? It does not seem natural to have such a behavior? >> >> Any comment is welcome. >> >> An example is below. >> >> Kind regards, Christophe >> >> >> #example from ?glm >> counts <- c(18,17,15,20,10,20,25,13,12) >> outcome <- paste0("O", gl(3,1,9)) >> treatment <- paste0("T", gl(3,3)) >> >> X3 <- model.matrix(counts ~ outcome + treatment) >> X4 <- model.matrix(counts ~ outcome + treatment, contrasts = >> list("outcome"="contr.sum")) >> X5 <- model.matrix(counts ~ outcome + treatment, contrasts = >> list("outcome"="contr.helmert")) >> >> #check with original factor >> cbind.data.frame(X3, outcome) >> cbind.data.frame(X4, outcome) >> cbind.data.frame(X5, outcome) >> >> #same issue with glm >> glm.D93 <- glm(counts ~ outcome + treatment, family = poisson()) >> glm.D94 <- glm(counts ~ outcome + treatment, family = poisson(), contrasts = >> list("outcome"="contr.sum")) >> glm.D95 <- glm(counts ~ outcome + treatment, family = poisson(), contrasts = >> list("outcome"="contr.helmert")) >> >> coef(glm.D93) >> coef(glm.D94) >> coef(glm.D95) >> >> #check linear predictor >> cbind(X3 %*% coef(glm.D93), predict(glm.D93)) >> cbind(X4 %*% coef(glm.D94), predict(glm.D94)) >> >> - >> Christophe DUTANG >> LJK, Ensimag, Grenoble INP, UGA, France >> ILB research fellow >> Web: http://dutangc.free.fr >> >> __ >> 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. > > -- > Peter Dalgaard, Professor, > Center for Statistics, Copenhagen Business School > Solbjerg Plads 3, 2000 Frederiksberg, Denmark > Phone: (+45)38153501 > Office: A 4.23 > Email: pd@cbs.dk Priv: pda...@gmail.com > __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] code for year month day hr format
Hello Rui, Thanks for your kind and unrelenting help. The code works actually. I will see what to do to sort things out. Please, accept my indebtedness. *Jibrin Adejoh Alhassan (Ph.D)* Department of Physics and Astronomy, University of Nigeria, Nsukka On Mon, Jun 17, 2024 at 8:53 PM Rui Barradas wrote: > Às 09:44 de 17/06/2024, Jibrin Alhassan escreveu: > > Hello Rui, > > The df1 output printed from June instead of January .Here is part of it. > > 4288 2012-06-27 15 6.2 420 70 -7 109.9 > > 4289 2012-06-27 16 6.5 442 70 -9 109.9 > > 4290 2012-06-27 17 6.3 450 70 -6 109.9 > > 4291 2012-06-27 18 6.0 453 700 109.9 > > 4292 2012-06-27 19 6.7 473 702 109.9 > > 4293 2012-06-27 20 5.7 460 702 109.9 > > 4294 2012-06-27 21 5.4 469 700 109.9 > > 4295 2012-06-27 22 4.5 485 70 -2 109.9 > > 4296 2012-06-27 23 4.9 497 701 109.9 > > 4297 2012-06-28 0 4.6 500 873 123.7 > > 4298 2012-06-28 1 4.7 503 872 123.7 > > 4299 2012-06-28 2 4.3 488 871 123.7 > > 4300 2012-06-28 3 4.9 479 870 123.7 > > 4301 2012-06-28 4 5.1 459 870 123.7 > > 4302 2012-06-28 5 4.9 458 870 123.7 > > 4303 2012-06-28 6 5.1 460 870 123.7 > > 4304 2012-06-28 7 5.0 451 87 -3 123.7 > > 4305 2012-06-28 8 5.2 452 87 -5 123.7 > > 4306 2012-06-28 9 5.2 445 87 -6 123.7 > > 4307 2012-06-28 10 5.0 430 87 -7 123.7 > > 4308 2012-06-28 11 4.6 434 87 -8 123.7 > > 4309 2012-06-28 12 4.1 442 87 -7 123.7 > > 4310 2012-06-28 13 3.9 433 87 -7 123.7 > > 4311 2012-06-28 14 3.5 421 87 -9 123.7 > > 4312 2012-06-28 15 4.4 420 87 -8 123.7 > > 4313 2012-06-28 16 4.6 421 87 -9 123.7 > > 4314 2012-06-28 17 3.2 417 87 -7 123.7 > > 4315 2012-06-28 18 3.5 415 87 -3 123.7 > > 4316 2012-06-28 19 3.9 394 87 -2 123.7 > > 4317 2012-06-28 20 4.2 407 870 123.7 > > 4318 2012-06-28 21 3.9 411 87 -3 123.7 > > 4319 2012-06-28 22 3.6 420 87 -5 123.7 > > 4320 2012-06-28 23 4.0 423 870 123.7 > > 4321 2012-06-29 0 3.2 418 1035 121.3 > > 4322 2012-06-29 1 3.3 421 1037 121.3 > > 4323 2012-06-29 2 3.7 411 1039 121.3 > > 4324 2012-06-29 3 3.8 413 1039 121.3 > > 4325 2012-06-29 4 3.3 413 1036 121.3 > > 4326 2012-06-29 5 3.2 417 1032 121.3 > > 4327 2012-06-29 6 3.4 414 1032 121.3 > > 4328 2012-06-29 7 3.7 405 1031 121.3 > > 4329 2012-06-29 8 3.9 393 1031 121.3 > > 4330 2012-06-29 9 4.2 385 1032 121.3 > > 4331 2012-06-29 10 4.4 381 1032 121.3 > > 4332 2012-06-29 11 4.0 386 1033 121.3 > > 4333 2012-06-29 12 4.7 386 1035 121.3 > > 4334 2012-06-29 13 5.2 378 1037 121.3 > > 4335 2012-06-29 14 5.1 376 1035 121.3 > > 4336 2012-06-29 15 4.7 366 1032 121.3 > > 4337 2012-06-29 16 4.5 378 1030 121.3 > > 4338 2012-06-29 17 4.8 369 1030 121.3 > > 4339 2012-06-29 18 5.4 365 1030 121.3 > > 4340 2012-06-29 19 5.7 369 1031 121.3 > > 4341 2012-06-29 20 5.8 373 1033 121.3 > > 4342 2012-06-29 21 4.9 392 103 10 121.3 > > 4343 2012-06-29 22 4.0 406 103 19 121.3 > > 4344 2012-06-29 23 7.1 402 103 19 121.3 > > 4345 2012-06-30 0 6.5 398 104 18 128.2 > > 4346 2012-06-30 1 7.6 397 104 12 128.2 > > 4347 2012-06-30 2 8.8 407 104 10 128.2 > > 4348 2012-06-30 3 11.2 404 104 -1 128.2 > > 4349 2012-06-30 4 11.2 410 1041 128.2 > > 4350 2012-06-30 5 8.8 410 1041 128.2 > > 4351 2012-06-30 6 9.7 417 104 -6 128.2 > > 4352 2012-06-30 7 12.3 446 104 -14 128.2 > > 4353 2012-06-30 8 9.5 476 104 -10 128.2 > > 4354 2012-06-30 9 8.7 496 104 -13 128.2 > > 4355 2012-06-30 10 12.6 560 104 -17 128.2 > > 4356 2012-06-30 11 11.4 600 104 -13 128.2 > > 4357 2012-06-30 12 11.4 607 104 -12 128.2 > > 4358 2012-06-30 13 11.1 603 104 -8 128.2 > > 4359 2012-06-30 14 11.1 616 104 -14 128.2 > > 4360 2012-06-30 15 9.7 616 104 -13 128.2 > > 4361 2012-06-30 16 9.7 629 104 -15 128.2 > > 4362 2012-06-30 17 6.6 654 104 -24 128.2 > > 4363 2012-06-30 18 6.5 660 104 -24 128.2 > > 4364 2012-06-30 19 6.8 676 104 -31 128.2 > > 4365 2012-06-30 20 7.2 675 104 -37 128.2 > > 4366 2012-06-30 21 7.0 657 104 -32 128.2 > > 4367 2012-06-30 22 6.4 634 104 -31 128.2 > > 4368 2012-06-30 23 7.6 640 104 -29 128.2 > > 4369 2012-07-01 0 6.9 650 126 -23 137.9 > > 4370 2012-07-01 1 7.0 635 126 -18 137.9 > > 4371 2012-07-01 2 6.9 651 126 -17 137.9 > > 4372 2012-07-01 3 6.3 661 126 -25 137.9 > > 4373 2012-07-01 4 5.6 663 126 -26 137.9 > > 4374 2012-07-01 5 5.4 655 126 -26 137.9 > > 4375 2012-07-01 6 5.1 656 126 -33 137.9 > > 4376 2012-07-01 7 4.9 658 126 -30 137.9 > > 4377 2012-07-01 8 5.1 648 126 -24 137.9 > > 4378 2012-07-01 9 5.0 643 126 -24 137.9 > > 4379 2012-07-01 10 5.0 633 126 -20 137.9 > > 4380 2012-07-01 11 5.1 650 126
Re: [R] Column names of model.matrix's output with contrast.arg
It's sorta-kinda-obliquely-partially documented in the examples: zapsmall(cP <- contr.poly(3)) # Linear and Quadratic output: .L .Q [1,] -0.7071068 0.4082483 [2,] 0.000 -0.8164966 [3,] 0.7071068 0.4082483 FWIW the faux package provides better-named alternatives. On 2024-06-17 4:25 p.m., Christophe Dutang wrote: Thanks for your reply. It might good to document the naming convention in ?contrasts. It is hard to understand .L for linear, .Q for quadratic, .C for cubic and ^n for other degrees. For contr.sum, we could have used .Sum, .Sum… Maybe the examples ?model.matrix should use names in dd objects so that we observe when names are dropped. Kind regards, Christophe Le 14 juin 2024 à 11:45, peter dalgaard a écrit : You're at the mercy of the various contr.XXX functions. They may or may not set the colnames on the matrices that they generate. The rationales for (not) setting them is not perfectly transparent, but you obviously cannot use level names on contr.poly, so it uses .L, .Q, etc. In MASS, contr.sdif is careful about labeling the columns with the levels that are being diff'ed. For contr.treatment, there is a straightforward connection to 0/1 dummy variables, so level names there are natural. One could use levels in contr.sum and contr.helmert, but it might confuse users that comparisons are with the average of all levels or preceding levels. (It can be quite confusing when coding is +1 for male and -1 for female, so that the gender difference is twice the coefficient.) -pd On 14 Jun 2024, at 08:12 , Christophe Dutang wrote: Dear list, Changing the default contrasts used in glm() makes me aware how model.matrix() set column names. With default contrasts, model.matrix() use the level values to name the columns. However with other contrasts, model.matrix() use the level indexes. In the documentation, I don’t see anything in the documentation related to this ? It does not seem natural to have such a behavior? Any comment is welcome. An example is below. Kind regards, Christophe #example from ?glm counts <- c(18,17,15,20,10,20,25,13,12) outcome <- paste0("O", gl(3,1,9)) treatment <- paste0("T", gl(3,3)) X3 <- model.matrix(counts ~ outcome + treatment) X4 <- model.matrix(counts ~ outcome + treatment, contrasts = list("outcome"="contr.sum")) X5 <- model.matrix(counts ~ outcome + treatment, contrasts = list("outcome"="contr.helmert")) #check with original factor cbind.data.frame(X3, outcome) cbind.data.frame(X4, outcome) cbind.data.frame(X5, outcome) #same issue with glm glm.D93 <- glm(counts ~ outcome + treatment, family = poisson()) glm.D94 <- glm(counts ~ outcome + treatment, family = poisson(), contrasts = list("outcome"="contr.sum")) glm.D95 <- glm(counts ~ outcome + treatment, family = poisson(), contrasts = list("outcome"="contr.helmert")) coef(glm.D93) coef(glm.D94) coef(glm.D95) #check linear predictor cbind(X3 %*% coef(glm.D93), predict(glm.D93)) cbind(X4 %*% coef(glm.D94), predict(glm.D94)) - Christophe DUTANG LJK, Ensimag, Grenoble INP, UGA, France ILB research fellow Web: http://dutangc.free.fr __ 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. -- Peter Dalgaard, Professor, Center for Statistics, Copenhagen Business School Solbjerg Plads 3, 2000 Frederiksberg, Denmark Phone: (+45)38153501 Office: A 4.23 Email: pd@cbs.dk Priv: pda...@gmail.com __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Dr. Benjamin Bolker Professor, Mathematics & Statistics and Biology, McMaster University Director, School of Computational Science and Engineering (Acting) Graduate chair, Mathematics & Statistics > E-mail is sent at my convenience; I don't expect replies outside of working hours. __ 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] Column names of model.matrix's output with contrast.arg
Dear Christophe and Ben, Also see the car package for replacements for contr.treatment(), contr.sum(), and contr.helmert() -- e.g., help("contr.Sum", package="car"). These functions have been in the car package for more than two decades, and AFAIK, no one uses them (including myself). I didn't write a replacement for contr.poly() because the current coefficient labeling seemed reasonably transparent. Best, John -- John Fox, Professor Emeritus McMaster University Hamilton, Ontario, Canada web: https://www.john-fox.ca/ -- On 2024-06-17 4:29 p.m., Ben Bolker wrote: Caution: External email. It's sorta-kinda-obliquely-partially documented in the examples: zapsmall(cP <- contr.poly(3)) # Linear and Quadratic output: .L .Q [1,] -0.7071068 0.4082483 [2,] 0.000 -0.8164966 [3,] 0.7071068 0.4082483 FWIW the faux package provides better-named alternatives. On 2024-06-17 4:25 p.m., Christophe Dutang wrote: Thanks for your reply. It might good to document the naming convention in ?contrasts. It is hard to understand .L for linear, .Q for quadratic, .C for cubic and ^n for other degrees. For contr.sum, we could have used .Sum, .Sum… Maybe the examples ?model.matrix should use names in dd objects so that we observe when names are dropped. Kind regards, Christophe Le 14 juin 2024 à 11:45, peter dalgaard a écrit : You're at the mercy of the various contr.XXX functions. They may or may not set the colnames on the matrices that they generate. The rationales for (not) setting them is not perfectly transparent, but you obviously cannot use level names on contr.poly, so it uses .L, .Q, etc. In MASS, contr.sdif is careful about labeling the columns with the levels that are being diff'ed. For contr.treatment, there is a straightforward connection to 0/1 dummy variables, so level names there are natural. One could use levels in contr.sum and contr.helmert, but it might confuse users that comparisons are with the average of all levels or preceding levels. (It can be quite confusing when coding is +1 for male and -1 for female, so that the gender difference is twice the coefficient.) -pd On 14 Jun 2024, at 08:12 , Christophe Dutang wrote: Dear list, Changing the default contrasts used in glm() makes me aware how model.matrix() set column names. With default contrasts, model.matrix() use the level values to name the columns. However with other contrasts, model.matrix() use the level indexes. In the documentation, I don’t see anything in the documentation related to this ? It does not seem natural to have such a behavior? Any comment is welcome. An example is below. Kind regards, Christophe #example from ?glm counts <- c(18,17,15,20,10,20,25,13,12) outcome <- paste0("O", gl(3,1,9)) treatment <- paste0("T", gl(3,3)) X3 <- model.matrix(counts ~ outcome + treatment) X4 <- model.matrix(counts ~ outcome + treatment, contrasts = list("outcome"="contr.sum")) X5 <- model.matrix(counts ~ outcome + treatment, contrasts = list("outcome"="contr.helmert")) #check with original factor cbind.data.frame(X3, outcome) cbind.data.frame(X4, outcome) cbind.data.frame(X5, outcome) #same issue with glm glm.D93 <- glm(counts ~ outcome + treatment, family = poisson()) glm.D94 <- glm(counts ~ outcome + treatment, family = poisson(), contrasts = list("outcome"="contr.sum")) glm.D95 <- glm(counts ~ outcome + treatment, family = poisson(), contrasts = list("outcome"="contr.helmert")) coef(glm.D93) coef(glm.D94) coef(glm.D95) #check linear predictor cbind(X3 %*% coef(glm.D93), predict(glm.D93)) cbind(X4 %*% coef(glm.D94), predict(glm.D94)) - Christophe DUTANG LJK, Ensimag, Grenoble INP, UGA, France ILB research fellow Web: http://dutangc.free.fr __ 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. -- Peter Dalgaard, Professor, Center for Statistics, Copenhagen Business School Solbjerg Plads 3, 2000 Frederiksberg, Denmark Phone: (+45)38153501 Office: A 4.23 Email: pd@cbs.dk Priv: pda...@gmail.com __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Dr. Benjamin Bolker Professor, Mathematics & Statistics and Biology, McMaster University Director, School of Computational Science and Engineering (Acting) Graduate chair, Mathematics & Statistics > E-mail is sent at my convenience; I don't expect replies outside of working hours. __ R-help@r-project.org m