[R] create a table in the console!!

jim holtman jholtman at gmail.com
Tue Aug 18 17:29:27 CEST 2009


> # not sure what you want your data to look like, but
> # one alternative is to create a dataframe:
>
> x <- data.frame("GWP_Max"=20,
+     No_GWPMax= 8,
+     "[0-1000]"= 4,
+     "[1000-3000]"= 3,
+     "[> 3000]"= 5, check.names=FALSE)
> t(x)  # transpose for output
            [,1]
GWP_Max       20
No_GWPMax      8
[0-1000]       4
[1000-3000]    3
[> 3000]       5
>


On Tue, Aug 18, 2009 at 10:26 AM, Inchallah
Yarab<inchallahyarab at yahoo.fr> wrote:
> HI
>
> I want to do a table with R (in the console)
>
> GWP_Max NumberOfPolicies
> No_GWPMax 8
> [0-1000] 4
> [1000-3000] 3
> [> 3000] 5
>
> i begin by calculate the number of policies in each class :
>
>  Data1 <- read.csv2("c:/Total1.csv", sep=",")
>> Data2 <- read.csv2("c:/GWPMax1.csv",sep=",")[1:20,1:2]
>> M <- merge(Data1,Data2, by.x = "Policy.Number",by.y = "Policy.Number",all.x = TRUE,all.y = TRUE )
>> (No_GWPMax<-nrow(M[M[,25]=="NA",]))
> [1] 8
>> M2<- merge(Data1,Data2, by.x = "Policy.Number",by.y = "Policy.Number")
>> M2$GWP_Max <- as.numeric(as.character(M2$GWP_Max ))
>> class1 <- M2[M2[,25]>0 & M2[,25]<1000,]
>> (NbpolicyClass1 <- nrow(class1))
> [1] 5
>> class2 <- M2[M2[,25]>1000 & M2[,25]<3000,]
>> (NbpolicyClass2 <- nrow(class2))
> [1] 3
>> class3 <- M2[M2[,25]>3000,]
>> (NbpolicyClass3 <- nrow(class3))
> [1] 4
>
> can you help me ?
>
> thank you a lot!!
>
>
>
>        [[alternative HTML version deleted]]
>
>
> ______________________________________________
> R-help at 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?




More information about the R-help mailing list