Displaying 20 results from an estimated 339 matches for "dta".
Did you mean:
data
2011 Aug 17
2
dotchart vs. dotplot ... groups
...r aspects of the plot appearance.
Basically, w/ lattice I've not been able to get the y-axis label to include the group variable.
I'd like...
A
1
2
B
1
2
3
4
C
1
2
3
I'm getting...
1
2
1
2
3
4
1
2
3
The following example code illustrates....
set.seed(18)
dta <- data.frame(var1=factor(c("A", "A", "B", "B", "B", "B", "C", "C", "C")),
var2=c(1,2,1,2,3,4,1,2,3),
var3=round(runif(9,1,10),1),
plotorder=9:1)
dta
windows(3,3)
dotchart(dta$var3[order(dta$var1, -...
2008 Jan 26
1
Read stata file from internet?
Dear R-helpers,
I would like to have my students read into R an online Stata dataset: 'http://www.stat.ucla.edu/projects/datasets/risk_project.dta'
I was able to read it into R after downloading it and converting it
with StatTransfer (http://www.stattransfer.com/).
Here is what happens when I use read.dta() as I would use read.table():
> require(foreign)
> risk2 <- read.dta('http://www.stat.ucla.edu/projects/datasets/ris...
2017 Jun 29
0
Different date formats in one column
...atterns you have, and even that may not be able to get them all
right unless you know something that limits the range of possible formats.
Below is an example of how this can be done. There are many tutorials on
the internet that describe regular expressions... they are not unique to
R.
#-----
dta <- read.table( text=
"DtStr
020917
2/22/17
May-2-2015
May-12-15
", header=TRUE, as.is=TRUE )
dta$Dt <- as.Date( NA )
idx <- grepl(
"^(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)-[0-9]+-[0-9]{4}$",
dta$DtStr, perl=TRUE, ignore.case = TRUE )
dta$Dt[ idx ] <- a...
2005 Jun 06
3
write.dta limits
Hope everyone id doing great ..
Just need some clarification over the limit of write.dta. I have some
coauthors that use stata and I need to send them my data in .dta format.
the data.frame is 41706x229 and I get the following
Error in write.dta(Panel, file = "STATADATA/Panel.dta", version = 7) :
a binary write error occured
Once I subset the data everything works out fin...
2017 Sep 18
0
Q2/R2 ratio in PLSDA
...ions of R2/Q2 ratios?
2.Is there a rule telling me what values my errorates should have in order to have a good model performance
3. Is there a way to calculate R2/Q2 ratios for PLSDA using the mixOmics package
Thank you
Below I provide a simplified example data set and my code:
DATA:
> dput(dta)
structure(list(Treatment = structure(c(2L, 1L, 1L, 2L, 2L, 1L,
2L, 2L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 1L, 2L, 2L, 2L, 1L, 2L,
1L, 1L, 2L, 1L, 2L, 2L, 1L, 1L), .Label = c("C", "CAT"), class = "factor"),
comp1 = c(0, 0.5677, 0.4486, 0.1772, 0.2145, 0.0302, 0.216,...
2017 Jun 29
1
Different date formats in one column
...atterns you have, and even that may not be able to get them all
right unless you know something that limits the range of possible formats.
Below is an example of how this can be done. There are many tutorials on
the internet that describe regular expressions... they are not unique to
R.
#-----
dta <- read.table( text=
"DtStr
020917
2/22/17
May-2-2015
May-12-15
", header=TRUE, as.is=TRUE )
dta$Dt <- as.Date( NA )
idx <- grepl(
"^(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)-[0-9]+-[0-9]{4}$",
dta$DtStr, perl=TRUE, ignore.case = TRUE )
dta$Dt[ idx ] <- a...
2013 Jan 16
1
Read.dta and Write.dta Binary Data Error
Thanks in advance.
I pass data sets between R and Stata and think dta files would be the best
files for this. To do this I can use package foreign or package memisc. I
mostly use foreign, although have used memisc and this problem mostly didn't
happen, but created errors at other times.
I have a csv data set (and created a test case) with with at least one
colum...
2018 Mar 22
3
exporting data to stata
Hi,
I am new to R and I want to export data into Stata. Could somebody help with that? Thanks a lot.
This is the code I am using:
> setwd("D:/datasets/Seg-bcn/ESBD")
> data1 <- readRDS("r17045_ESDB_Habitatges_BDD_V_1_0.rds")
> library(foreign)
> write.dta(data="data1", file = "D:/datasets/data1.dta")
Error in write.dta(data = "data1", file = "D:/datasets/data1.dta") :
The object "dataframe" must have class data.frame
> class (data1)
[1] "survey.design2" "survey.design"
[[a...
2007 Jul 30
1
correlation and matrix
...groups of 4 variables.
-I have to delete the factors just having one level ( because when
correlating one-level factors, the output is NA)
here is my code:
lst<-seq(1, 204, by=12) % there are 12 factors for 17 natural resources
for (n in lst)
{
Mx<- matrix(0, byrow = F, ncol = 4, nrow=nrow(dta)) % I extract the 4
factors I have to correlate and I'd like to do it for each n
{if (nlevels(dta[,n+4])!=1)
Mx[,1]<-dta[,n+4]
else
Mx[,1]<-NA}
{if (nlevels(dta[,n+5])!=1)
Mx[,2]<-dta[,n+5]
else
Mx[,2]<-NA}
{if (nlevels(dta[,n+7])!=1)
Mx[,3]<-dta[,n+7]
else
Mx[,3]<-NA}
{if...
2017 Sep 18
1
Data arrangement for PLSDA using the ropls package
...somebody maybe tell me how I correctly have to arrange my data in order to perfom a PLSDA using the "ropls" package?
Thank you very much,
Mike
Please find my code and an example data set below:
CODE:
#Input data and convert to data frame and define "Sample" as row
dta<-read.csv("Demo.csv",sep=";",header=T)
rownames(dta)<-dta$Sample
dta
#Remove non-numeric "Sample" and "Gender" rows and convert to matrix
dta.exp<-dta[,c(-1,-7)]
matrix<-as.matrix(dta.exp)
str(matrix)
matrix
#create vector with "g...
2018 Mar 22
1
exporting data to stata
On Thu, Mar 22, 2018 at 4:52 AM, Raja, Dr. Edwin Amalraj
<amalraj.raja at abdn.ac.uk> wrote:
> Hi ,
>
> library(foreign)
> write.dta(data1, "data1.dta")
>
> should work.
I don't think so:
> library(foreign)
> example(svydesign)
> write.dta(dstrat, "~/Downloads/foo.dta")
Error in write.dta(dstrat, "~/Downloads/foo.dta") :
The object "dataframe" must have class data....
2017 Jun 28
4
Different date formats in one column
Hi,?
I have a data set with various date formats in one column and not sure how to unify it.Here is a few formats:
02091702/22/170221201703/17/160015-08-239/2/1500170806May-2-201522-March-2014
I tried parse_date_time from lubridate library but it failed.Thanks so much.?Best,Farnoosh
[[alternative HTML version deleted]]
2010 Jun 21
1
survfit function - event information???
...*******************
*Format of the Matrix:*
[,1] [,2] [,3] [,4] [,5] [6]
[7] [8]
[1,] "rs12082473_T" "2288" "2211" "21" "56" (Number of Events)
*******************
*CODE & Output:*
ee=survfit(Surv(dta$dmi,dta$mi==1)~dta[,i],data=dta)
records n.max n.start *events* median 0.95LCL 0.95UCL
dta[, i]=0 2211 2211 2211 *106 * NA NA NA
dta[, i]=1 21 21 21 *2 * NA NA NA
dta[, i]=2 56 56 56 * 3* NA NA NA
****...
2011 Aug 06
3
.dta from e-mail
I got a .dta extension file by e-mail, but I can't save it in my computer
and open it in R. How can I do it?
[[alternative HTML version deleted]]
2007 Jun 15
1
importing .dta files
I'm trying to read in a Stata file but I've never used this function (
read.dta). It's the only one that seems to come close to working, but I
keep getting this error:
> data<-read.dta("C:/Documents and
Settings/Chris/Desktop/S4412/catestscores.dta")
Error in read.dta("C:/Documents and
Settings/Chris/Desktop/S4412/catestscores.dta", :
a...
2008 Aug 06
3
Help in running Stata dataset in R
Dear All,
I installed R 2.7.0 and tried to call a dataset i had ealier own called
on R2.6.2 but i keep on getting an error:
use("maltreat.dta")
Error in fromchar(x) :
character string is not in a standard unambiguous format
Tried doing the same with R2.7.1 but i get the same error.
However if i call the same on R 2.6.2, there is no error:
use("maltreat.dta")
> des()
No. of observations = 670
Variable...
2011 Nov 08
2
compare linear regressions
Hi,
I'm trying to compare two linear regressions. I'm using the
following approach:
##################
xx<-1:100
df1 <- data.frame(x = xx, y = xx * 2 + 30 + rnorm(n=length(xx),sd=10), g = 1)
df2 <- data.frame(x = xx, y = xx * 4 + 9 + rnorm(n=length(xx),sd=10), g = 2)
dta <- rbind(df1, df2)
dta$g <- factor(dta$g)
plot(df2$x,df2$y,type="l",col="red")
lines(df1$x,df1$y,col="blue")
summary(lm(formula = y ~ x + g + x:g, dta))
##################
I learned that the coefficients (g2 and x:g2) tell me about the
differences in intercept an...
2018 Mar 22
0
exporting data to stata
Hi ,
library(foreign)
write.dta(data1, "data1.dta")
should work. The file will be saved in the working directory.
Use
getwd()
to know the working directory.
Best wishes
Amalraj Raja
-----Original Message-----
From: R-help [mailto:r-help-bounces at r-project.org] On Behalf Of rosario scandurra
Sent: 22 March 2018 07:...
2017 Jun 30
0
Different date formats in one column
...to get them all
>
>right unless you know something that limits the range of possible
>formats.
>
>Below is an example of how this can be done. There are many tutorials
>on
>the internet that describe regular expressions... they are not unique
>to
>R.
>
>#-----
>dta <- read.table( text=
>"DtStr
>020917
>2/22/17
>May-2-2015
>May-12-15
>", header=TRUE, as.is=TRUE )
>
>dta$Dt <- as.Date( NA )
>
>idx <- grepl(
>"^(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)-[0-9]+-[0-9]{4}$",
>dta$DtStr, perl=...
2003 Nov 04
2
write.dta and handling labels
Hello,
I need to write out a data matrix as a STATA 7 file and this happens perfectly with write.dta(), except I cannot seem to export the labelnames to Stata.
So far I have tried the following:
# X is the data matrix that is to be exported
attributes(X)$var.labels <- c("apple", "banana", "cat")
write(X, filename = "text.dta", version = 7)
When i open...