View Issue Details

This bug affects 1 person(s).
 6
IDProjectCategoryView StatusLast Update
04644Bug reportsStatisticspublic2010-10-13 16:22
Reporteruser9189Assigned Tomdekker  
PrioritynormalSeverityminor 
Status closedResolutionfixed 
Product Version1.90+ 
Fixed in Version1.90+ 
Summary04644: Errors in Export R syntax file
Description
  1. There is one serious error:

The "lastpage" field doesn't get exported in the .csv file. In the R syntax file, the column numbering doesn't keep proper track of this. So, in the second line of the R syntax file, the columns get numbered sequentially:

names(data)=paste("V",1:dim(data)[2],sep="")

But the remainder of the script works with the field names as supplied by the spss_fieldmap() function. This means the data and the syntax file gets out of step (notice the missing V15):

data[,which(names(data)=="V14")]=as.character(data[,which(names(data)=="V14")])
data[,which(names(data)=="V16")]=as.character(data[,which(names(data)=="V16")])

The same error will recur for each hidden variable in the survey.

The fix for this is to have an indexing variable, e.g. $i that gets incremented when the foreach loop outputs something, and to use this indexing variable to refer to the columns.

  1. A second big problem is that the second to last line in the syntax file is written as one long string (v.names=(c....))

This possibly works fine when calling source(), but when loading into an editor, the line gets truncated.

The solution to this is to add a \n line break character between each column name.

  1. In addition, there are some encoding problems, meaning that a ' (single apostrophe) and - (minus) gets incorrectly encoded and escaped:
    ' gets encoded as ’
    • gets encoded as –

The solution to this is to use a combination of addslashes() and iconv().

  1. Finally, some relatively minor R issues. Although the = assignment operator works, it is actually better practise to use the <- assignment operator.
Additional Information

I attach a rewritten file with my proposed corrections to export_data_r.php

I have made substantial changes, the most important being to rewrite the logic to contain a single foreach loop. This has the side-effect of probably being more efficient, but the biggest reason is to ensure the incrementing of the $i variable is in only a single place.

I hope this is of help.

TagsNo tags attached.
Attached Files
export_data_r.php (11,461 bytes)
Bug heat6
Complete LimeSurvey version number (& build)9089
I will donate to the project if issue is resolved
BrowserFirefox
Database type & versionMySql 5.0.90
Server OS (if known)Linux
Webserver software & version (if known)Apache 1.3.42
PHP Version5.2.9

Users monitoring this issue

There are no users monitoring this issue.

Activities

c_schmitz

c_schmitz

2010-10-04 21:20

administrator   ~12989

Menno, can you please check if this looks okay and if the review comes out ok please commit it?

user9189

2010-10-04 23:05

  ~12993

Note: Ignore point 3 above. I traced the encoding problems to my survey data.

mdekker

mdekker

2010-10-11 14:44

reporter   ~13066

Patch looks good to me, tested on my local install and seems to work fine. Brought admin interface in line with spss export, giving the option to filter the response by completed, not completed or all.

committed in Rev 9205

c_schmitz

c_schmitz

2010-10-13 16:22

administrator   ~13121

Released in latest Plus version

Issue History

Date Modified Username Field Change
2010-10-01 19:19 user9189 New Issue
2010-10-01 19:19 user9189 File Added: export_data_r.php
2010-10-01 19:19 user9189 Issue Monitored: user9189
2010-10-04 21:18 c_schmitz Assigned To => mdekker
2010-10-04 21:18 c_schmitz Status new => assigned
2010-10-04 21:20 c_schmitz Note Added: 12989
2010-10-04 23:05 user9189 Note Added: 12993
2010-10-11 14:44 mdekker Note Added: 13066
2010-10-11 14:44 mdekker Status assigned => resolved
2010-10-11 14:44 mdekker Fixed in Version => 1.90+
2010-10-11 14:44 mdekker Resolution open => fixed
2010-10-13 16:22 c_schmitz Note Added: 13121
2010-10-13 16:22 c_schmitz Status resolved => closed