Posts by djas • 276 points
7 posts
-
2
votes1
answer270
viewsA: How to download multiple urls in R?
There are several ways; a not very elegant: library(RCurl) library(XML) base = 'http://www.rsssfbrasil.com/tablesae/' page = url(base) download.file(base, destfile='test.html') page =…
-
3
votes1
answer2475
viewsA: How to transform a list into a vector in R?
At least two ways -- surely there are others: # note a diferenca entre as listas mylist <- list ("2 tomates", "5 tomates", "9 tomates") first, myvector <- unlist(mylist) x =…
-
2
votes3
answers830
viewsA: Loop in R with indexing and matrix
Hard to understand what the result expected by the OP, but here goes a try. Y = matrix(NA,nrow=0,ncol=5) x=c(0,1,2,3,4) z=c(1,2,3,4,5) for (i in 1:5) { y = 1*x+2*z[i] Y = rbind(Y,y) } Y [,1] [,2]…
-
0
votes2
answers97
viewsA: Subtracting matrices with different arguments
no; it just means that x and yare objects of different dimensions. for example, x<-array(1:4,dim=c(4)) y = 1:4 x-y [1] 0 0 0 0…
-
0
votes2
answers6494
viewsA: How to create inverse matrix in R
if you reverse X'X, the simplest way is by using solve(): # crio uma matriz qualquer (3 colunas, 100 linhas) X = cbind(1, rnorm(100), runif(100)) # invertenddo X'X a = solve(t(X)%*%X) # invertendo a…
-
1
votes3
answers530
viewsA: How to select all data.frame variables at once for a regression?
or, if dados is your frame and the first column has name y (as is your case), modelo <- lm(formula=dados) also works.
-
3
votes1
answer473
viewsA: How to generate correlated variables in R?
There are at least two ways to do this: Since the two variables are Normal, you can use the function mvrnorm() package MASS. Another option is to follow these instructions: # gerar dois vetores…