Hello,
In the particular case you have, to change to NA based on condition, use
`is.na<-`.
Here is some test data, 3 times the same df.
set.seed(2021)
df3 <- df2 <- df1 <- data.frame(
x = c(0, 0, 1, 2, 3),
y = c(1, 2, 3, 0, 0),
z = rbinom(5, 1, prob = c(0.25, 0.75)),
a = letters[1:5]
Of Luigi Marongiu
> Sent: Thursday, September 2, 2021 3:35 PM
> To: r-help
> Subject: [R] Loop over columns of dataframe and change values condtionally
>
> Hello,
> it is possible to select the columns of a dataframe in sequence with:
> ```
> for(i in 1:ncol(df)) {
> df[
Hello,
it is possible to select the columns of a dataframe in sequence with:
```
for(i in 1:ncol(df)) {
df[ , i]
}
# or
for(i in 1:ncol(df)) {
df[ i]
}
```
And change all values with, for instance:
```
for(i in 1:ncol(df)) {
df[ , i] <- df[ , i] + 10
}
```
Is it possible to apply a condition?
t;https://www.precheza.cz/en/01-disclaimer/>
https://www.precheza.cz/en/01-disclaimer/
From: Hesham A. AL-bukhaiti
Sent: Tuesday, September 15, 2020 1:48 PM
To: PIKAL Petr
Subject: Re: [R] Loop for two columns and 154 rows
thanks petr v much
i attached my problem in word and my data
Dears in R :i have this code in R:
# this for do not work true (i tried )out<-read.csv("outbr.csv")
truth<-out[,seq(1,2)]truth<-cbind(as.character(truth[,1]),as.character(truth[,2])
,as.data.frame(rep(0,,dim(out)[1])));for (j in 1:2) { for (i in
1:20) { truth[(truth[,1]== truth[
## I start with sim_data_wide
sim_data_wide <- tidyr::spread(sim_data, quarter, pd)
## and calculate wide
wide1 <- with(sim_data_wide, cbind(PC_1 = P_1,
PC_2 = 1-(1-P_1)*(1-P_2),
PC_3 = 1-(1-P_1)*(1-P_2)*(1-P_3),
PC_4 = 1-(1-P_1
Does this help?
sim_wide2 <- (
sim_data
%>% arrange( borrower_id, quarter )
%>% group_by( borrower_id )
%>% mutate( cumpd = 1 - cumprod( 1 - pd ) )
%>% ungroup()
%>% mutate( qlbl = paste0( "PC_", quarter ) )
%>% select( borrower_id, qlbl, cumpd )
%>% spread( qlbl, cumpd )
)
On May 9, 2020 4:4
Dear Axel,
Assuming that you're not wedded to using mutate():
> D1 <- 1 - as.matrix(sim_data_wide[, 2:11])
> D2 <- matrix(0, 10, 10)
> colnames(D2) <- paste0("PC_", 1:10)
> for (i in 1:10) D2[, i] <- 1 - apply(D1[, 1:i, drop=FALSE], 1, prod)
> all.equal(D2, as.matrix(sim_data_wide[, 22:31]))
[1]
Hello,
Is there a less verbose approach to obtaining the PC_i variables inside the
mutate?
library(tidyverse)
sim_data <- data.frame(borrower_id = sort(rep(1:10, 20)),
quarter = rep(1:20, 10),
pd = runif(length(rep(1:20, 10 # conditional probs
Just to add one more option (which is best probably depends on if all
the same dates are together in adjacent rows, if an earlier date can
come later in the data frame, and other things):
df$count <- cumsum(!duplicated(df$Date))
Skill a cumsum of logicals, just a different way of getting the logi
Is this what you're after?
> df <- data.frame(
+ Date = as.Date(c("2018-03-29", "2018-03-29", "2018-03-29",
+ "2018-03-30", "2018-03-30", "2018- ..." ...
[TRUNCATED]
> df$count <- cumsum(c(TRUE, diff(df$Date) > 0))
> df
Date count
1 2018-03-29 1
2 2018
Hi Phillip,
While I really like Ana's solution, this might also help:
phdf<-read.table(text="Date count
2018-03-29 1
2018-03-29 1
2018-03-29 1
2018-03-30 1
2018-03-30 1
2018-03-30 1
2018-03-31 1
2018-03-31 1
2018-03-31 1",
header=TRUE,strings
Hello,
Maybe I am not understanding but isn't this what you have asked in your
previous question and my 2nd post (adapted) does?
If not, where does it fail?
Hope this helps,
Rui Barradas
Às 18:46 de 20/09/19, Phillip Heinrich escreveu:
With the data snippet below I’m trying to increment the
== dates$lag)) + 1
dates$lag <- NULL
> dates
dates.object count
1 2018-03-29 1
2 2018-03-29 1
3 2018-03-29 1
4 2018-03-30 2
5 2018-03-30 2
6 2018-03-30 2
7 2018-03-31 3
8 2018-03-31 3
9 2018-03-31 3
De: Phillip Heinrich
Enviado: vierne
With the data snippet below I’m trying to increment the “count” vector by one
each time the date changes.
Date count
1 2018-03-29 1
2 2018-03-29 1
3 2018-03-29 1
81 2018-03-30 1
82 2018-03-30 1
83 2018-03-30 1
165 2018-03-31 1
166 2018-03-31 1
1
Wow...Great one BOB...Gracias, Merci.
On Tue, 6 Aug 2019, 10:46 Bob O'Hara, wrote:
> For a start, try this:
>
> for(i in 1:5) {
> x <- runif(4,0,1)
> }
>
> Which will do what you want, but will over-write x each time (so isn't
> very good). Better (if you want to use the random numbers outside
For a start, try this:
for(i in 1:5) {
x <- runif(4,0,1)
}
Which will do what you want, but will over-write x each time (so isn't
very good). Better (if you want to use the random numbers outside the
loop) is this:
x <- matrix(NA, nrow=5, ncol=4)
for(i in 1:5) {
x[i,] <- runif(4,0,1)
}
But
Thanks guys, I've tried all you're suggesting, both for (x in 1:5) and
break, but I cant seem to ascertain when the loop has generated a vector of
4 random numbers 5 times.
On Tue, 6 Aug 2019, 10:09 Jim Lemon, wrote:
> Hi Tolulope,
> The "in" operator steps through each element of the vector o
Hi Tolulope,
The "in" operator steps through each element of the vector on the
right. You only have one element. Therefore you probably want:
for(x in 1:5)
...
Jim
Jim
On Tue, Aug 6, 2019 at 6:54 PM Tolulope Adeagbo
wrote:
>
> Hey guys,
>
> I'm trying to write a loop that will repeat an action
Is there anything wrong with just doing this?
x <- runif(5, min = 0, max = 1)
Also note that you use x to be at last 2 things: in
for (x in 5) {
you set it to 5, and then in the loop you
x = runif(1:4, min = 0, max = 1)
you make it a vector of length 4.
You also fail to use break to stop the
Hey guys,
I'm trying to write a loop that will repeat an action for a stipulated
number of times. I have written some code but i think i'm missing something.
for (x in 5) {
repeat{
x = runif(1:4, min = 0, max = 1)
print(x)
if (x== var_1[5]){
print("done")
}
pri
Thank you so much, Jim. That’s exactly what I need. Sorry for not providing the
data frame. But you created the correct data structure. Thanks again!
From: jim holtman
Sent: Monday, March 25, 2019 2:07 PM
To: Yuan, Keming (CDC/DDNID/NCIPC/DVP)
Cc: R-help@r-project.org
Subject: Re: [R] loop
"Does anyone know how to use loop (or other methods) to create new columns?
In SAS, I can use array to get it done. But I don't know how to do it in R."
Yup. Practically all users of R know how, as this is entirely elementary.
You will too if you make the effort to go through a basic R tutorial, o
R Notebook
You forgot to provide what your test data looks like. For example, are all
the columns a single letter followed by “_" as the name, or are there
longer names? Are there always matched pairs (‘le’ and ‘me’) or can singles
occur?
Hide
library(tidyverse)# create some data
test <- tibble(a
Hi All,
I have a data frame with variable names like A_le, A_me, B_le, B_me, C_le,
C_me
if A_le=1 or A_me=1 then I need to create a new column A_new=1. Same operation
to create columns B_new, C_new...
Does anyone know how to use loop (or other methods) to create new columns? In
SAS, I can
colname.mat[,
> > column]]),3,TRUE)))
> >
> > }
> >
> > > get(samplenames[1])
> > [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10]
> > year224 0.556 0.667 0.571 0.526 0.629 0.696 0.323 0.526 0.256 0.667
> > year142 0.324 0.32
0.526 0.256 0.667
> year142 0.324 0.324 0.706 0.638 0.600 0.294 0.612 0.688 0.432 0.387
> year237 0.571 0.696 0.629 0.471 0.462 0.471 0.452 0.595 0.333 0.435
>
>
>
>
> --
> *From:* Jim Lemon
> *Sent:* September 11, 2018 1:44 AM
> *To:* Kristi G
.333 0.435
From: Jim Lemon
Sent: September 11, 2018 1:44 AM
To: Kristi Glover
Cc: r-help mailing list
Subject: Re: [R] loop for comparing two or more groups using bootstrapping
Hi Kristy,
Try this:
colname.mat<-combn(paste0("year",1:4),2)
samplenames
Hi Kristy,
Try this:
colname.mat<-combn(paste0("year",1:4),2)
samplenames<-apply(colname.mat,2,paste,collapse="")
k<-1
for(column in 1:ncol(colname.mat)) {
assign(samplenames[column],replicate(k,sample(unlist(daT[,colname.mat[,column]]),3,TRUE)))
}
Then use get(samplenames[1]) and so on to
Hello,
There are now three solutions to the OP's problem.
I have timed them and the results depend on the matrix size.
The solution I thought would be better, Enrico's diag(), is in fact the
slowest. As for the other two, Eric's for loop is 50% fastest than the
matrix index for small matrices
> > Eric Bergeron Wed, 8 Aug 2018 12:53:32 +0300 writes:
>
> > You only need one "for loop"
> > for(i in 2:nrow(myMatrix)) {
> >myMatrix[i-1,i-1] = -1
> >myMatrix[i-1,i] = 1
> > }
Or none, with matrix-based array indexing and explicit control of the indices
to prevent overrun i
> Eric Bergeron Wed, 8 Aug 2018 12:53:32 +0300 writes:
> You only need one "for loop"
> for(i in 2:nrow(myMatrix)) {
>myMatrix[i-1,i-1] = -1
>myMatrix[i-1,i] = 1
> }
>
> HTH,
> Eric
and why are you not using Enrico Schumann's even nicer solution
(from August 6) that I had mention
Thanks a lot ! That's it!
Maija
ke 8. elok. 2018 klo 12.53 Eric Berger (ericjber...@gmail.com) kirjoitti:
> You only need one "for loop"
>
> for(i in 2:nrow(myMatrix)) {
>myMatrix[i-1,i-1] = -1
>myMatrix[i-1,i] = 1
> }
>
> HTH,
> Eric
>
>
> On Wed, Aug 8, 2018 at 12:40 PM, Maija Sirkjärv
You only need one "for loop"
for(i in 2:nrow(myMatrix)) {
myMatrix[i-1,i-1] = -1
myMatrix[i-1,i] = 1
}
HTH,
Eric
On Wed, Aug 8, 2018 at 12:40 PM, Maija Sirkjärvi
wrote:
> Thanks!
>
> If I do it like this:
>
> myMatrix <- matrix(0,5,5*2-3)
> print(myMatrix)
> for(i in 2:nrow(myMatrix))
>
Thanks!
If I do it like this:
myMatrix <- matrix(0,5,5*2-3)
print(myMatrix)
for(i in 2:nrow(myMatrix))
for(j in 2:ncol(myMatrix))
myMatrix[i-1,j-1] = -1
myMatrix[i-1,j] = 1
print(myMatrix)
I get the following result:
[,1] [,2] [,3] [,4] [,5] [,6] [,7]
[1,] -1 -1 -1 -1 -1
Hello,
If it is not running as you want it, you should say what went wrong.
Post the code that you have tried and the expected output, please.
(In fact, the lack of expected output was the reason why my suggestion
was completely off target.)
Rui Barradas
On 07/08/2018 09:20, Maija Sirkjärvi w
Thanks, but I didn't quite get it. And I don't get it running as it should.
ti 7. elok. 2018 klo 10.47 Martin Maechler (maech...@stat.math.ethz.ch)
kirjoitti:
>
> > Thanks for help!
> > However, changing the index from i to j for the column vector changes the
> > output. I would like the matrix t
> Thanks for help!
> However, changing the index from i to j for the column vector changes the
> output. I would like the matrix to be the following:
> -1 1 0 0 0 0 0
> 0 -1 1 0 0 0 0
> 0 0 -1 1 0 0 0
> .
> etc.
> How to code it?
as Enrico Schumann showed you: Without any loop, a very nic
Thanks for help!
However, changing the index from i to j for the column vector changes the
output. I would like the matrix to be the following:
-1 1 0 0 0 0 0
0 -1 1 0 0 0 0
0 0 -1 1 0 0 0
.
etc.
How to code it?
Best,
Maija
>> myMatrix <- matrix(0,5,12)
>> for(i in 1:nrow(myMatrix)) {
>>
Hello,
Eric is right but...
You have two assignments. The second sets a value that will be
overwritten is the next iteration by myMatrix[i,i] = -1 when 'i' becomes
the next value.
If you fix the second index and use 'j', you might as well do
myMatrix[] = -1
myMatrix[, ncol(myMatrix)] = 1
H
Quoting Maija Sirkjärvi :
I have a basic for loop with a simple matrix. The code is doing what it is
supposed to do, but I'm still wondering the error "subscript out of
bounds". What would be a smoother way to code such a basic for loop?
myMatrix <- matrix(0,5,12)
for(i in 1:nrow(myMatrix)) {
Both loops are on 'i', which is a bad idea. :-)
Also myMatrix[i,i+1] will be out-of-bounds if i = ncol(myMatrix)
On Mon, Aug 6, 2018 at 12:02 PM, Maija Sirkjärvi
wrote:
> I have a basic for loop with a simple matrix. The code is doing what it is
> supposed to do, but I'm still wondering the err
I have a basic for loop with a simple matrix. The code is doing what it is
supposed to do, but I'm still wondering the error "subscript out of
bounds". What would be a smoother way to code such a basic for loop?
myMatrix <- matrix(0,5,12)
for(i in 1:nrow(myMatrix)) {
for(i in 1:ncol(myMatrix)) {
Here is a simplified example:
dat <- data.frame(x=1:4, y1=runif(4), y2=runif(4), y3=4:1)
for (icol in 2:4) plot(dat[,1] , dat[,icol] )
(not tested, so hopefully all my parentheses are balanced, no typos, etc.)
This shows the basic principle.
An alternative is to construct each column name as a
As Jim says, "No data". R-help is very fussy about what files it will accept.
You might try changing the extention to txt. However the preferred way here is
to use the dput() command and paste the results into the post. See ?dput for
details.
On Monday, May 21, 2018, 1:40:59 a.m. EDT
Hi Steven,
Sad to say that your CSV file didn't make it to the list and I can't
access the data via your Dropbox account. Therefore we don't know the
structure of "mydata". If you are able to plot the data as in your
example, this might help:
genexp<-matrix(runif(360,1,2),ncol=18)
colnames(genexp)
Hello,
I am trying to create multiple scatter plot graphs. I have 1 independent
variable (Age - weeks post conception) and 18 dependent variables ("Gene n"
Expression) in one csv file. Is there a way to set up a looped function to
produce 18 individual scatterplots? At the moment, I am writing the
> On Jul 6, 2017, at 2:19 PM, Dai, Shengyu wrote:
>
> Hi R helpers,
>
>
>
> I hope this email finds you well.
>
>
>
> I am having trouble with R loop function in Tableau.
>
There is no "R loop function". (There is an R `for`-function.) If yo
Hi R helpers,
I hope this email finds you well.
I am having trouble with R loop function in Tableau. Please see the attachment
of a simple dataset. The problem is to test whether the value of columns is
match.
Because Tableau do not have iteration function, I coded “if statement” in
1. Statistically, you probably don't want to do this at all (but
that's another story).
2. Programatically, you probably want to use one of several packages
that do it already rather than trying to reinvent the wheel. A quick
search on rseek.org for "all subsets regression" brought up this:
http:
It's hard to imagine a situation where this makes sense, but of course
you can do it if you want. Perhaps
rhs <- unlist(sapply(1:(ncol(df)-1), function(x)
apply(combn(names(df)[-1], x), 2, paste, collapse = " + ")))
lapply(rhs, function(x) lm(as.formula(paste("y ~", x)), data = df))
--Ista
On Fr
Suppose I have the following data:
y<-rnorm(10)
age<-rnorm(10)
sex<-rbinom(10,1, 0.5)
edu<-round(runif(10, 1, 20))
edu2<-edu^2
df<-data.frame(y,age,sex,edu,edu2)
I want to run a large number of models, for example:
lm(y~age)
lm(y~age+sex)
lm(y~age+sex+edu)
lm(y~age+sex+edu+edu2)
lm(y~sex+edu2)
8 148 1 1
>
>
>
> Cheers
>
> Petr
>
>
>
>
>
> *From:* dusa.adr...@gmail.com [mailto:dusa.adr...@gmail.com] *On Behalf
> Of *Adrian Du?a
> *Sent:* Monday, October 10, 2016 12:26 PM
> *To:* Christoph Puschmann
> *Cc:* r-help@r-project.org; PIKAL Petr
&g
il.com [mailto:dusa.adr...@gmail.com] On Behalf Of Adrian
Du?a
Sent: Monday, October 10, 2016 12:26 PM
To: Christoph Puschmann
Cc: r-help@r-project.org; PIKAL Petr
Subject: Re: [R] Loop to check for large dataset
This is an example of how a reproducible code looks like, assuming you have
three columns i
This is an example of how a reproducible code looks like, assuming you have
three columns in your dataset named S (store), P (product) and W (week),
and also assuming they have integer values from 1 to 19, 1 to 22 and 1 to
157 respectively:
#
mydata <- expand.grid(seq(19), seq(22), seq(15
ull set STORE, WEEK and description and merge it
with original data by merge.
Cheers
Petr
From: Christoph Puschmann [mailto:c.puschm...@student.unsw.edu.au]
Sent: Monday, October 10, 2016 9:34 AM
To: PIKAL Petr ; r-help@r-project.org
Subject: Re: [R] Loop to check for large dataset
Dear Petr,
Dear Petr,
I attached a sample file, which contains the first 4 products.
It is more that I have: 157 weeks, 19 different Stores and 22 products:
157*19*22 = 65,626 rows. And as I sated I have roughly 63,127 rows. (so some
have to be missing).
All the best,
Christoph
Hi
see in line
> -Original Message-
> From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Christoph
> Puschmann
> Sent: Sunday, October 9, 2016 1:27 AM
> To: Adrian Dușa
> Cc: r-help@r-project.org; Christoph Puschmann
>
> Subject: Re: [R] Loop to
Dear Adrian,
Yes it is a cyclical data set and theoretically it should repeat this interval
until 61327. The data set itself is divided into 2 Parts:
1. Product category (column 10)
2. Number of Stores Participating (column 01)
Overall there are 22 different products and in each you have 19 diffe
It would help to have a minimal, reproducible example.
Unless revealing the structure of your FD object, it is difficult to
understand how a column having 61327 values would be "consistent over an 1
to 157 interval": is this interval cyclic until it reaches 61327 values?
>From your example using F
Hello,
I'm not at all sure if the following is what you need but instead of
for (i in length(FD$WEEK))
try
for (i in 1:length(FD$WEEK))
or even better
for (i in seq_len(FD$WEEK))
And use Control[i, 1], not Control[, 1]
Hope thi helps,
Rui Barradas
Citando Christoph Puschmann :
Hey
Hey all,
I would like to know if anyone, can put in the right direction of the following
problem:
I am currently want to use it to check if a column with a length of 61327 is
consistent over an 1 to 157 interval until the end of the column. In the case
the interval is interrupted I want to kno
Hi
I want to comment something.
When i added the detach(get(yyz)) the RAM consumption was considerable
reduced.
So, i want to declare this issue as solved and thank you all for your
assistance.
Good luck to all.
On Tue, Aug 30, 2016 at 6:24 PM, Juan Ceccarelli Arias
wrote:
> The attach(get(yyz))
The attach(get(yyz)) option i tried and it worked. The only issue, is that
when i'm trying to export the results, it takes a lot of time.
Considerably more than Stata. Also, the computer almost collapses for a
task which isn't so exhausting for my PC station.
Im dubious...
On Tue, Aug 30, 2016 at
Hello,
Try
attach(get(yyz))
Hope this helps,
Rui Barradas
Citando Juan Ceccarelli Arias :
Hi.
I need to loop over rda files.
I generated the list of them.
That's ok. The problem is that the name of the files are as _mm (eg
2010_01 is january or 2010, 2016_03 is march of 2016).
So,
You can attach rda files directly with the attach function, no need to
load them first (see the what argument in the help for attach). This
may do what you want more directly.
In general it is better to not use loops and attach for this kind of
thing. It is better to store multiple data objects
Here's the problem: when you load the object and name it yyz, its simply
storing the name of the data frame as a string. Naturally, when you you
attach the string, it throws an error. The loop actually loads the data
frame but inside yyz there's not a data frame.
One problem with load() is that yo
Hi.
I need to loop over rda files.
I generated the list of them.
That's ok. The problem is that the name of the files are as _mm (eg
2010_01 is january or 2010, 2016_03 is march of 2016).
So, when i try to use the attach function to create a simple table(age,
sex) it fails.
The only way to atta
Ok. Please, declare this issue as solved.
And thanks again for your help.
On Wed, Aug 24, 2016 at 2:18 PM, wrote:
> Maybe it's better to open a new thread.
>
> Rui Barradas
>
>
> Citando Juan Ceccarelli Arias :
>
> The error wasn't in the loop. It was in the file list.
> It's running now because
The error wasn't in the loop. It was in the file list.
It's running now because i added full.names option to TRUE
fuente=list.files("C:/Users/Jceccarelli/Bases/Stata", pattern="dta$",
full.names=T)
Now R can proccess the data. Now it callapses or stops because other kind
of error.
¿Should i open an
Maybe it's better to open a new thread.
Rui Barradas
Citando Juan Ceccarelli Arias :
> The error wasn't in the loop. It was in the file list.
> It's running now because i added full.names option to TRUE
> fuente=list.files("C:/Users/Jceccarelli/Bases/Stata",
> pattern="dta$", full.names=T)
>
I just doesn't work...
Im loading the read,dta13 package already.
When i try to perform a simple table(sex), i received the "File not found"
message.
However, if i load the data using the file.choose() option inside
read.dta13, i can open the stata file.
I don't know what am i doing wrong...
On Tu
Hello,
That means that probably the files are in a different folder/directory.
Use getwd() to see what is your current directory and
setwd("path/to/files") to set the right place where the files can be found.
Rui Barradas
Citando Juan Ceccarelli Arias :
> I just doesn't work...
> Im loading t
Or maybe a print() statement on the table() in the loop.
print(table(...))
Rui Barradas
Citando David Winsemius :
>> On Aug 23, 2016, at 10:01 AM, Juan Ceccarelli Arias
>> wrote:
>>
>> Im running this but the code doesn't seem work.
>> It just hangs out but doesn't show any error.
>>
>> fo
Compare what happens with these two command:
for (i in 1:3) { table(letters[1:4]) }
for (i in 1:3) { print(table(letters[1:4])) }
Then try modifying your loop similarly.
--
Don MacQueen
Lawrence Livermore National Laboratory
7000 East Ave., L-627
Livermore, CA 94550
925-423-1062
On 8/2
Hello,
Where does read_dta come from? You should also post the library() instruction.
Try to run the code without the loop, with just one file and inspect
xxx to see what's happening.
xxx <- read_dta(fuente[1])
str(xxx)
table(xxx$cise, xxx$sexo)
Rui Barradas
Citando Juan Ceccarelli Arias :
> On Aug 23, 2016, at 10:01 AM, Juan Ceccarelli Arias wrote:
>
> Im running this but the code doesn't seem work.
> It just hangs out but doesn't show any error.
>
>
> for (i in 1:length(fuente)){
>
> xxx=read_dta(fuente[i])
>
> table(xxx$cise, xxx$sexo)
>
> rm(xxx)
>
> }
I still find the
Im running this but the code doesn't seem work.
It just hangs out but doesn't show any error.
for (i in 1:length(fuente)){
xxx=read_dta(fuente[i])
table(xxx$cise, xxx$sexo)
rm(xxx)
}
On Tue, Aug 23, 2016 at 6:31 AM, wrote:
> Hello,
>
> The op could also use package sos to find that and oth
Hello,
The op could also use package sos to find that and other packages to
read stata files.
install.packages("sos")
library(sos)
findFn("stata")
found 374 matches; retrieving 19 pages
2 3 4 5 6 7 8 9 10
11 12 13 14 15 16 17 18 19
Downloaded 258 links in 121 packages
The first package is re
Dear Juan
If this is a Stata 13 file the package readstata13 available from CRAN
may be of assistance.
On 22/08/2016 18:40, Juan Ceccarelli Arias wrote:
I removed the data,frame=True...
I obtain this warnings...
Error in read.dta(fuente[i]) : not a Stata version 5-12 .dta file
In addition: Th
> On Aug 22, 2016, at 10:40 AM, Juan Ceccarelli Arias wrote:
>
> I removed the data,frame=True...
> I obtain this warnings...
> Error in read.dta(fuente[i]) : not a Stata version 5-12 .dta file
Well, that seems fairly self-explanatory. What version of Stata are you using
and does it have capac
I removed the data,frame=True...
I obtain this warnings...
Error in read.dta(fuente[i]) : not a Stata version 5-12 .dta file
In addition: There were 50 or more warnings (use warnings() to see the
first 50)
the warnings() throws this
Warning messages:
1: In `levels<-`(`*tmp*`, value = if (nl == nL)
Hello,
That argument doesn't exist, hence the error.
Read the help page ?read.dta more carefully. You will see that already
read.dta reads into a data.frame.
Hope this helps,
Rui Barradas
Citando Juan Ceccarelli Arias :
> Hi
> I need to apply some code over some stata files that are in fol
Hi
I need to apply some code over some stata files that are in folder.
I've wrote this
library(foreign)
fuente=list.files("C:/Users/Jceccarelli/Bases/Stata", pattern="dta$",
full.names=FALSE)
for (i in 1:length(fuente)){
xxx=read.dta(fuente[i], to.data.frame=TRUE)
}
But i get this error
Err
You seemed to have re-written over the "b" object in your code.
This might work for you.
library(MASS)
for (i in 58:1){
for(j in 58:i){
str.temp <- paste("y1 ~ x", i, "* x", j, sep = "")
univar <- glm.nb(as.formula(str.temp), data=df)
b <- summary(univar)$coeffients[4, 4]
if(b <
Hi Dear users,
for an interactive use, i am trying to write a loop that looks for all
variables in the conditions which i introduced, this is what I'm trying:
library(MASS)> i=1> for (i in 58:1){+ for(j in 58:i){+ + str.temp <-
paste("y1 ~ x", i, "* x", j, sep = "")+
univar<-glm.nb(as.formula(str.
m: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Brittany
> Demmitt
> Sent: Monday, June 20, 2016 12:15 PM
> To: r-help@r-project.org
> Subject: [R] loop testing unidentified columns
>
> Hello,
>
> I want to compare all of the columns of one data frame to anoth
23
-
David L Carlson
Department of Anthropology
Texas A&M University
College Station, TX 77840-4352
-Original Message-
From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Brittany Demmitt
Sent: Monday, June 20, 2016 12:15 PM
To: r-help@r-project.org
Subject: [R]
Hello,
I want to compare all of the columns of one data frame to another to see if any
of the columns are equivalent to one another. The first column in both of my
data frames are the sample IDs and do not need to be compared. Below is an
example of the loop I am using to compare the two data f
Hi tan sj,
It is by no means easy to figure out what you want without the code,
but If I read your message correctly, you can run the loops either
way. When you have nested loops producing output, it is often a good
idea to include the parameters for each run in the output as well as
the result so
hi, i am new in this field.
I am now writing a code in robustness simulation study. I have written a brief
code "for loop" for the factor (samples sizes d,std deviation ) , i wish to
test them in gamma distribution with equal and unequal skewness, with the above
for loop in a single code if pos
> On Feb 29, 2016, at 6:24 AM, Fernando McRayearth wrote:
>
> Need to create ascii maps for 10 species by writing a loop. So i have to have
> the vectors ready in the Global Environment, and the "raster map" so the
> information can be added.
>
> when writing the loop I am using the "paste"
Need to create ascii maps for 10 species by writing a loop. So i have to have
the vectors ready in the Global Environment, and the "raster map" so the
information can be added.
when writing the loop I am using the "paste" function because the only thing
that changes in the vector is the name o
Thank you David and Thierry, your answers helped a lot!
Kind regards,
RK.
__
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/postin
or 1.0536478 0.1712595 6.152348 1.41e-07
> virginica 0.6314052 0.1428938 4.418702 5.647610e-05
>
> David C
>
> -Original Message-
> From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of David L
> Carlson
> Sent: Monday, February 16, 2015 8:52 AM
&
inica 0.6314052 0.1428938 4.418702 5.647610e-05
David C
-Original Message-
From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of David L Carlson
Sent: Monday, February 16, 2015 8:52 AM
To: Ronald Kölpin; r-help@r-project.org
Subject: Re: [R] Loop over regression results
In R y
David L Carlson
Department of Anthropology
Texas A&M University
College Station, TX 77840-4352
-Original Message-
From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Ronald Kölpin
Sent: Monday, February 16, 2015 7:37 AM
To: r-help@r-project.org
Subject
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1
Dear all,
I have a problem when trying to present the results of several
regression. Say I have run several regressions on a dataset and saved
the different results (as in the mini example below). I then want to
loop over the regression results in ord
ty(alpha=.3)+xlab(names(scores)[i]))
dev.off()
}
Cheers
Petr
> -Original Message-
> From: r-help-boun...@r-project.org [mailto:r-help-bounces@r-
> project.org] On Behalf Of Patricia Seo
> Sent: Tuesday, October 28, 2014 1:59 AM
> To: r-help@r-project.org
> Subject: [R] Lo
Hi everyone,
I have been battling with this problem for the past month and reading all that
I can about it, but I just can't seem to understand what I'm doing wrong. It
seems easy and I can replicate others well-recorded attempts, but can not seem
to apply this to my data.
I have created a dat
1 - 100 of 632 matches
Mail list logo