5,5 1,3
01/05/2012 2,9 5,7 0
01/06/2012 3 7 0
01/07/2012 3,1 6,6 0
-Mensagem original-
De: Petr PIKAL [mailto:petr.pi...@precheza.cz]
Enviada em: terça-feira, 30 de agosto de 2011 09:28
Para: Filipe Leme Botelho
Cc: r-help@r-project.org
Assunto
Hi all,
I am reading previous posts and guidance on the 'reshape' package in order to
solve the simple problem below. Thinking that this might be very trivial for
most of you, I thought there could be a fast solution coming from you guys, and
I´d be very thankful for that.
I have a matrix with
--- Begin Message ---
Vickie, try something like this
# Dummy data
lst <- list("This",c("should", "work",
"just"),"fine","I","guess...",c(NA,NA))
names(lst) <- letters[seq(1,length(lst))]
lst
# Arranging
for (i in 1:length(lst)) {
lst[[i]] <- as.matrix(lst[[i]])
rownames(lst[[i]]) <- rep(nam
Hi Frederico. I would keep the data as it is, create two small vectors
referring to the ranges and use a mapply (as a sapply but with multiple
variables) for the function. Hope the example below is helpful, although as
usual someone out there will have a better solution for it.
> dta <- c()
> f
--- Begin Message ---
Hi Vikas. Apply the logic in the example below in your dataframe
> dta
V1 V1
1 85 32
2 80 33
3 77 11
4 75 56
5 96 43
6 99 12
7 94 32
8 97 44
> dta[,1]>
[1] TRUE TRUE FALSE FALSE TRUE TRUE TRUE TRUE
> which(dta[,1]>)
[1] 1 2 5 6 7 8
> ref <- which(dta[,1]>)
> dt
--- Begin Message ---
For sure some smart cookie has a much better solution but this can do
the trick
dt <- as.data.frame(cbind(rnorm(1:12),rnorm(1:12)))
regs <- sapply(seq(1,9,by=4), function(x) coef(lm(dt[(x:(x+3)),1] ~
dt[(x:(x+3)),2])))
tmp <- c()
for (i in 1:ncol(regs)) {
tmp <-
--- Begin Message ---
This may be useful; convert them to NAs then omit them afterwards, you
end up keeping the positions where you had 0s.
> n[y==0] <- NA
> n
[1] 1 1 1 1 1 1 2 2 NA NA NA 2 3 3 NA NA 3 3
> na.omit(n)
[1] 1 1 1 1 1 1 2 2 2 3 3 3 3
attr(,"na.action")
[1] 9 10 11
Hi Tom,
At least to me it´s hard to picture what´s wrong without further details
regarding your data. I use spline/linear interpolation of time series
regularly, so maybe this example help you out.
> ci_x
[1] 1 4 69 131 194 256 320 382
> ci_y
[1] 0.1211 0.1213 0.1233 0.1241 0.1250 0.1254 0
Flávio, first install package 'xts'. Then with a matrix with rownames as dates
like:
> testing
[,1]
2011-05-12 177.05
2011-05-13 182.85
2011-05-16 182.20
2011-05-17 181.90
2011-05-18 180.50
2011-05-19 184.95
2011-05-20 181.75
2011-05-23 180.85
2011-05-24 182.75
2011-05-25 186.80
2011
--- Begin Message ---
Ivan, try this
d1 <- matrix(rnorm(10),50,50)
d2 <- matrix(rnorm(10),50,50)
regs <- lapply(1:ncol(d1), function(i) lm(d1[,i] ~ d2[,i])
HTH, Filipe
-Mensagem original-
De: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
Em nome de ivan
Enviada
Hi all, I need to know two quick things regarding RPut function from RExcel.
1/ How to assign colnames and rownames in the command, i.e., something like
'=RPut("example"; A10:F50; rownames=TRUE; colnames=TRUE)'.
2/ When I use RPut and I have NAs in Excel selection, the entire matrix is
coerced
--- Begin Message ---
Hi,
I never tried to read SPSS data, but to read a csv extracted from excel
for instance, you can do something like
read.csv(example, na.strings='#N/A')
if that is the case, then your NAs will be identified and properly read
while loading data.
HTH. Cheers,
Filipe Botelho
--- Begin Message ---
Hi Barjesh,
I am not sure which data you analyze, but once I had a similar situation
and it was a multicolinearity issue. I realized this after finding a
huge correlation between the independent variables, then I dropped one
of them and signs of slopes made sense.
Beforehand
Many thanks for this clever solution, it is much more elegant and efficient
indeed. Cheers!
-Mensagem original-
De: Petr PIKAL [mailto:petr.pi...@precheza.cz]
Enviada em: sexta-feira, 3 de junho de 2011 09:37
Para: Filipe Leme Botelho
Cc: Lisa; r-help@r-project.org
Assunto: Odp: [R] RES
--- Begin Message ---
I think this is proper.
a <- c(1, 2, 3, 3, 4, 4, 5, 6, 1, 2, 2, 3, 1, 2, 1, 2, 3, 3, 4, 5, 1, 2,
3, 4)
b <- c(1, 5, 8, 9, 14, 20, 3, 10, 12, 6, 16, 7, 11, 13, 17, 18, 2, 4,
15, 19)
ref <- 1
for (i in 2:length(a)) {
if (a[i]!=a[i-1]) ref <- c(ref, ref[length(ref)]+1)
if
--- Begin Message ---
Hi Martin, I believe this can do the trick. Let me know otherwise.
Cheers
testing <- matrix(rnorm(10),50,2)
testing_list <- lapply(1:nrow(testing), function(j) testing[j,])
-Mensagem original-
De: r-help-boun...@r-project.org [mailto:r-help-boun...@r
Hi Caio,
I just replied to a fellow who needed to run a series of regressions changing
the dependent variables for the same period. I believe your solution might be
similar to that one, just making the window dynamic instead. I used a lapply to
store regressions and sapplys to extract stats fro
--- Begin Message ---
Hi Raphael, using your data as is, and if I understood what you
need
> birds
Square Sp1 Sp2 Sp3 Sp4 Spn Natprop Effort
[1,] 1 1 0 1 1 0 0.5 10
[2,] 2 1 0 1 1 0 0.6 20
[3,] 3 1 1 0 1 0 0.8 23
[4
Estefania, if you do something like
your.matrix <- matrix(1, 50, 50)
your.matrix[upper.tri(your.matrix)] <- NA
You will have NAs for the entire upper triangle. If you opt to do
your.matrix[upper.tri(your.matrix)] <- ""
The upper triangle will be empty but it will coerc
--- Begin Message ---
Why not using Statconn/RExcel?
-Mensagem original-
De: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
Em nome de Robert Baer
Enviada em: sexta-feira, 13 de maio de 2011 09:33
Para: Asan Ramzan; r-help@r-project.org
Assunto: Re: [R] Excel to R
---
20 matches
Mail list logo