Re: [R] Problem in reading data

2009-12-01 Thread Gabor Grothendieck
Specify that your input is of class yearmon (as opposed to Date class) and
also correct the format specification as per the percent codes in ?strptime

library(zoo)
z <- read.zoo("clipboard", FUN = as.yearmon, format = "%b-%y")



On Tue, Dec 1, 2009 at 12:55 PM, Megh  wrote:

>
> In my Excel file, I have data in following format :
>
> Feb-07  38.49
> Mar-07  39.95
> Apr-07  37.47
> May-07  35.77
> Jun-07  32.96
> Jul-07  33.27
>
> I tried to copy this data as a time series using following code :
>
> library(zoo)
> dat <- read.zoo(file="clipboard", format="%m-%y")
>
> However getting following error :
>
> Error in read.zoo(file = "clipboard", format = "%m-%y") :
>  index has bad entries at data rows: 1 2 3 4 5 6
>
> Can anyone please guide me what is the right way to do that?
>
> Thanks,
>
> --
> View this message in context:
> http://n4.nabble.com/Problem-in-reading-data-tp932386p932386.html
> Sent from the R help mailing list archive at Nabble.com.
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Problem in reading data

2009-12-01 Thread Megh

In my Excel file, I have data in following format :

Feb-07  38.49
Mar-07  39.95
Apr-07  37.47
May-07  35.77
Jun-07  32.96
Jul-07  33.27

I tried to copy this data as a time series using following code :

library(zoo)
dat <- read.zoo(file="clipboard", format="%m-%y")

However getting following error :

Error in read.zoo(file = "clipboard", format = "%m-%y") : 
  index has bad entries at data rows: 1 2 3 4 5 6

Can anyone please guide me what is the right way to do that?

Thanks,

-- 
View this message in context: 
http://n4.nabble.com/Problem-in-reading-data-tp932386p932386.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] problem in reading data

2009-05-01 Thread tedzzx

Dear jholtman,

The problem is that in this case, it seems that the blank is not replaced by
NA according to the information I quote. It is replaced by blank. I have
try: which(is.na(a$V4)), but get NA.

I want to delete the rows that have different format from others.

jholtman wrote:
> 
> In some cases the missing values have been replaced by NAs so you can look
> for those.
> 
> On Thu, Apr 30, 2009 at 9:28 AM, tedzzx  wrote:
> 
>>
>> Dear R users
>> I am runing into a problem in reading data in R
>> This is the error information
>>
>> a<-read.table("tt_mb_200409.txt",as.is=T)
>> Error in scan(file, what, nmax, sep, dec, quote, skip, nlines,
>> na.strings,
>> :
>>  line 1653997 did not have 5 elements
>>
>> It seams that some lines don't have equal variables. I want to try
>>
>> > a<-read.table("tt_mb_200409.txt",as.is=T,fill=T)
>> > a[1653997,]
>>   V1  V2V3 V4 V5
>> 1653997 00992 2777010
>>
>> But, I want to delect the rows that do not have the same number of
>> variables
>> with others, how can I do this?
>>
>> Many thanks
>>
>> Ted
>>
>>
>> --
>> View this message in context:
>> http://www.nabble.com/problem-in-reading-data-tp23316321p23316321.html
>> Sent from the R help mailing list archive at Nabble.com.
>>
>> __
>> R-help@r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide
>> http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>>
> 
> 
> 
> -- 
> Jim Holtman
> Cincinnati, OH
> +1 513 646 9390
> 
> What is the problem that you are trying to solve?
> 
>   [[alternative HTML version deleted]]
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
> 
> 

-- 
View this message in context: 
http://www.nabble.com/problem-in-reading-data-tp23316321p23327660.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] problem in reading data

2009-04-30 Thread jim holtman
In some cases the missing values have been replaced by NAs so you can look
for those.

On Thu, Apr 30, 2009 at 9:28 AM, tedzzx  wrote:

>
> Dear R users
> I am runing into a problem in reading data in R
> This is the error information
>
> a<-read.table("tt_mb_200409.txt",as.is=T)
> Error in scan(file, what, nmax, sep, dec, quote, skip, nlines, na.strings,
> :
>  line 1653997 did not have 5 elements
>
> It seams that some lines don't have equal variables. I want to try
>
> > a<-read.table("tt_mb_200409.txt",as.is=T,fill=T)
> > a[1653997,]
>   V1  V2V3 V4 V5
> 1653997 00992 2777010
>
> But, I want to delect the rows that do not have the same number of
> variables
> with others, how can I do this?
>
> Many thanks
>
> Ted
>
>
> --
> View this message in context:
> http://www.nabble.com/problem-in-reading-data-tp23316321p23316321.html
> Sent from the R help mailing list archive at Nabble.com.
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



-- 
Jim Holtman
Cincinnati, OH
+1 513 646 9390

What is the problem that you are trying to solve?

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] problem in reading data

2009-04-30 Thread Dimitri Liakhovitski
What kind of .txt file is it? If it's a tab-delimited file, try
read.delim("tt_mb_200409.txt")
Dimitri

On Thu, Apr 30, 2009 at 9:28 AM, tedzzx  wrote:
>
> Dear R users
> I am runing into a problem in reading data in R
> This is the error information
>
> a<-read.table("tt_mb_200409.txt",as.is=T)
> Error in scan(file, what, nmax, sep, dec, quote, skip, nlines, na.strings,
> :
>  line 1653997 did not have 5 elements
>
> It seams that some lines don't have equal variables. I want to try
>
>> a<-read.table("tt_mb_200409.txt",as.is=T,fill=T)
>> a[1653997,]
>           V1      V2        V3     V4     V5
> 1653997 00992 2777010
>
> But, I want to delect the rows that do not have the same number of variables
> with others, how can I do this?
>
> Many thanks
>
> Ted
>
>
> --
> View this message in context: 
> http://www.nabble.com/problem-in-reading-data-tp23316321p23316321.html
> Sent from the R help mailing list archive at Nabble.com.
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



-- 
Dimitri Liakhovitski
MarketTools, Inc.
dimitri.liakhovit...@markettools.com

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] problem in reading data

2009-04-30 Thread tedzzx

Dear R users
I am runing into a problem in reading data in R
This is the error information

a<-read.table("tt_mb_200409.txt",as.is=T)
Error in scan(file, what, nmax, sep, dec, quote, skip, nlines, na.strings, 
: 
  line 1653997 did not have 5 elements

It seams that some lines don't have equal variables. I want to try

> a<-read.table("tt_mb_200409.txt",as.is=T,fill=T)
> a[1653997,]
   V1  V2V3 V4 V5
1653997 00992 2777010 

But, I want to delect the rows that do not have the same number of variables
with others, how can I do this?

Many thanks

Ted


-- 
View this message in context: 
http://www.nabble.com/problem-in-reading-data-tp23316321p23316321.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.