Sys.Date()[1] "2025-02-21"
Di cosa si tratta?
Punti di forza:
Punti di debolezza:
Linguaggio:
Modalità d’uso:
Da non dimenticare:
Sys.Date()[1] "2025-02-21"
nrow(available.packages())
18897
Ma ci sono ormai molte altre fonti (GitHub e dintorni):
install.packages("devtools")
?devtools::install_githubO anche:
install.packages("remotes")
?remotes::install_githubUn’alternativa recente per installare pacchetti da fonti multiple:
(sembrerebbe più agevole, ma ancora da esplorare per scaricare package da diverse fonti)
nrow(getCRANmirrors())[1] 94
table(getCRANmirrors()$Country)
0-Cloud 0-Cloud-East-Asia Argentina
1 1 1
Australia Austria Belgium
3 1 2
Brazil Bulgaria Canada
3 1 3
Chile China Colombia
1 13 1
Costa Rica Cyprus Czech Republic
1 1 1
Denmark Ecuador Finland
1 1 1
France Germany Greece
3 8 1
Hungary Iceland India
1 1 2
Indonesia Iran Italy
1 1 2
Japan Korea Mexico
1 1 2
Morocco Netherlands New Zealand
1 2 1
Norway Poland Portugal
1 1 1
Russia South Africa Spain
1 1 2
Sweden Switzerland Taiwan
1 2 1
Turkey UK United Arab Emirates
1 3 1
Uruguay USA Worldwide
1 11 1
Documentazione ufficiale:
Task Views:
The R Journal:
diverse mailing list generali e Special Interest Group (SIG):
Alcune risorse interessanti:
… si fa per dire:
Ambienti multipiattaforma:
Due possibili modalità per effettuare la ricerca nell’help per parola chiave:
help.search("regression")??regression
Per nome della funzione (anche qui due possibili modalità):
help(mean)?mean
Per l’help di alcune funzioni (quelle di programmazione e gli operatori) è necessario usare gli apici (singoli o doppi):
?for
?"for"
E’ possibile cercare tutti gli oggetti (sulla “search list”) che contengono una data parola:
apropos("mean") [1] ".colMeans" ".rowMeans" "colMeans" "kmeans"
[5] "mean" "mean.Date" "mean.default" "mean.difftime"
[9] "mean.POSIXct" "mean.POSIXlt" "rowMeans" "weighted.mean"
così come cercare in che posizione si trovano:
find("mean")[1] "package:base"
find("kmeans")[1] "package:stats"
Gli esempi della funzioni possono essere provati usando la funzione example:
example(mean)
mean> x <- c(0:10, 50)
mean> xm <- mean(x)
mean> c(xm, mean(x, trim = 0.10))
[1] 8.75 5.50
example(plot)
plot> Speed <- cars$speed
plot> Distance <- cars$dist
plot> plot(Speed, Distance, panel.first = grid(8, 8),
plot+ pch = 0, cex = 1.2, col = "blue")
plot> plot(Speed, Distance,
plot+ panel.first = lines(stats::lowess(Speed, Distance), lty = "dashed"),
plot+ pch = 0, cex = 1.2, col = "blue")
plot> ## Show the different plot types
plot> x <- 0:12
plot> y <- sin(pi/5 * x)
plot> op <- par(mfrow = c(3,3), mar = .1+ c(2,2,3,1))
plot> for (tp in c("p","l","b", "c","o","h", "s","S","n")) {
plot+ plot(y ~ x, type = tp, main = paste0("plot(*, type = \"", tp, "\")"))
plot+ if(tp == "S") {
plot+ lines(x, y, type = "s", col = "red", lty = 2)
plot+ mtext("lines(*, type = \"s\", ...)", col = "red", cex = 0.8)
plot+ }
plot+ }
plot> par(op)
plot> ##--- Log-Log Plot with custom axes
plot> lx <- seq(1, 5, length.out = 41)
plot> yl <- expression(e^{-frac(1,2) * {log[10](x)}^2})
plot> y <- exp(-.5*lx^2)
plot> op <- par(mfrow = c(2,1), mar = par("mar")-c(1,0,2,0), mgp = c(2, .7, 0))
plot> plot(10^lx, y, log = "xy", type = "l", col = "purple",
plot+ main = "Log-Log plot", ylab = yl, xlab = "x")
plot> plot(10^lx, y, log = "xy", type = "o", pch = ".", col = "forestgreen",
plot+ main = "Log-Log plot with custom axes", ylab = yl, xlab = "x",
plot+ axes = FALSE, frame.plot = TRUE)
plot> my.at <- 10^(1:5)
plot> axis(1, at = my.at, labels = formatC(my.at, format = "fg"))
plot> e.y <- -5:-1 ; at.y <- 10^e.y
plot> axis(2, at = at.y, col.axis = "red", las = 1,
plot+ labels = as.expression(lapply(e.y, function(E) bquote(10^.(E)))))
plot> par(op)
example(plotmath)
pltmth> require(graphics)
pltmth> x <- seq(-4, 4, length.out = 101)
pltmth> y <- cbind(sin(x), cos(x))
pltmth> matplot(x, y, type = "l", xaxt = "n",
pltmth+ main = expression(paste(plain(sin) * phi, " and ",
pltmth+ plain(cos) * phi)),
pltmth+ ylab = expression("sin" * phi, "cos" * phi), # only 1st is taken
pltmth+ xlab = expression(paste("Phase Angle ", phi)),
pltmth+ col.main = "blue")
pltmth> axis(1, at = c(-pi, -pi/2, 0, pi/2, pi),
pltmth+ labels = expression(-pi, -pi/2, 0, pi/2, pi))
pltmth> ## How to combine "math" and numeric variables :
pltmth> plot(1:10, type="n", xlab="", ylab="", main = "plot math & numbers")
pltmth> theta <- 1.23 ; mtext(bquote(hat(theta) == .(theta)), line= .25)
pltmth> for(i in 2:9)
pltmth+ text(i, i+1, substitute(list(xi, eta) == group("(",list(x,y),")"),
pltmth+ list(x = i, y = i+1)))
pltmth> ## note that both of these use calls rather than expressions.
pltmth> ##
pltmth> text(1, 10, "Derivatives:", adj = 0)
pltmth> text(1, 9.6, expression(
pltmth+ " first: {f * minute}(x) " == {f * minute}(x)), adj = 0)
pltmth> text(1, 9.0, expression(
pltmth+ " second: {f * second}(x) " == {f * second}(x)), adj = 0)
pltmth> ## note the "{ .. }" trick to get "chained" equations:
pltmth> plot(1:10, 1:10, main = quote(1 <= {1 < 2}))