[R] Strings to Numbers?

JeeBee JeeBee at troefpunt.nl
Thu Jun 22 21:20:53 CEST 2006

- The increment to i and j in your loops are done already, so remove them.
  try this to see what I mean:
  for(i in seq(1,5)) { print(i) }
- Provide us with a small (not with 378 rows) example that works,
  hence give us your yearly.
  Try str(yearly) to see for yourself what's in there exactly.

  My guess is there are factors in yearly (so your conference names are
  not strings as you think they are).
  See ?factor (type "?factor" in R without the quotes).

  If you used something like read.csv to import your yearly from a file,
  try adding as.is=TRUE there, that might also solve your problem.


> I am running the following command.
> for( i in 1:378){
> 	for (j in 1:5) {
> 				*********Year [((i-1)*5)+j,1]<- yearly[i,2];*********
> 				Year [((i-1)*5)+j,2] <- j;
> 				Year [((i-1)*5)+j,3] <- yearly[i,(j+2)];
> 				j <- (j+1);
> 			}
> 		i <- (i+1)
> 		}
> The array referenced yearly[i,2] contains conference names i.e. BIG12,
> SEC, BIG10.  The loop executes fine except for the fact that instead
> of the strings from yearly, Year[,1] contains numbers.
> Any suggestions.

More information about the R-help mailing list